Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions agent_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ set(AGENT_SOURCES
"${SOURCE_DIR}/asset/raw_material.hpp"
"${SOURCE_DIR}/asset/qif_document.hpp"
"${SOURCE_DIR}/asset/component_configuration_parameters.hpp"
"${SOURCE_DIR}/asset/physical_asset.hpp"
"${SOURCE_DIR}/asset/fixture.hpp"
"${SOURCE_DIR}/asset/pallet.hpp"

# src/asset SOURCE_FILES_ONLY

Expand All @@ -34,6 +37,9 @@ set(AGENT_SOURCES
"${SOURCE_DIR}/asset/raw_material.cpp"
"${SOURCE_DIR}/asset/qif_document.cpp"
"${SOURCE_DIR}/asset/component_configuration_parameters.cpp"
"${SOURCE_DIR}/asset/physical_asset.cpp"
"${SOURCE_DIR}/asset/fixture.cpp"
"${SOURCE_DIR}/asset/pallet.cpp"

# src/buffer HEADER_FILES_ONLY

Expand Down
26 changes: 15 additions & 11 deletions src/mtconnect/agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
#include "mtconnect/asset/component_configuration_parameters.hpp"
#include "mtconnect/asset/cutting_tool.hpp"
#include "mtconnect/asset/file_asset.hpp"
#include "mtconnect/asset/fixture.hpp"
#include "mtconnect/asset/pallet.hpp"
#include "mtconnect/asset/qif_document.hpp"
#include "mtconnect/asset/raw_material.hpp"
#include "mtconnect/configuration/config_options.hpp"
Expand Down Expand Up @@ -98,6 +100,8 @@ namespace mtconnect {
RawMaterial::registerAsset();
QIFDocumentWrapper::registerAsset();
ComponentConfigurationParameters::registerAsset();
Pallet::registerAsset();
Fixture::registerAsset();

m_assetStorage = make_unique<AssetBuffer>(
GetOption<int>(options, mtconnect::configuration::MaxAssets).value_or(1024));
Expand Down Expand Up @@ -242,7 +246,7 @@ namespace mtconnect {
// Start all the sources
for (auto source : m_sources)
source->start();

m_afterStartHooks.exec(*this);
}
catch (std::runtime_error &e)
Expand Down Expand Up @@ -478,11 +482,11 @@ namespace mtconnect {
changed = receiveDevice(device, true) || changed;
if (changed)
{
if (source)
{
auto s = findSource(*source);
if (s)
if (source)
{
auto s = findSource(*source);
if (s)
{
s->setOptions({{config::Device, uuid}});
}
}
Expand Down Expand Up @@ -1018,7 +1022,7 @@ namespace mtconnect {
if (m_agentDevice)
{
auto d = m_agentDevice->getDeviceDataItem("device_removed");
if (d)
if (d)
m_loopback->receive(d, oldUuid);
}
}
Expand Down Expand Up @@ -1465,12 +1469,12 @@ namespace mtconnect {
{
try
{
double fact_value = stod(factor);
double off_value = stod(offset);
double fact_value = stod(factor);
double off_value = stod(offset);

device_model::data_item::UnitConversion conv(fact_value, off_value);
di->setConverter(conv);
}
device_model::data_item::UnitConversion conv(fact_value, off_value);
di->setConverter(conv);
}
catch (std::exception e)
{
LOG(error) << "Cannot convert factor " << factor << " or " << offset
Expand Down
19 changes: 9 additions & 10 deletions src/mtconnect/agent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ namespace mtconnect {
/// @brief Hooks to run when before the agent starts all the soures and sinks
/// @return configuration::HookManager<Agent>&
auto &beforeStartHooks() { return m_beforeStartHooks; }

/// @brief Hooks to run when after the agent starts all the soures and sinks
/// @return configuration::HookManager<Agent>&
auto &afterStartHooks() { return m_afterStartHooks; }
Expand Down Expand Up @@ -663,7 +663,7 @@ namespace mtconnect {
}

buffer::CircularBuffer &getCircularBuffer() override { return m_agent->getCircularBuffer(); }

configuration::HookManager<Agent> &getHooks(HookType type) override
{
using namespace sink;
Expand All @@ -672,41 +672,40 @@ namespace mtconnect {
case BEFORE_START:
return m_agent->beforeStartHooks();
break;

case AFTER_START:
return m_agent->afterStartHooks();
break;

case BEFORE_STOP:
return m_agent->beforeStopHooks();
break;

case BEFORE_DEVICE_XML_UPDATE:
return m_agent->beforeDeviceXmlUpdateHooks();
break;

case AFTER_DEVICE_XML_UPDATE:
return m_agent->afterDeviceXmlUpdateHooks();
break;

case BEFORE_INITIALIZE:
return m_agent->beforeInitializeHooks();
break;

case AFTER_INITIALIZE:
return m_agent->afterInitializeHooks();
break;
}

LOG(error) << "getHooks: Bad hook manager type given to sink contract";
throw std::runtime_error("getHooks: Bad hook manager type");

// Never gets here.
static configuration::HookManager<Agent> NullHooks;
return NullHooks;
}


protected:
Agent *m_agent;
};
Expand Down
14 changes: 1 addition & 13 deletions src/mtconnect/asset/cutting_tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,7 @@ namespace mtconnect {
Requirement("nominal", ValueType::DOUBLE, false),
Requirement("VALUE", ValueType::DOUBLE, false)}));

static auto measurement = make_shared<Factory>(Requirements(
{Requirement("significantDigits", ValueType::INTEGER, false),
Requirement("units", false), Requirement("nativeUnits", false),
Requirement("code", false), Requirement("maximum", ValueType::DOUBLE, false),
Requirement("minimum", ValueType::DOUBLE, false),
Requirement("nominal", ValueType::DOUBLE, false),
Requirement("VALUE", ValueType::DOUBLE, false)}));

static auto measurements = make_shared<Factory>(Requirements({Requirement(
"Measurement", ValueType::ENTITY, measurement, 1, Requirement::Infinite)}));
measurements->registerMatchers();
measurements->registerFactory(regex(".+"), measurement);
static auto measurements = PhysicalAsset::getMeasurementsFactory()->deepCopy();

static auto ext = make_shared<Factory>();
ext->registerFactory(regex(".+"), ext);
Expand All @@ -83,7 +72,6 @@ namespace mtconnect {
item->registerFactory(regex(".+"), ext);
item->setAny(true);

measurements->registerMatchers();
item->setOrder({"Description", "CutterStatus", "Locus", "ItemLife", "ProgramToolGroup",
"Measurements"});

Expand Down
1 change: 1 addition & 0 deletions src/mtconnect/asset/cutting_tool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <vector>

#include "asset.hpp"
#include "mtconnect/asset/physical_asset.hpp"
#include "mtconnect/config.hpp"
#include "mtconnect/utilities.hpp"

Expand Down
54 changes: 54 additions & 0 deletions src/mtconnect/asset/fixture.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#include "fixture.hpp"

using namespace std;

namespace mtconnect::asset {
using namespace entity;

FactoryPtr Fixture::getFactory()
{
static FactoryPtr factory;
if (!factory)
{
factory = make_shared<Factory>(*PhysicalAsset::getFactory());
factory->addRequirements(Requirements {{"FixtureId", ValueType::STRING, false},
{"FixtureNumber", ValueType::INTEGER, false},
{"ClampingMethod", ValueType::STRING, false},
{"MountingMethod", ValueType::STRING, false}});

factory->setOrder({"ManufactureDate", "CalibrationDate", "InspectionDate",
"NextInspectionDate", "Measurements", "FixtureId", "FixtureNumber",
"ClampingMethod", "MountingMethod"});
}

return factory;
}

void Fixture::registerAsset()
{
static bool once {true};
if (once)
{
Asset::registerAssetType("Fixture", getFactory());
once = false;
}
}

} // namespace mtconnect::asset
37 changes: 37 additions & 0 deletions src/mtconnect/asset/fixture.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#pragma once

#include <map>
#include <utility>
#include <vector>

#include "mtconnect/entity/entity.hpp"
#include "mtconnect/entity/factory.hpp"
#include "mtconnect/utilities.hpp"
#include "physical_asset.hpp"

namespace mtconnect::asset {
/// @brief abstract Physical Asset
class AGENT_LIB_API Fixture : public PhysicalAsset
{
public:
static entity::FactoryPtr getFactory();
static void registerAsset();
};
} // namespace mtconnect::asset
55 changes: 55 additions & 0 deletions src/mtconnect/asset/pallet.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#include "pallet.hpp"

using namespace std;

namespace mtconnect::asset {
using namespace entity;

FactoryPtr Pallet::getFactory()
{
static FactoryPtr factory;
if (!factory)
{
factory = make_shared<Factory>(*PhysicalAsset::getFactory());
factory->addRequirements(Requirements {{"Type", ValueType::STRING, false},
{"PalletId", ValueType::STRING, false},
{"PalletNumber", ValueType::INTEGER, false},
{"ClampingMethod", ValueType::STRING, false},
{"MountingMethod", ValueType::STRING, false}});

factory->setOrder({"ManufactureDate", "CalibrationDate", "InspectionDate",
"NextInspectionDate", "Measurements", "Type", "PalletId", "PalletNumber",
"ClampingMethod", "MountingMethod"});
}

return factory;
}

void Pallet::registerAsset()
{
static bool once {true};
if (once)
{
Asset::registerAssetType("Pallet", getFactory());
once = false;
}
}

} // namespace mtconnect::asset
37 changes: 37 additions & 0 deletions src/mtconnect/asset/pallet.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#pragma once

#include <map>
#include <utility>
#include <vector>

#include "mtconnect/entity/entity.hpp"
#include "mtconnect/entity/factory.hpp"
#include "mtconnect/utilities.hpp"
#include "physical_asset.hpp"

namespace mtconnect::asset {
/// @brief abstract Physical Asset
class AGENT_LIB_API Pallet : public PhysicalAsset
{
public:
static entity::FactoryPtr getFactory();
static void registerAsset();
};
} // namespace mtconnect::asset
Loading
Loading