Skip to content

Commit 6acb744

Browse files
authored
Merge pull request #582 from mtconnect/581_add_2_7_asset_support
Added support for 2.7 Assets
2 parents cdc5986 + 9ef9d23 commit 6acb744

26 files changed

Lines changed: 4077 additions & 180 deletions

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# The version number.
22
set(AGENT_VERSION_MAJOR 2)
3-
set(AGENT_VERSION_MINOR 6)
3+
set(AGENT_VERSION_MINOR 7)
44
set(AGENT_VERSION_PATCH 0)
5-
set(AGENT_VERSION_BUILD 7)
6-
set(AGENT_VERSION_RC "")
5+
set(AGENT_VERSION_BUILD 1)
6+
set(AGENT_VERSION_RC "RC1")
77

88
# This minimum version is to support Visual Studio 2019 and C++ feature checking and FetchContent
99
cmake_minimum_required(VERSION 3.23 FATAL_ERROR)

agent_lib/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ set(AGENT_SOURCES
2727
"${SOURCE_DIR}/asset/component_configuration_parameters.hpp"
2828
"${SOURCE_DIR}/asset/physical_asset.hpp"
2929
"${SOURCE_DIR}/asset/fixture.hpp"
30+
"${SOURCE_DIR}/asset/part.hpp"
31+
"${SOURCE_DIR}/asset/process.hpp"
3032
"${SOURCE_DIR}/asset/pallet.hpp"
33+
"${SOURCE_DIR}/asset/target.hpp"
34+
"${SOURCE_DIR}/asset/task.hpp"
3135

3236
# src/asset SOURCE_FILES_ONLY
3337

@@ -39,7 +43,11 @@ set(AGENT_SOURCES
3943
"${SOURCE_DIR}/asset/component_configuration_parameters.cpp"
4044
"${SOURCE_DIR}/asset/physical_asset.cpp"
4145
"${SOURCE_DIR}/asset/fixture.cpp"
46+
"${SOURCE_DIR}/asset/part.cpp"
47+
"${SOURCE_DIR}/asset/process.cpp"
4248
"${SOURCE_DIR}/asset/pallet.cpp"
49+
"${SOURCE_DIR}/asset/target.cpp"
50+
"${SOURCE_DIR}/asset/task.cpp"
4351

4452
# src/buffer HEADER_FILES_ONLY
4553

src/mtconnect/agent.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,11 @@
4848
#include "mtconnect/asset/file_asset.hpp"
4949
#include "mtconnect/asset/fixture.hpp"
5050
#include "mtconnect/asset/pallet.hpp"
51+
#include "mtconnect/asset/part.hpp"
52+
#include "mtconnect/asset/process.hpp"
5153
#include "mtconnect/asset/qif_document.hpp"
5254
#include "mtconnect/asset/raw_material.hpp"
55+
#include "mtconnect/asset/task.hpp"
5356
#include "mtconnect/configuration/config_options.hpp"
5457
#include "mtconnect/device_model/agent_device.hpp"
5558
#include "mtconnect/entity/xml_parser.hpp"
@@ -102,6 +105,12 @@ namespace mtconnect {
102105
ComponentConfigurationParameters::registerAsset();
103106
Pallet::registerAsset();
104107
Fixture::registerAsset();
108+
Process::registerAsset();
109+
ProcessArchetype::registerAsset();
110+
Part::registerAsset();
111+
PartArchetype::registerAsset();
112+
Task::registerAsset();
113+
TaskArchetype::registerAsset();
105114

106115
m_assetStorage = make_unique<AssetBuffer>(
107116
GetOption<int>(options, mtconnect::configuration::MaxAssets).value_or(1024));

src/mtconnect/asset/asset.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,27 @@
1515
// limitations under the License.
1616
//
1717

18-
#include "mtconnect/asset/asset.hpp"
18+
#include "asset.hpp"
1919

2020
#include <map>
2121
#include <utility>
2222

23+
#include "mtconnect/device_model/configuration/configuration.hpp"
24+
2325
using namespace std;
2426

2527
namespace mtconnect {
2628
using namespace entity;
2729
namespace asset {
2830
FactoryPtr Asset::getFactory()
2931
{
32+
using namespace device_model::configuration;
3033
static auto asset = make_shared<Factory>(
31-
Requirements({Requirement("assetId", false), Requirement("deviceUuid", false),
32-
Requirement("timestamp", ValueType::TIMESTAMP, false),
33-
Requirement("hash", false),
34-
Requirement("removed", ValueType::BOOL, false)}),
34+
Requirements(
35+
{Requirement("assetId", false), Requirement("deviceUuid", false),
36+
Requirement("timestamp", ValueType::TIMESTAMP, false), Requirement("hash", false),
37+
Requirement("Configuration", ValueType::ENTITY, Configuration::getFactory(), false),
38+
Requirement("removed", ValueType::BOOL, false)}),
3539
[](const std::string &name, Properties &props) -> EntityPtr {
3640
return make_shared<Asset>(name, props);
3741
});

src/mtconnect/asset/part.cpp

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
//
2+
// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”)
3+
// All rights reserved.
4+
//
5+
// Licensed under the Apache License, Version 2.0 (the "License");
6+
// you may not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing, software
12+
// distributed under the License is distributed on an "AS IS" BASIS,
13+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
// See the License for the specific language governing permissions and
15+
// limitations under the License.
16+
//
17+
18+
#include "part.hpp"
19+
20+
using namespace std;
21+
22+
namespace mtconnect {
23+
using namespace entity;
24+
namespace asset {
25+
FactoryPtr PartArchetype::getFactory()
26+
{
27+
static FactoryPtr factory;
28+
if (!factory)
29+
{
30+
auto ext = make_shared<Factory>();
31+
ext->registerFactory(regex(".+"), ext);
32+
ext->setAny(true);
33+
ext->setList(true);
34+
35+
auto customer = make_shared<Factory>(Requirements {
36+
{"customerId", true},
37+
{"name", false},
38+
{"Address", false},
39+
{"Description", false},
40+
});
41+
42+
auto customers = make_shared<Factory>(Requirements {
43+
{"Customer", ValueType::ENTITY, customer, 1, entity::Requirement::Infinite}});
44+
45+
factory = make_shared<Factory>(*Asset::getFactory());
46+
factory->addRequirements({
47+
{"revision", true},
48+
{"family", false},
49+
{"drawing", false},
50+
{"Customers", ValueType::ENTITY_LIST, customers, false},
51+
});
52+
factory->registerFactory(regex(".+"), ext);
53+
factory->setAny(true);
54+
}
55+
return factory;
56+
}
57+
58+
void PartArchetype::registerAsset()
59+
{
60+
static bool once {true};
61+
if (once)
62+
{
63+
Asset::registerAssetType("PartArchetype", getFactory());
64+
once = false;
65+
}
66+
}
67+
68+
FactoryPtr Part::getFactory()
69+
{
70+
static FactoryPtr factory;
71+
if (!factory)
72+
{
73+
auto ext = make_shared<Factory>();
74+
ext->registerFactory(regex(".+"), ext);
75+
ext->setAny(true);
76+
ext->setList(true);
77+
78+
auto identifier = make_shared<Factory>(
79+
Requirements {{"type", ControlledVocab {"UNIQUE_IDENTIFIER", "GROUP_IDENTIFIER"}, true},
80+
{"stepIdRef", false},
81+
{"timestamp", ValueType::TIMESTAMP, true},
82+
{"VALUE", true}});
83+
84+
auto identifiers = make_shared<Factory>(Requirements {
85+
{"Identifier", ValueType::ENTITY, identifier, 1, entity::Requirement::Infinite}});
86+
87+
factory = make_shared<Factory>(*Asset::getFactory());
88+
factory->addRequirements({{"revision", true},
89+
{"family", false},
90+
{"drawing", false},
91+
{"PartIdentifiers", ValueType::ENTITY_LIST, identifiers, false}});
92+
factory->registerFactory(regex(".+"), ext);
93+
factory->setAny(true);
94+
}
95+
return factory;
96+
}
97+
98+
void Part::registerAsset()
99+
{
100+
static bool once {true};
101+
if (once)
102+
{
103+
Asset::registerAssetType("Part", getFactory());
104+
once = false;
105+
}
106+
}
107+
} // namespace asset
108+
} // namespace mtconnect

src/mtconnect/asset/part.hpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//
2+
// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”)
3+
// All rights reserved.
4+
//
5+
// Licensed under the Apache License, Version 2.0 (the "License");
6+
// you may not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing, software
12+
// distributed under the License is distributed on an "AS IS" BASIS,
13+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
// See the License for the specific language governing permissions and
15+
// limitations under the License.
16+
//
17+
18+
#pragma once
19+
20+
#include <map>
21+
#include <utility>
22+
#include <vector>
23+
24+
#include "asset.hpp"
25+
#include "mtconnect/entity/factory.hpp"
26+
#include "mtconnect/utilities.hpp"
27+
28+
namespace mtconnect::asset {
29+
/// @brief Manufacturing process archetype asset
30+
class AGENT_LIB_API PartArchetype : public Asset
31+
{
32+
public:
33+
static entity::FactoryPtr getFactory();
34+
static void registerAsset();
35+
};
36+
37+
/// @brief Manufacturing process asset
38+
class AGENT_LIB_API Part : public Asset
39+
{
40+
public:
41+
static entity::FactoryPtr getFactory();
42+
static void registerAsset();
43+
};
44+
} // namespace mtconnect::asset

src/mtconnect/asset/process.cpp

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
//
2+
// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”)
3+
// All rights reserved.
4+
//
5+
// Licensed under the Apache License, Version 2.0 (the "License");
6+
// you may not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing, software
12+
// distributed under the License is distributed on an "AS IS" BASIS,
13+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
// See the License for the specific language governing permissions and
15+
// limitations under the License.
16+
//
17+
18+
#include "process.hpp"
19+
20+
#include "target.hpp"
21+
22+
using namespace std;
23+
24+
namespace mtconnect {
25+
using namespace entity;
26+
namespace asset {
27+
FactoryPtr ProcessArchetype::getFactory()
28+
{
29+
static FactoryPtr factory;
30+
if (!factory)
31+
{
32+
auto activity =
33+
make_shared<Factory>(Requirements {{"sequence", ValueType::INTEGER, false},
34+
{"activityId", true},
35+
{"precedence", ValueType::INTEGER, false},
36+
{"optional", ValueType::BOOL, false},
37+
{"Description", false}});
38+
39+
auto activityGroup = make_shared<Factory>(Requirements {
40+
{"activityGroupId", true},
41+
{"name", false},
42+
{"Activity", ValueType::ENTITY, activity, 1, entity::Requirement::Infinite},
43+
});
44+
45+
auto activityGroups = make_shared<Factory>(Requirements {
46+
{"ActivityGroup", ValueType::ENTITY, activityGroup, 1, entity::Requirement::Infinite}});
47+
48+
auto processStep = make_shared<Factory>(
49+
Requirements {{{"stepId", true},
50+
{"optional", ValueType::BOOL, false},
51+
{"sequence", ValueType::INTEGER, false},
52+
{"Description", false},
53+
{"StartTime", ValueType::TIMESTAMP, false},
54+
{"Duration", ValueType::DOUBLE, false},
55+
{"Targets", ValueType::ENTITY_LIST, Target::getTargetsFactory(), false},
56+
{"ActivityGroups", ValueType::ENTITY_LIST, activityGroups, false}}});
57+
processStep->setOrder(
58+
{"Description", "StartTime", "Duration", "Targets", "ActivityGroups"});
59+
60+
auto routing = make_shared<Factory>(Requirements {
61+
{"precedence", ValueType::INTEGER, true},
62+
{"routingId", true},
63+
{"ProcessStep", ValueType::ENTITY, processStep, 1, entity::Requirement::Infinite},
64+
});
65+
66+
auto routings = make_shared<Factory>(Requirements {
67+
{"Routing", ValueType::ENTITY, routing, 1, entity::Requirement::Infinite}});
68+
69+
factory = make_shared<Factory>(*Asset::getFactory());
70+
factory->addRequirements({
71+
{"revision", true},
72+
{"Targets", ValueType::ENTITY_LIST, Target::getTargetsFactory(), false},
73+
{"Routings", ValueType::ENTITY_LIST, routings, true},
74+
});
75+
factory->setOrder({"Configuration", "Routings", "Targets"});
76+
}
77+
return factory;
78+
}
79+
80+
void ProcessArchetype::registerAsset()
81+
{
82+
static bool once {true};
83+
if (once)
84+
{
85+
Asset::registerAssetType("ProcessArchetype", getFactory());
86+
once = false;
87+
}
88+
}
89+
90+
FactoryPtr Process::getFactory()
91+
{
92+
static FactoryPtr factory;
93+
if (!factory)
94+
{
95+
factory = ProcessArchetype::getFactory()->deepCopy();
96+
auto routings = factory->getRequirement("Routings");
97+
auto routing = routings->getFactory()->getRequirement("Routing");
98+
routing->setMultiplicity(1, 1);
99+
}
100+
return factory;
101+
}
102+
103+
void Process::registerAsset()
104+
{
105+
static bool once {true};
106+
if (once)
107+
{
108+
Asset::registerAssetType("Process", getFactory());
109+
once = false;
110+
}
111+
}
112+
} // namespace asset
113+
} // namespace mtconnect

0 commit comments

Comments
 (0)