コード例 #1
0
  @Test
  public void xmlParsedInfo_serialize() {

    // make TypeSpecReal
    TypeSpecReal typeSpecReal_0 = new TypeSpecReal();
    typeSpecReal_0.start = 20.25;
    typeSpecReal_0.nominal = 21.25;
    typeSpecReal_0.min = 22.25;
    typeSpecReal_0.max = 23.25;
    typeSpecReal_0.unit = "C";

    typeSpecReal_0.startValueStatus = 1;
    typeSpecReal_0.nominalValueStatus = 1;
    typeSpecReal_0.minValueStatus = 1;
    typeSpecReal_0.maxValueStatus = 1;
    typeSpecReal_0.unitValueStatus = 1;

    // make ScalarVariableReal
    ScalarVariableReal scalarVariableReal_0 = new ScalarVariableReal(typeSpecReal_0);
    scalarVariableReal_0.setName("scalarVar name");
    scalarVariableReal_0.setIdx(1);
    scalarVariableReal_0.setCausality(Enu.enu_input);
    scalarVariableReal_0.setVariability(Enu.enu_continuous);
    scalarVariableReal_0.setDescription("The Description 1");
    scalarVariableReal_0.setValueReference(125420);

    // make TypeSpecReal 2
    TypeSpecReal typeSpecReal_1 = new TypeSpecReal();
    typeSpecReal_1.start = 2.25;
    typeSpecReal_1.nominal = 2.25;
    typeSpecReal_1.min = 2.25;
    typeSpecReal_1.max = 2.25;
    typeSpecReal_1.unit = "Pa";

    typeSpecReal_1.startValueStatus = 1;
    typeSpecReal_1.nominalValueStatus = 1;
    typeSpecReal_1.minValueStatus = 1;
    typeSpecReal_1.maxValueStatus = 1;
    typeSpecReal_1.unitValueStatus = 1;

    // make ScalarVariableReal 2
    ScalarVariableReal scalarVariableReal_1 = new ScalarVariableReal(typeSpecReal_1);
    scalarVariableReal_1.setName("scalarVar name");
    scalarVariableReal_1.setIdx(1);
    scalarVariableReal_1.setCausality(Enu.enu_input);
    scalarVariableReal_1.setVariability(Enu.enu_discrete);
    scalarVariableReal_1.setDescription("The Description");
    scalarVariableReal_1.setValueReference(125420);

    SerializableVector<ScalarVariableReal> realVarList =
        new SerializableVector<ScalarVariableReal>("ScalarVariableReal");
    realVarList.add(scalarVariableReal_0);
    realVarList.add(scalarVariableReal_1);

    ScalarVariableCollection sVarColl = new ScalarVariableCollection();
    sVarColl.setRealVarList(realVarList);

    // make scalarVariablesAll 1
    ScalarVariablesAll scalarVariablesAll = new ScalarVariablesAll();
    scalarVariablesAll.setInput(sVarColl);
    scalarVariablesAll.setOutput(sVarColl);
    scalarVariablesAll.setInternal(sVarColl);

    // make SimStateWrapper 1
    XMLparsedInfo xmlParsedInfo = new XMLparsedInfo(scalarVariablesAll);

    // serialize
    String json = xmlParsedInfo.serialize();

    assertEquals(
        "{\"t\":\"XMLparsedInfo\",\"scalarVariablesAll_\":{\"t\":\"ScalarVariablesAll\",\"input\":{\"t\":\"ScalarVariableCollection\",\"realVarList_\":[{\"t\":\"ScalarVariableReal\",\"n\":\"scalarVar name\",\"i\":1,\"c\":6,\"vb\":5,\"d\":\"The Description 1\",\"vr\":125420,\"typeSpecReal\":{\"t\":\"TypeSpecReal\",\"start\":20.25,\"nominal\":21.25,\"min\":22.25,\"max\":23.25,\"unit\":\"C\"}},{\"t\":\"ScalarVariableReal\",\"n\":\"scalarVar name\",\"i\":1,\"c\":6,\"vb\":4,\"d\":\"The Description\",\"vr\":125420,\"typeSpecReal\":{\"t\":\"TypeSpecReal\",\"start\":2.25,\"nominal\":2.25,\"min\":2.25,\"max\":2.25,\"unit\":\"Pa\"}}]},\"output\":{\"t\":\"ScalarVariableCollection\",\"realVarList_\":[{\"t\":\"ScalarVariableReal\",\"n\":\"scalarVar name\",\"i\":1,\"c\":6,\"vb\":5,\"d\":\"The Description 1\",\"vr\":125420,\"typeSpecReal\":{\"t\":\"TypeSpecReal\",\"start\":20.25,\"nominal\":21.25,\"min\":22.25,\"max\":23.25,\"unit\":\"C\"}},{\"t\":\"ScalarVariableReal\",\"n\":\"scalarVar name\",\"i\":1,\"c\":6,\"vb\":4,\"d\":\"The Description\",\"vr\":125420,\"typeSpecReal\":{\"t\":\"TypeSpecReal\",\"start\":2.25,\"nominal\":2.25,\"min\":2.25,\"max\":2.25,\"unit\":\"Pa\"}}]},\"internal\":{\"t\":\"ScalarVariableCollection\",\"realVarList_\":[{\"t\":\"ScalarVariableReal\",\"n\":\"scalarVar name\",\"i\":1,\"c\":6,\"vb\":5,\"d\":\"The Description 1\",\"vr\":125420,\"typeSpecReal\":{\"t\":\"TypeSpecReal\",\"start\":20.25,\"nominal\":21.25,\"min\":22.25,\"max\":23.25,\"unit\":\"C\"}},{\"t\":\"ScalarVariableReal\",\"n\":\"scalarVar name\",\"i\":1,\"c\":6,\"vb\":4,\"d\":\"The Description\",\"vr\":125420,\"typeSpecReal\":{\"t\":\"TypeSpecReal\",\"start\":2.25,\"nominal\":2.25,\"min\":2.25,\"max\":2.25,\"unit\":\"Pa\"}}]}},\"sessionID_\":\"xxo\"}",
        json);
  }
コード例 #2
0
  @Test
  public void scalarVariablesAll_serialize() {

    // make TypeSpecReal
    TypeSpecReal typeSpecReal = new TypeSpecReal();
    typeSpecReal.start = 20.25;
    typeSpecReal.nominal = 21.25;
    typeSpecReal.min = 22.25;
    typeSpecReal.max = 23.25;

    typeSpecReal.startValueStatus = 1;
    typeSpecReal.nominalValueStatus = 1;
    typeSpecReal.minValueStatus = 1;
    typeSpecReal.maxValueStatus = 1;

    // make ScalarVariableReal
    ScalarVariableReal sVarReal = new ScalarVariableReal(typeSpecReal);
    sVarReal.setName("scalarVar name");
    sVarReal.setIdx(1);
    sVarReal.setCausality(Enu.enu_input);
    sVarReal.setVariability(Enu.enu_discrete);
    sVarReal.setDescription("The Description");
    sVarReal.setValueReference(125420);

    // make TypeSpecReal 2
    TypeSpecReal typeSpecReal2 = new TypeSpecReal();
    typeSpecReal2.start = 2.25;
    typeSpecReal2.nominal = 2.25;
    typeSpecReal2.min = 2.25;
    typeSpecReal2.max = 2.25;

    typeSpecReal2.startValueStatus = 1;
    typeSpecReal2.nominalValueStatus = 1;
    typeSpecReal2.minValueStatus = 1;
    typeSpecReal2.maxValueStatus = 1;

    // make ScalarVariableReal 2
    ScalarVariableReal sVarReal2 = new ScalarVariableReal(typeSpecReal);
    sVarReal2.setName("scalarVar name");
    sVarReal2.setIdx(1);
    sVarReal2.setCausality(Enu.enu_input);
    sVarReal2.setVariability(Enu.enu_discrete);
    sVarReal2.setDescription("The Description");
    sVarReal2.setValueReference(125420);

    SerializableVector<ScalarVariableReal> realVarList =
        new SerializableVector<ScalarVariableReal>("ScalarVariableReal");
    realVarList.add(sVarReal);
    realVarList.add(sVarReal2);

    ScalarVariableCollection sVarColl = new ScalarVariableCollection();
    sVarColl.setRealVarList(realVarList);

    // make scalarVariablesAll 1
    ScalarVariablesAll scalarVariablesAll = new ScalarVariablesAll();
    scalarVariablesAll.setInput(sVarColl);
    scalarVariablesAll.setOutput(sVarColl);
    scalarVariablesAll.setInternal(sVarColl);

    // serialize / deserialize
    String json = scalarVariablesAll.serialize();

    assertEquals(
        "{\"t\":\"ScalarVariablesAll\",\"input\":{\"t\":\"ScalarVariableCollection\",\"realVarList_\":[{\"t\":\"ScalarVariableReal\",\"n\":\"scalarVar name\",\"i\":1,\"c\":6,\"vb\":4,\"d\":\"The Description\",\"vr\":125420,\"typeSpecReal\":{\"t\":\"TypeSpecReal\",\"start\":20.25,\"nominal\":21.25,\"min\":22.25,\"max\":23.25,\"unit\":\"\"}},{\"t\":\"ScalarVariableReal\",\"n\":\"scalarVar name\",\"i\":1,\"c\":6,\"vb\":4,\"d\":\"The Description\",\"vr\":125420,\"typeSpecReal\":{\"t\":\"TypeSpecReal\",\"start\":20.25,\"nominal\":21.25,\"min\":22.25,\"max\":23.25,\"unit\":\"\"}}]},\"output\":{\"t\":\"ScalarVariableCollection\",\"realVarList_\":[{\"t\":\"ScalarVariableReal\",\"n\":\"scalarVar name\",\"i\":1,\"c\":6,\"vb\":4,\"d\":\"The Description\",\"vr\":125420,\"typeSpecReal\":{\"t\":\"TypeSpecReal\",\"start\":20.25,\"nominal\":21.25,\"min\":22.25,\"max\":23.25,\"unit\":\"\"}},{\"t\":\"ScalarVariableReal\",\"n\":\"scalarVar name\",\"i\":1,\"c\":6,\"vb\":4,\"d\":\"The Description\",\"vr\":125420,\"typeSpecReal\":{\"t\":\"TypeSpecReal\",\"start\":20.25,\"nominal\":21.25,\"min\":22.25,\"max\":23.25,\"unit\":\"\"}}]},\"internal\":{\"t\":\"ScalarVariableCollection\",\"realVarList_\":[{\"t\":\"ScalarVariableReal\",\"n\":\"scalarVar name\",\"i\":1,\"c\":6,\"vb\":4,\"d\":\"The Description\",\"vr\":125420,\"typeSpecReal\":{\"t\":\"TypeSpecReal\",\"start\":20.25,\"nominal\":21.25,\"min\":22.25,\"max\":23.25,\"unit\":\"\"}},{\"t\":\"ScalarVariableReal\",\"n\":\"scalarVar name\",\"i\":1,\"c\":6,\"vb\":4,\"d\":\"The Description\",\"vr\":125420,\"typeSpecReal\":{\"t\":\"TypeSpecReal\",\"start\":20.25,\"nominal\":21.25,\"min\":22.25,\"max\":23.25,\"unit\":\"\"}}]}}",
        json);
  }