Пример #1
0
    /// <summary>
    /// Initialise the sub devices of this tank. This methode overrides the parent class methode.
    /// </summary>
    /// <param name="istIds">Mapping actual values opc ua node id's.</param>
    /// <param name="sollIds">Mapping set values opc ua node id's.</param>
    /// <param name="rest">RestAPI object.</param>
    public override void InitOPCUAData(IstOPCUANodeIds istIds, SollOPCUANodeIds sollIds, RestAPIRequest rest)
    {
        // Load mapping -> TODO: Has to be fixed ...
        subDevicesTopologie = plantTopo.ModuleSubmodels(linkedData_data.ModuleDiscription) [linkedData_data.PlantTag];
        Device local;         // Safepoint

        // loop through dictionary
        foreach (KeyValuePair <string, TopologyObject> entry in subDevicesTopologie)
        {
            // Get the class of the subdevice
            local = devVali.Validator(entry.Key, linkedData_data.ModuleDiscription, istIds);
            // A sub device with set and actual value.
            if (sollIds.SollNodeId [linkedData_data.ModuleDiscription].ContainsKey(entry.Key))
            {
                // init this device.
                local.InitOPCUAData(rest.getNode(istIds.TagToNodeId [linkedData_data.ModuleDiscription] [entry.Key].Core), rest.getNode(sollIds.SollNodeId [linkedData_data.ModuleDiscription] [entry.Key]));
            }
            else
            {
                // A sub device with only actual value. TODO: Neue Variable wirklich notwendig?
                Sensor locSensor = (Sensor)local;                 // Until now: Only sensors. In further software versions you need maybe more cases.
                // Fix it. Looks bad! Problem1: LinkedData doesen't know the position. Problem2: the validation can't see if binary sensor or something else.
                if (subDevicesTopologie [locSensor.Tag].Position == "ontop" && locSensor.GetType().ToString() == "BinarySensor")
                {
                    locSensor = new LinearFluidLevelSensor(locSensor.Tag);
                }
                // init the new sensor
                locSensor.InitOPCUAData(rest.getNode(istIds.TagToNodeId [linkedData_data.ModuleDiscription] [entry.Key].Core));
                local = locSensor;
            }
            // Add the sub device to dictionary
            subDevices.Add(local.Tag, local);
        }
    }
Пример #2
0
    /// <summary>
    /// Awake this instance.
    /// </summary>
    void Awake()
    {
        //get referecences to communicator scripts for restAPI and linkedData request
        linkedData = GameObject.Find("Communicator").GetComponent <linkedDataRequest>();
        restAPI    = GameObject.Find("Communicator").GetComponent <RestAPIRequest>();

        // invoke static nodeid lists
        istNodeIds  = new IstOPCUANodeIds(restAPI);
        sollNodeIds = new SollOPCUANodeIds(istNodeIds.NodeIdCrawlerResult);

        //initialise dictionary
        try {
            moduleDatabase = new Dictionary <string, Dictionary <string, DeviceGUI> >();
        } catch (Exception e) {
            Debug.Log("exception at new dataDictionary occurd: " + e.Message);
        }
    }
Пример #3
0
    /// <summary>
    /// Awake this instance.
    /// </summary>
    void Awake()
    {
        zyklusRest     = Time.time;
        zyklusOPC      = Time.time;
        zyklusMatching = 0;

        GameObject go = GameObject.Find("SocketIO");

        socket = go.GetComponent <SocketIOComponent>();
        // Test OPC UA Server connection
        // connect to database
        database    = GameObject.Find("Database").GetComponent <Database>();
        istNodeIds  = database.IstNodeIds;
        sollNodeIds = database.SollNodeIds;

        // Test serverstatus for the first time
        testRest();
        //socket.On ("message", testSocket);
        socket.On("message", socketMessage);
    }
Пример #4
0
 /// <summary>
 /// For submodules.
 /// </summary>
 public virtual void InitOPCUAData(IstOPCUANodeIds istIds, SollOPCUANodeIds sollIds, RestAPIRequest rest)
 {
 }
Пример #5
0
    /// <summary>
    /// Identifies the class/type of the device and returns it.
    /// </summary>
    /// <param name="plantTag">Plant tag</param>
    /// <param name="module">Name of the module in plant</param>
    /// <param name="istIds">Mapping of opc ua node id's</param>
    /// <returns></returns>
    public Device Validator(string plantTag, string module, IstOPCUANodeIds istIds)
    {
        Device local;

        switch (plantTag[0].ToString())
        {
        case "P":
            switch (plantTag)
            {
            case "PIC":
                local = new Device(plantTag);
                break;

            case "PROP_V":
                local = new Device(plantTag);
                break;

            default:
                local = new Pump(plantTag);
                break;
            }
            break;

        case "V":
            // Valve modeld in opc ua
            if (istIds.TagToNodeId[module].ContainsKey(plantTag))
            {
                // RelayValve
                if (istIds.TagToNodeId[module][plantTag].Core.Contains("#"))
                {
                    local = new RelayValve(plantTag);
                }
                else                     // Normal valve
                {
                    local = new Valve(plantTag);
                }
            }
            else                 // only modeld in Linked Data
                                 // Handventil. Achtung codedopplung.
            {
                local = new HandValve(plantTag);
            }
            break;

        case "F":
            // TODO: Fix device typ
            local = new Device(plantTag);
            break;

        case "L":
            // TODO: NIcht eindeutig ob binär oder linear
            local = new BinarySensor(plantTag);
            break;

        case "R":
            local = new Mixer(plantTag);
            break;

        case "T":
            local = new TemperatureSensor(plantTag);
            break;

        case "B":
            local = new Tank(plantTag);
            break;

        case "W":
            // Spechial case: WT
            if (plantTag [1].ToString() == "T")
            {
                local = new DeviceGUI(plantTag);
            }
            else
            {
                local = new Device(plantTag);
            }
            break;

        default:
            local = new Device(plantTag);
            break;
        }
        return(local);
    }