Esempio n. 1
0
        static string getOPCUATransformerUA5231(int companyId, int messageCatalogId)
        {
            var transformerJson = new JObject();

            // messageCatalogId
            transformerJson.Add("messageCatalogId", messageCatalogId);

            // companyId
            transformerJson.Add("companyId", companyId);

            // msgTimestamp
            var msgTimestamp = Just.GetValueIfExistsAndNotEmpty("Value.SourceTimestamp");

            transformerJson.Add("msgTimestamp", msgTimestamp);

            // equipmentId
            var applicationUri = Just.GetValueIfExists("ApplicationUri");

            var equipmentId = Just.IfCondition(applicationUri,
                                               "urn:OPC-A:ICPDAS:ICPDAS_OPC_UA_Server",
                                               "Windwos-OPC-UA-Publisher-v212",
                                               Just.CDS_MESSAGE_TRANSFORM_PROPERTY_NOT_FOUND);

            transformerJson.Add("equipmentId", equipmentId);

            // equipmentRunStatus
            transformerJson.Add("equipmentRunStatus", 1);// Hard code


            var valueValue = Just.GetValueIfExistsAndNotEmpty("Value.Value");
            var nodeId     = Just.GetValueIfExistsAndNotEmpty("NodeId");

            // TemperatureC
            var temperature = Just.IfCondition(
                nodeId,
                Just.CDS_MESSAGE_TRANSFORM_PROPERTY_NOT_FOUND,
                Just.CDS_MESSAGE_TRANSFORM_PROPERTY_NOT_FOUND,
                Just.IfCondition(
                    nodeId,
                    "ns=2;s=MTCP_CurrentValueTask.Temperature_C",
                    valueValue,
                    Just.CDS_MESSAGE_TRANSFORM_PROPERTY_NOT_FOUND));

            transformerJson.Add("TemperatureC", temperature);

            // CO2
            var co2 = Just.IfCondition(
                nodeId,
                Just.CDS_MESSAGE_TRANSFORM_PROPERTY_NOT_FOUND,
                Just.CDS_MESSAGE_TRANSFORM_PROPERTY_NOT_FOUND,
                Just.IfCondition(
                    nodeId,
                    "ns=2;s=MTCP_CurrentValueTask.CO2",
                    valueValue,
                    Just.CDS_MESSAGE_TRANSFORM_PROPERTY_NOT_FOUND));

            transformerJson.Add("CO2", co2);

            // Humidity
            var humidity = Just.IfCondition(
                nodeId,
                Just.CDS_MESSAGE_TRANSFORM_PROPERTY_NOT_FOUND,
                Just.CDS_MESSAGE_TRANSFORM_PROPERTY_NOT_FOUND,
                Just.IfCondition(
                    nodeId,
                    "ns=2;s=MTCP_CurrentValueTask.Humidity",
                    valueValue,
                    Just.CDS_MESSAGE_TRANSFORM_PROPERTY_NOT_FOUND));

            transformerJson.Add("Humidity", humidity);

            // TemperatureF
            var temperatureF = Just.IfCondition(
                nodeId,
                Just.CDS_MESSAGE_TRANSFORM_PROPERTY_NOT_FOUND,
                Just.CDS_MESSAGE_TRANSFORM_PROPERTY_NOT_FOUND,
                Just.IfCondition(
                    nodeId,
                    "ns=2;s=MTCP_CurrentValueTask.Temperature_F",
                    valueValue,
                    Just.CDS_MESSAGE_TRANSFORM_PROPERTY_NOT_FOUND));

            transformerJson.Add("TemperatureF", temperatureF);

            return(transformerJson.ToString());
        }
Esempio n. 2
0
        static string getOpcuaTransformerUagwadvt01(int companyId, int messageCatalogId)
        {
            var transformerJson = new JObject();

            // messageCatalogId
            transformerJson.Add("messageCatalogId", messageCatalogId);

            // companyId
            transformerJson.Add("companyId", companyId);

            // msgTimestamp
            var msgTimestamp = Just.GetValueIfExistsAndNotEmpty("Value.SourceTimestamp");

            transformerJson.Add("msgTimestamp", msgTimestamp);

            // equipmentId
            var applicationUri = Just.GetValueIfExists("ApplicationUri");
            var gatewayName    = Just.GetValueIfExists("Gateway");

            var equipmentId = Just.IfCondition(applicationUri,
                                               "urn::SchneiderElectric:M241-251UaServer",
                                               Just.IfCondition(gatewayName,
                                                                "uagwadvt01",
                                                                "SchneiderPLC-A",
                                                                Just.IfCondition(gatewayName,
                                                                                 "uagwmoxa01",
                                                                                 "SchneiderPLC-M",
                                                                                 Just.IfCondition(gatewayName,
                                                                                                  "uagwnexc01",
                                                                                                  "SchneiderPLC-N",
                                                                                                  Just.CDS_MESSAGE_TRANSFORM_PROPERTY_NOT_FOUND))),
                                               Just.CDS_MESSAGE_TRANSFORM_PROPERTY_NOT_FOUND);

            transformerJson.Add("equipmentId", equipmentId);

            // equipmentRunStatus
            transformerJson.Add("equipmentRunStatus", 1);// Hard code

            var valueValue = Just.GetValueIfExistsAndNotEmpty("Value.Value");
            var nodeId     = Just.GetValueIfExistsAndNotEmpty("NodeId");

            // RPM
            var rpm = Just.IfCondition(
                nodeId,
                Just.CDS_MESSAGE_TRANSFORM_PROPERTY_NOT_FOUND,
                Just.CDS_MESSAGE_TRANSFORM_PROPERTY_NOT_FOUND,
                Just.IfCondition(
                    nodeId,
                    "ns=2;s=OPC.Read_Velocity",
                    valueValue,
                    Just.CDS_MESSAGE_TRANSFORM_PROPERTY_NOT_FOUND));

            transformerJson.Add("RPM", rpm);

            // Distance
            var distance = Just.IfCondition(
                nodeId,
                Just.CDS_MESSAGE_TRANSFORM_PROPERTY_NOT_FOUND,
                Just.CDS_MESSAGE_TRANSFORM_PROPERTY_NOT_FOUND,
                Just.IfCondition(
                    nodeId,
                    "ns=2;s=OPC.Sensor_IW0",
                    valueValue,
                    Just.CDS_MESSAGE_TRANSFORM_PROPERTY_NOT_FOUND));

            transformerJson.Add("Distance", distance);

            // cpuUsage
            var cpuUsage = Just.GetValueIfExistsAndNotEmpty("CPU_Usage");

            transformerJson.Add("cpuUsage", cpuUsage);

            // memoryUsage
            var memoryUsage = Just.GetValueIfExistsAndNotEmpty("Memory_Usage");

            transformerJson.Add("memoryUsage", memoryUsage);

            // Approach
            var approach = Just.IfCondition(
                nodeId,
                Just.CDS_MESSAGE_TRANSFORM_PROPERTY_NOT_FOUND,
                Just.CDS_MESSAGE_TRANSFORM_PROPERTY_NOT_FOUND,
                Just.IfCondition(
                    nodeId,
                    "ns=2;s=OPC.Sensor_IX00_ON",
                    valueValue,
                    Just.CDS_MESSAGE_TRANSFORM_PROPERTY_NOT_FOUND));

            transformerJson.Add("Approach", approach);

            return(transformerJson.ToString());
        }