protected override IEnumerable <IOpcNode> CreateNodes(OpcNodeReferenceCollection references)
        {
            var machineNode = new OpcObjectNode(this.DefaultNamespace.GetName("Machine"));

            this.jobsNode = new OpcFolderNode(machineNode, "Jobs");
            references.Add(machineNode, OpcObjectTypes.ObjectsFolder);

            // Add some predefined jobs.
            new OpcDataVariableNode <int>(this.jobsNode, "JOB01", value: 0);
            new OpcDataVariableNode <int>(this.jobsNode, "JOB02", value: 0);
            new OpcDataVariableNode <int>(this.jobsNode, "JOB03", value: 0);

            // Define a generic event to notify about job-scheduled.
            this.jobScheduldedEventNode          = new OpcEventNode(this.jobsNode, "JobSchedulded");
            this.jobScheduldedEventNode.Severity = OpcEventSeverity.Medium;
            this.jobScheduldedEventNode.Message  = "The job has been schedulded.";

            this.jobsNode.AddNotifier(this.SystemContext, this.jobScheduldedEventNode);

            // Define a generic event to notify about job-completed.
            this.jobCompletedEventNode          = new OpcEventNode(this.jobsNode, "JobCompleted");
            this.jobCompletedEventNode.Severity = OpcEventSeverity.Medium;
            this.jobCompletedEventNode.Message  = "The job has been completed.";

            this.jobsNode.AddNotifier(this.SystemContext, this.jobCompletedEventNode);
            return(new IOpcNode[] { machineNode });
        }
        protected override IEnumerable <IOpcNode> CreateNodes(OpcNodeReferenceCollection references)
        {
            var variableNodes = new OpcObjectNode("MyVariables");

            references.Add(variableNodes, OpcObjectTypes.ObjectsFolder);

            var simpleVariableNodes = new OpcObjectNode(variableNodes, "Simple");

            new MySimpleVariableNode(simpleVariableNodes, "Var01", 1);
            new MySimpleVariableNode(simpleVariableNodes, "Var02", 2);

            var complexVariableNodes = new OpcObjectNode(variableNodes, "Complex");

            new MyComplexVariableNode(complexVariableNodes, "Var01", "A");
            new MyComplexVariableNode(complexVariableNodes, "Var02", "B", 42);

            var objectNodes = new OpcObjectNode("MyObjects");

            references.Add(objectNodes, OpcObjectTypes.ObjectsFolder);

            var simpleObjectNodes = new OpcObjectNode(objectNodes, "Simple");

            new MySimpleObjectNode(simpleObjectNodes, "Object01");
            new MySimpleObjectNode(simpleObjectNodes, "Object02");

            var complexObjectNodes = new OpcObjectNode(objectNodes, "Complex");

            new MyComplexObjectNode(complexObjectNodes, "Object01");
            new MyComplexObjectNode(complexObjectNodes, "Object02");

            return(new[] { variableNodes, objectNodes });
        }
        protected override IEnumerable <IOpcNode> CreateNodes(OpcNodeReferenceCollection references)
        {
            // We just want to define a simple "entry point" for client added nodes.
            var machineNode = new OpcObjectNode(this.DefaultNamespace.GetName("Machine"));

            references.Add(machineNode, OpcObjectTypes.ObjectsFolder);

            return(new IOpcNode[] { machineNode });
        }
Beispiel #4
0
        protected override void ImplementNode(IOpcNode node)
        {
            if (node is OpcObjectNode objectNode && node.Name.Value == "Alerts")
            {
                this.alertsNode = objectNode;
            }

            base.ImplementNode(node);
        }
        protected override IEnumerable <IOpcNode> CreateNodes(OpcNodeReferenceCollection references)
        {
            var machineNode = new OpcObjectNode(this.DefaultNamespace.GetName("Machine"));

            new VariableNode <int>(this, machineNode, "Status", value: 42);
            new VariableNode <string>(this, machineNode, "Job", value: "JOB-0543");

            new VariableNode <bool>(this, machineNode, "Shutdown", value: false);
            new VariableNode <short>(this, machineNode, "Speed", value: 1000);
            new VariableNode <string>(this, machineNode, "Tooling", value: "cutter");

            references.Add(machineNode, OpcObjectTypes.ObjectsFolder);
            return(new IOpcNode[] { machineNode });
        }
        public static void Main(string[] args)
        {
            temperatureNode = new OpcDataVariableNode <double>("Temperature");
            speedNode       = new OpcDataVariableNode <int>("Speed");

            var machineNode = new OpcObjectNode(
                "Machine",
                temperatureNode,
                speedNode,
                new OpcActionMethodNode("StartMachine", StartMachine),
                new OpcActionMethodNode("StopMachine", StopMachine));

            using (var server = new OpcServer("opc.tcp://localhost:4840/", machineNode)) {
                server.Start();

                machineNode.AddNotifier(server.SystemContext, temperatureNode);
                machineNode.AddNotifier(server.SystemContext, speedNode);

                Console.WriteLine("Server started - press any key to exit.");
                Console.ReadKey(true);
            }
        }