Exemple #1
0
        /// <summary>
        /// Called when the node manager is started.
        /// </summary>
        public override void Startup()
        {
            try
            {
                Console.WriteLine("Starting DcsLabNodeManager.");

                DefaultNamespaceIndex = AddNamespaceUri("http://yourorganisation.org/DCS-lab/");

                Console.WriteLine("Loading the DcsLab Model.");
                ImportUaNodeset(Assembly.GetEntryAssembly(), "dcs-lab.xml");

                var controllers = LookupObject(ObjectIds.Controllers);

                Vms = new AssemblyStationViewModel[]
                {
                    CreateAssemblyStation("AS1_1_2", controllers),
                    CreateAssemblyStation("AS21_1_2", controllers),
                    CreateAssemblyStation("AS2_1_2", controllers),
                };

                foreach (var vm in Vms)
                {
                    vm.Start();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed to start DcsLabNodeManager " + e.Message);
            }
        }
Exemple #2
0
        public AssemblyStationViewModel CreateAssemblyStation(string name, ObjectNode parent)
        {
            var settings = new CreateObjectSettings()
            {
                ParentNodeId     = parent.NodeId,
                ReferenceTypeId  = UnifiedAutomation.UaBase.ReferenceTypeIds.Organizes,
                RequestedNodeId  = new NodeId(name, DefaultNamespaceIndex),
                BrowseName       = new QualifiedName(name, DefaultNamespaceIndex),
                TypeDefinitionId = new NodeId(Polsl.DcsLab.ObjectTypes.AssemblyStationType, DefaultNamespaceIndex),
            };

            var node = CreateObject(Server.DefaultRequestContext, settings);

            var vm      = new AssemblyStationViewModel(node);
            var getters = getGetters(vm);
            var setters = getSetters(vm);

            foreach (var variable in variables)
            {
                SetVariableConfiguration(
                    node.NodeId, new QualifiedName(variable, DefaultNamespaceIndex),
                    NodeHandleType.ExternalPolled,
                    new Tuple <Func <object>, Action <object> >(getters[variable], setters[variable]));
            }
            return(vm);
        }
Exemple #3
0
 private Dictionary <string, Func <object> > getGetters(AssemblyStationViewModel station)
 {
     return(new Dictionary <string, Func <object> >()
     {
         { "ST_INPUT", () => station.StInput },
         { "ST_OUTPUT", () => station.StOutput },
         { "CYCLE_TIME", () => station.CurrentCycleTime },
         { "ALARM", () => station.Alarm },
         { "BLOCKED", () => station.Blocked },
         { "EMPTY", () => station.Empty },
         { "EXCLUDED", () => station.Excluded },
         { "RUN", () => station.Run },
         { "TIMEOUT", () => station.Timeout },
     });
 }
Exemple #4
0
 private Dictionary <string, Action <object> > getSetters(AssemblyStationViewModel station)
 {
     return(new Dictionary <string, Action <object> >()
     {
         { "ST_INPUT", v => station.StInput = (bool)v },
         { "ST_OUTPUT", v => station.StOutput = (bool)v },
         { "CYCLE_TIME", v => station.CurrentCycleTime = (byte)v },
         { "ALARM", v => station.Alarm = (bool)v },
         { "BLOCKED", v => station.Blocked = (bool)v },
         { "EMPTY", v => station.Empty = (bool)v },
         { "EXCLUDED", v => station.Excluded = (bool)v },
         { "RUN", v => station.Run = (bool)v },
         { "TIMEOUT", v => station.Timeout = (bool)v },
     });
 }