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
68 changes: 67 additions & 1 deletion GMS/BasicGMS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Copyright 2022 (c) Sebastian Friedl, ISW University of Stuttgart (for VDMA e.V.)
* Copyright 2022 (c) Alen Galinec
*/

#include "BasicGMS.hpp"

#include <sstream>
#include <string>
#include <unordered_map>

#include "../TypeDefinition/GMS/Constants.hpp"
#include "../TypeDefinition/GMS/GMSType.hpp"
#include "../TypeDefinition/TypeDefinition.hpp"

BasicGMS::BasicGMS(UA_Server* pServer) : InstantiatedMachineTool(pServer) {
BasicGMS::BasicGMS(UA_Server* pServer) : InstantiatedGMS(pServer) {
MachineName = "BasicGMS";
CreateObject();
}
Expand Down Expand Up @@ -42,8 +46,10 @@ void BasicGMS::CreateObject() {
InstantiateIdentification();
InstantiateMonitoring();
InstantiateProduction();
InstantiateEquipment();
InstantiateTools();
InstantiateResultManagement();
InstantiateNotification();

InstantiateOptional(mt.Notification->Prognoses, m_pServer, n);
InstantiateOptional(mt.Notification->Prognoses->Calibration, m_pServer, n);
Expand Down Expand Up @@ -179,6 +185,66 @@ void BasicGMS::InstantiateTools() {
}
}

void BasicGMS::InstantiateEquipment() {
InstantiateOptional(gms.Equipment->Tools, m_pServer, n);

auto &sensor1 = InstantiateSensor("Sensor1");
sensor1.Class->Value = 2; /* TactileTouchTrigger */
sensor1.ControlIdentifier1 = 11;
sensor1.ControlIdentifier2 = 3;
sensor1.ControlIdentifierInterpretation = UA_ToolManagement::UA_TOOLMANAGEMENT_GROUPBASED;
sensor1.Locked->Value = true;
sensor1.Locked->ReasonForLocking = UA_ToolLocked::UA_TOOLLOCKED_BYOPERATOR;
sensor1.Name = "T11_P3";
InstantiateOptional(sensor1.ControlIdentifier2, m_pServer, n);
InstantiateOptional(sensor1.Name, m_pServer, n);

// Additional SensorType members
InstantiateOptional(sensor1.Alignment, m_pServer, n);
sensor1.Alignment = UA_ToolAlignmentState::UA_TOOLALIGNMENTSTATE_INDEXED;

// TODO: What is the correct format of the "Axes" property according to the spec?
InstantiateOptional(sensor1.Axes, m_pServer, n);
sensor1.Axes->push_back("X");
sensor1.Axes->push_back("Y");

InstantiateOptional(sensor1.Capabilities, m_pServer, n);
// sensor1.Capabilities->push_back(UA_ToolCapabilities::UA_TOOLCAPABILITIES_PTMEAS);

InstantiateOptional(sensor1.IsQualifiedStatus, m_pServer, n);
/// \todo Must be updated to release specification
sensor1.IsQualifiedStatus = UA_ToolIsQualifiedStatus::UA_TOOLISQUALIFIEDSTATUS_QUALIFIED;

// EUInformation for Days according to CEFACT
const UmatiServerLib::EUInformation_t EU_Days{
.NamespaceUri = "http://www.opcfoundation.org/UA/units/un/cefact", .UnitId = 4473177, .DisplayName = {"", "d"}, .Description = {"", "days"}};

sensor1.ToolLife->Qualified->EngineeringUnits = EU_Days;
sensor1.ToolLife->Qualified->IsCountingUp = true;
sensor1.ToolLife->Qualified->StartValue = 0;
sensor1.ToolLife->Qualified->WarningValue = 5;
sensor1.ToolLife->Qualified->LimitValue = 7;
sensor1.ToolLife->Qualified->Value = 1;
InstantiateOptional(sensor1.ToolLife, m_pServer, n);
InstantiateOptional(sensor1.ToolLife->Qualified, m_pServer, n);
InstantiateOptional(sensor1.ToolLife->Qualified->Value, m_pServer, n);
InstantiateOptional(sensor1.ToolLife->Qualified->StartValue, m_pServer, n);
InstantiateOptional(sensor1.ToolLife->Qualified->WarningValue, m_pServer, n);
InstantiateOptional(sensor1.ToolLife->Qualified->LimitValue, m_pServer, n);
}

void BasicGMS::InstantiateNotification() {
InstantiateOptional(gms.Notification->Prognoses, m_pServer, n);
InstantiateOptional(gms.Notification->Prognoses->Calibration, m_pServer, n);
gms.Notification->Prognoses->Calibration.value.Calibrated = true;
InstantiateOptional(gms.Notification->Prognoses->Calibration->CalibrationCertificate, m_pServer, n);
{
std::stringstream ss;
ss << "https://www.ptb.de/dcc/#" << MachineName;
gms.Notification->Prognoses->Calibration.value.CalibrationCertificate->push_back(ss.str());
}
}

void BasicGMS::Simulate() {
++m_simStep;
int i = m_simStep;
Expand Down
8 changes: 6 additions & 2 deletions GMS/BasicGMS.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Copyright 2022 (c) Sebastian Friedl, ISW University of Stuttgart (for VDMA e.V.)
* Copyright 2022 (c) Alen Galinec
*/

#pragma once
#include "../MachineTools/InstantiatedMachineTool.hpp"

#include "../TypeDefinition/GMS/GMSType.hpp"
#include "InstantiatedGMS.hpp"

class BasicGMS : public InstantiatedMachineTool {
class BasicGMS : public InstantiatedGMS {
public:
BasicGMS(UA_Server* pServer);

Expand All @@ -25,6 +27,8 @@ class BasicGMS : public InstantiatedMachineTool {
void InstantiateMonitoring();
void InstantiateProduction();
void InstantiateTools();
void InstantiateEquipment() override;
void InstantiateNotification() override;
int m_simStep = 0;

void initCorrection(GMS::CorrectionType_t& corr, std::string Identifier, std::string CharacteristicIdentifier, double value);
Expand Down
6 changes: 6 additions & 0 deletions GMS/InstantiatedGMS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ void InstantiatedGMS::InstantiateResultManagement() {}

void InstantiatedGMS::InstantiateMonitoring() {}

void InstantiatedGMS::SimulateStacklight() {
for (auto& light : gms.Monitoring->Stacklight->OrderedObjects.value) {
light->SignalOn = (rnd() % 2) == 0;
}
}

GMS::GMSSensor_t& InstantiatedGMS::InstantiateSensor(std::string const& sensorName) {
// It seems very wasteful for every instance of a sensor to have its own copy of the "Class" EnumStrings[].
// I assume this array is the same for all the sensors of the instance.
Expand Down
2 changes: 2 additions & 0 deletions GMS/InstantiatedGMS.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <cstdint>
#include <unordered_map>

#include "../MachineTools/InstantiatedMachineTool.hpp"
#include "../MachineTools/SimulatedInstance.hpp"
#include "../TypeDefinition/GMS/GMSType.hpp"
#include "../UmatiServerLib/NodesMaster.hpp"
Expand All @@ -33,6 +34,7 @@ class InstantiatedGMS : public SimulatedInstance {
virtual void InstantiateProduction();
virtual void InstantiateResultManagement();
virtual void InstantiateMonitoring();
virtual void SimulateStacklight();

// TODO: Take care of subcomponents later
// virtual void InstantiateNotificationCalibration();
Expand Down
8 changes: 4 additions & 4 deletions SampleServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
#include "AdditiveManufacturing/BasicAMMachine.hpp"
#include "AdditiveManufacturing/ShowcaseAMMachine.hpp"
#include "Configuration/Configuration_json.hpp"
#include "GMS/BasicGMS.hpp"
/* #include "GMS/FullGMS.hpp" */
// #include "GMS/BasicGMS.hpp"
#include "GMS/FullGMS.hpp"
#include "GMS/HexagonGlobal.hpp"
#include "GMS/HexagonSim.hpp"
#include "GMS/OGPSmartScopeCNC500.hpp"
Expand Down Expand Up @@ -250,12 +250,12 @@ int main(int argc, char* argv[]) {
/*machineTools.push_back(std::make_shared<BasicRobot>(pServer));*/
machineTools.push_back(std::make_shared<BasicWoodworking>(pServer));
machineTools.push_back(std::make_shared<FullWoodworking>(pServer));
machineTools.push_back(std::make_shared<BasicGMS>(pServer));
// machineTools.push_back(std::make_shared<BasicGMS>(pServer));
machineTools.push_back(std::make_shared<HexagonSim>(pServer));
machineTools.push_back(std::make_shared<HexagonGlobal>(pServer));
machineTools.push_back(std::make_shared<OGPSmartScopeCNC500>(pServer));
machineTools.push_back(std::make_shared<WenzelLH>(pServer));
/*machineTools.push_back(std::make_shared<FullGMS>(pServer));*/
machineTools.push_back(std::make_shared<FullGMS>(pServer));
machineTools.push_back(std::make_shared<BasicAMMachine>(pServer));
machineTools.push_back(std::make_shared<ShowcaseAMMachine>(pServer));

Expand Down