Skip to content

Commit

Permalink
Merge pull request #253 from mtconnect/add_units_and_native_units_to_…
Browse files Browse the repository at this point in the history
…solid_model

Added additional attributes to SolidModel per 2.0
  • Loading branch information
wsobel authored Aug 1, 2022
2 parents 2dc0f67 + 62bef55 commit 60e0e2d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set(AGENT_VERSION_MAJOR 2)
set(AGENT_VERSION_MINOR 0)
set(AGENT_VERSION_PATCH 0)
set(AGENT_VERSION_BUILD 10)
set(AGENT_VERSION_BUILD 11)
set(AGENT_VERSION_RC "")

# This minimum version is to support Visual Studio 2017 and C++ feature checking and FetchContent
Expand Down
2 changes: 1 addition & 1 deletion samples/solid_model.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<Components>
<Rotary name="C" id="c">
<Configuration>
<SolidModel id="cm" mediaType="STL" solidModelIdRef="dm" itemRef="spindle" coordinateSystemIdRef="machine">
<SolidModel id="cm" mediaType="STL" solidModelIdRef="dm" itemRef="spindle" coordinateSystemIdRef="machine" units="MILLIMETER" nativeUnits="METER">
<Transformation>
<Translation>10 20 30</Translation>
<Rotation>90 -90 180</Rotation>
Expand Down
22 changes: 14 additions & 8 deletions src/device_model/configuration/solid_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,21 @@ namespace mtconnect {
Requirement("Rotation", VECTOR, 3, false)});

solidModel = make_shared<Factory>(
Requirements {Requirement("id", true), Requirement("solidModelIdRef", false),
Requirement("href", false), Requirement("itemRef", false),
Requirement("mediaType",
ControlledVocab {"STEP", "STL", "GDML", "OBJ", "COLLADA",
Requirements {
{"id", true},
{"units", false},
{"nativeUnits", false},
{"coordinateSystemIdRef", false},
{"solidModelIdRef", false},
{"href", false},
{"itemRef", false},
{"mediaType", ControlledVocab {"STEP", "STL", "GDML", "OBJ", "COLLADA",
"IGES", "3DS", "ACIS", "X_T"},
true),
Requirement("coordinateSystemIdRef", false),
Requirement("Transformation", ENTITY, transformation, false),
Requirement("Scale", VECTOR, 3, false)});
true},

{"Transformation", ENTITY, transformation, false},
{"Scale", VECTOR, 3, false}}
);

solidModel->registerMatchers();
}
Expand Down
4 changes: 3 additions & 1 deletion test/solid_model_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ TEST_F(SolidModelTest, ParseRotarySolidModel)
ASSERT_EQ("spindle", model->get<string>("itemRef"));
ASSERT_EQ("STL", model->get<string>("mediaType"));
ASSERT_EQ("machine", model->get<string>("coordinateSystemIdRef"));
ASSERT_EQ("MILLIMETER", model->get<string>("units"));
ASSERT_EQ("METER", model->get<string>("nativeUnits"));

auto tf = model->maybeGet<EntityPtr>("Transformation");
ASSERT_TRUE(tf);
Expand Down Expand Up @@ -187,7 +189,7 @@ TEST_F(SolidModelTest, RotaryJsonPrinting)
auto model = rotary.at("/Configuration/SolidModel"_json_pointer);
ASSERT_TRUE(model.is_object());

ASSERT_EQ(6, model.size());
ASSERT_EQ(8, model.size());
EXPECT_EQ("cm", model["id"]);
EXPECT_EQ("STL", model["mediaType"]);
EXPECT_EQ("machine", model["coordinateSystemIdRef"]);
Expand Down

0 comments on commit 60e0e2d

Please sign in to comment.