/// <summary> /// Does any initialization required before the address space can be used. /// </summary> /// <remarks> /// The externalReferences is an out parameter that allows the node manager to link to nodes /// in other node managers. For example, the 'Objects' node is managed by the CoreNodeManager and /// should have a reference to the root folder node(s) exposed by this node manager. /// </remarks> public override void CreateAddressSpace(IDictionary <NodeId, IList <IReference> > externalReferences) { lock (Lock) { //Load DI nodeset LoadPredefinedNodes(SystemContext, externalReferences); //Add my variables to Address Space, under the DeviceSet object ----------------------- //------------------------------------------------------------------------------------- //get the DeviceSet object of the Address Space NodeState DeviceSetobj = (NodeState)FindPredefinedNode( ExpandedNodeId.ToNodeId(ObjectIds.DeviceSet, Server.NamespaceUris), typeof(NodeState)); //------------------------------------------------------------------------------------- //create myDevice1 as a simple folder with a variable FolderState mydev1 = CreateFolder(DeviceSetobj, "myDevice1", "myDevice1"); //create myDevice1/myVar1 BaseDataVariableState myvar1 = CreateVariable(mydev1, "myVar1", "myVar1", Opc.Ua.DataTypeIds.Double, ValueRanks.Scalar); //create myDevice1/Actual_State BaseDataVariableState Actual_State = CreateVariable(mydev1, "Actual_State", "Actual_State", Opc.Ua.DataTypeIds.Double, ValueRanks.Scalar); //create myDevice1/Sensors_Data Sensors_Data = CreateVariable(mydev1, "Sensors_Data", "Sensors_Data", Opc.Ua.DataTypeIds.Double, ValueRanks.OneDimension); //create myDevice1/myVar2 myvar2 = CreateVariable(mydev1, "myVar2", "myVar2", Opc.Ua.DataTypeIds.Int16, ValueRanks.Scalar); /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Poject //create myDevice1/Start_Piece Start_Piece = CreateVariable(mydev1, "Start_Piece", "Start_Piece", Opc.Ua.DataTypeIds.Boolean, ValueRanks.Scalar); // create myDevice1/Mould_1 Mould_1 = CreateVariable(mydev1, "Mould_1", "Mould_1", Opc.Ua.DataTypeIds.String, ValueRanks.Scalar); // create myDevice1/Mould_1_SN Mould_1_SN = CreateVariable(mydev1, "Mould_1_SN", "Mould_1_SN", Opc.Ua.DataTypeIds.String, ValueRanks.Scalar); // create myDevice1/Mould_2 Mould_2 = CreateVariable(mydev1, "Mould_2", "Mould_2", Opc.Ua.DataTypeIds.String, ValueRanks.Scalar); // create myDevice1/Mould_2_SN Mould_2_SN = CreateVariable(mydev1, "Mould_2_SN", "Mould_2_SN", Opc.Ua.DataTypeIds.String, ValueRanks.Scalar); // create myDevice1/Piece_SN Piece_SN = CreateVariable(mydev1, "Piece_SN", "Piece_SN", Opc.Ua.DataTypeIds.Int32, ValueRanks.Scalar); // create myDevice1/Piece_SN Machine_SN = CreateVariable(mydev1, "Machine_SN", "Machine_SN", Opc.Ua.DataTypeIds.String, ValueRanks.Scalar); //create myDevice1/Change_Mould Change_Mould = CreateVariable(mydev1, "Change_Mould", "Change_Mould", Opc.Ua.DataTypeIds.Boolean, ValueRanks.Scalar); //create myDevice1/Mould_Changed Mould_Changed = CreateVariable(mydev1, "Mould_Changed", "Mould_Changed", Opc.Ua.DataTypeIds.Boolean, ValueRanks.Scalar); // create myDevice1/Actual_Mould Actual_Mould = CreateVariable(mydev1, "Actual_Mould", "Actual_Mould", Opc.Ua.DataTypeIds.Int32, ValueRanks.Scalar); // create myDevice1/Mould_tobeused Mould_tobeused = CreateVariable(mydev1, "Mould_tobeused", "Mould_tobeused", Opc.Ua.DataTypeIds.String, ValueRanks.Scalar); // create myDevice1/Operator_ID Operator_ID = CreateVariable(mydev1, "Operator_ID", "Operator_ID", Opc.Ua.DataTypeIds.Int32, ValueRanks.Scalar); // create myDevice1/Robot_Finished Robot_Finished = CreateVariable(mydev1, "Robot_Finished", "Robot_Finished", Opc.Ua.DataTypeIds.Boolean, ValueRanks.Scalar); //initialize var myvar1.Value = (double)0.0; myvar2.Value = (short)0; Actual_State.Value = (double)0.0; Start_Piece.Value = (bool)false; Mould_1.Value = (string)"Mould 1"; Mould_2.Value = (string)"Mould 2"; Mould_1_SN.Value = (string)"1"; Mould_2_SN.Value = (string)"2"; Piece_SN.Value = (int)1; Machine_SN.Value = (string)"1"; Change_Mould.Value = (bool)false; Robot_Finished.Value = (bool)true; Actual_Mould.Value = (int)0; //Sensors_Data.Value = (int[])null; Mould_tobeused.Value = Mould_1_SN.Value; Mould_Changed.Value = (bool)false; //store variable in my variable list for latter access (not necessary if variable is declare as a field of the class) m_dynamicNodes.Add(myvar1); m_dynamicNodes.Add(Actual_State); //add to Address Space AddPredefinedNode(SystemContext, mydev1); //------------------------------------------------------------------------------------- //Create a new object using the type "Device" defined by the DI specification //The class DeviceState is defined in the code generated by ModelCompiler myTemperatureSensor = new DeviceState(null); myTemperatureSensor.Create(SystemContext, null, new QualifiedName("myTemperatureSensor", m_namespaceIndex), null, true); //Object is created under DeviceSet DeviceSetobj.AddChild(myTemperatureSensor); //create a variable to hold the value of the temperature, of the type AnalogItem, under myTemperatureSensor TemperatureValue = new AnalogItemState(null); TemperatureValue.Create(SystemContext, null, new QualifiedName("Temperature", m_namespaceIndex), null, true); //Object is created under myTemperatureSensor myTemperatureSensor.AddChild(TemperatureValue); //initialize var TemperatureValue.Value = (double)0.0; //the type "Device" has a set of predefined info variables myTemperatureSensor.SerialNumber.Value = "AABB112233"; myTemperatureSensor.Manufacturer.Value = "ACME"; myTemperatureSensor.Model.Value = new LocalizedText("PT", "MODEL 1.0"); //add to Address Space AddPredefinedNode(SystemContext, myTemperatureSensor); //------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------- //initialize Modbus client Modbus_client = new ModbusClient(Modbus_IP, Modbus_port); Modbus_client.ConnectionTimeout = 5000; // start periodic method to update my Address Space variables m_doprocessingTimer = new Timer(myDoProcessing, null, m_doprocessingInterval, m_doprocessingInterval); } }