コード例 #1
0
        internal IOpcNode AddNode(IOpcNode parentNode, params string[] path)
        {
            var context = this.SystemContext;

            foreach (var name in path)
            {
                var childNode = (OpcInstanceNode)parentNode.Child(context, name);

                if (childNode == null)
                {
                    if (name[0] == '.')
                    {
                        childNode = new OpcDataVariableNode <int>(parentNode, name, DateTime.Now.Millisecond);
                    }
                    else
                    {
                        childNode = new OpcFolderNode(parentNode, name);
                    }

                    this.AddNode(context, childNode);

                    if (childNode is OpcVariableNode)
                    {
                        return(childNode);
                    }
                }

                parentNode = childNode;
            }

            return(parentNode);
        }
コード例 #2
0
ファイル: OpcSim.cs プロジェクト: miboCloud/ZementTech
 public OpcSim(IOpcNode parent, OpcName name, OpcContext context) : base(parent, name)
 {
     Context = context;
     Simulator.Instance().Register(this);
     //LoadChildren(simChildren, Context);
     //RegisterChildren();
 }
コード例 #3
0
ファイル: Zyklon.cs プロジェクト: miboCloud/ZementTech
        public Zyklon(IOpcNode parent, OpcName name, OpcContext context, Drehrohrofen ofen) : base(parent, name, context)
        {
            Ofen = ofen;
            tempSensors.Add(new TemperaturSensor(this, "Temperatur_1,", Context)
            {
                UpperLimit = Ofen.MaxTemp
            });
            tempSensors.Add(new TemperaturSensor(this, "Temperatur_2,", Context)
            {
                UpperLimit = Ofen.MaxTemp
            });
            tempSensors.Add(new TemperaturSensor(this, "Temperatur_3,", Context)
            {
                UpperLimit = Ofen.MaxTemp
            });
            tempSensors.Add(new TemperaturSensor(this, "Temperatur_4,", Context)
            {
                UpperLimit = Ofen.MaxTemp
            });
            tempSensors.Add(new TemperaturSensor(this, "Temperatur_5,", Context)
            {
                UpperLimit = Ofen.MaxTemp
            });

            tempSensors.ForEach(s => s.TempPt1.TimeConstant = 8000);

            exhaustHeat             = new OpcDataVariableNode <bool>(this, "AbwärmeOk", false);
            exhaustHeat.AccessLevel = OpcAccessLevel.CurrentRead;

            tempSensors.ForEach(s => RegisterComponent(s));
        }
コード例 #4
0
 public ManualControl(IOpcNode parent, OpcName name, OpcContext context) : base(parent, name, context)
 {
     _start                    = new OpcDataVariableNode <bool>(this, "Ein");
     _start.AccessLevel        = OpcAccessLevel.CurrentRead;
     _manualActive             = new OpcDataVariableNode <bool>(this, "Erlaubt");
     _manualActive.AccessLevel = OpcAccessLevel.CurrentRead;
 }
コード例 #5
0
 public OpcSimOperation(IOpcNode parent, OpcName name, OpcContext context) : base(parent, name, context)
 {
     _operationState = new OpcDataVariableNode <OperationState>(this, "State");
     _operationState.BeforeApplyChanges += _operationState_BeforeApplyChanges;
     _operationState.AccessLevel         = OpcAccessLevel.CurrentRead;
     _operationMode = new OpcDataVariableNode <OperationMode>(this, "Mode");
     _operationMode.BeforeApplyChanges += _operationMode_BeforeApplyChanges;
 }
コード例 #6
0
        protected override void ImplementNode(IOpcNode node)
        {
            if (node is OpcObjectNode objectNode && node.Name.Value == "Alerts")
            {
                this.alertsNode = objectNode;
            }

            base.ImplementNode(node);
        }
コード例 #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        protected override IOpcNodeHistoryProvider RetrieveNodeHistoryProvider(IOpcNode node)
        {
            if (this.positionHistorian.Node == node)
            {
                return(this.positionHistorian);
            }

            return(base.RetrieveNodeHistoryProvider(node));
        }
コード例 #8
0
 public Silo(IOpcNode parent, OpcName name, OpcContext context, double capacity) : base(parent, name, context)
 {
     Level  = new LevelSensor(this, "LevelSensor", Context, capacity);
     Motor  = new Motor(this, "Fördermotor", Context);
     Outlet = new Valve(this, "Ausgangsventil", Context);
     RegisterComponent(Motor);
     RegisterComponent(Level);
     RegisterComponent(Outlet);
 }
コード例 #9
0
 public OpcSimComponent(IOpcNode parent, OpcName name, OpcContext context) : base(parent, name, context)
 {
     _warningActive = new OpcDataVariableNode <bool>(this, "WarnungAktiv");
     _errorActive   = new OpcDataVariableNode <bool>(this, "ErrorAktiv");
     _simError      = new OpcDataVariableNode <bool>(this, "SimStörung");
     _simError.BeforeApplyChanges += _simError_BeforeApplyChanges;
     _simWarning = new OpcDataVariableNode <bool>(this, "SimWarnung");
     _simWarning.BeforeApplyChanges += _simWarning_BeforeApplyChanges;
 }
コード例 #10
0
        public MotorDelayLane(IOpcNode parent, OpcName name, OpcContext context, int numerOfMotors) : base(parent, name, context)
        {
            for (int i = 0; i < numerOfMotors; i++)
            {
                motors.Add(new Motor(this, "Motor" + i, Context));
            }

            motors.ForEach(m => RegisterComponent(m));
        }
コード例 #11
0
 public MyComplexVariableNode(
     IOpcNode parent,
     OpcName name,
     string mandatoryValue,
     int optionalValue = -1)
     : base(parent, name)
 {
     this.InitializeChildren(mandatoryValue, optionalValue);
 }
コード例 #12
0
 private List <string> UpdateVariables()
 {
     try
     {
         HashSet <string> variableList = new HashSet <string>();
         _matlabService.Matlab.Execute(string.Format("{0} = who", MatlabService.VariablesTag));
         object vars;
         _matlabService.Matlab.GetWorkspaceData(MatlabService.VariablesTag, MatlabService.BaseTag, out vars);
         object[,] variables = vars as object[, ];
         if (variables != null)
         {
             for (int i = 0; i < variables.GetLength(0); i++)
             {
                 string variableName = variables[i, 0].ToString();
                 if (variableName != MatlabService.VariablesTag)
                 {
                     variableList.Add(variableName);
                     object variable = _matlabService.Matlab.GetVariable(variableName, MatlabService.BaseTag);
                     OpcDataVariableNode dataNode;
                     if (!_variableNodesIds.TryGetValue(variableName, out dataNode))
                     {
                         dataNode = new OpcDataVariableNode(_matlabFolder,
                                                            new OpcName(variableName), variable);
                         dataNode.WriteVariableValueCallback = WriteMatlabVariableValueCallback;
                         _variableNodesIds.Add(variableName, dataNode);
                         AddNode(dataNode);
                         Console.WriteLine("Added variable {0} : {1}", variableName, variable);
                     }
                     else if (!dataNode.Value.Equals(variable))
                     {
                         dataNode.Value = variable;
                         Console.WriteLine("Modified variable {0} : {1}", variableName, variable);
                     }
                     dataNode.DataType = OpcDataTypes.GetDataType(variable.GetType());
                 }
             }
             //Remove variables that no longer exists
             List <string> keys = _variableNodesIds.Keys.ToList();
             foreach (string key in keys)
             {
                 if (!variableList.Contains(key))
                 {
                     IOpcNode removeNode = _variableNodesIds[key];
                     this.RemoveNode(removeNode);
                     _variableNodesIds.Remove(key);
                     Console.WriteLine("Removed variable: {0}", key);
                 }
             }
         }
         return(variableList.ToList());
     }
     catch (Exception ex)
     {
         Console.WriteLine("Update variables error:{0}{1}{0}{2}", Environment.NewLine, ex.Message, ex.StackTrace);
         return(null);
     }
 }
コード例 #13
0
        protected override IOpcNodeHistoryProvider RetrieveNodeHistoryProvider(IOpcNode node)
        {
            // Determine existing historian of the node the history provider is requested for.
            if (this.historians.TryGetValue(node, out var historian))
            {
                return(historian);
            }

            return(base.RetrieveNodeHistoryProvider(node));
        }
コード例 #14
0
        public Absackung(IOpcNode parent, OpcName name, OpcContext context) : base(parent, name, context)
        {
            Abfüllung = new Motor(this, "Abfüllung", context);

            _numberOfBags             = new OpcDataVariableNode <int>(this, "AnzahlSäcke", 0);
            _numberOfBags.AccessLevel = OpcAccessLevel.CurrentRead;
            _resetBags = new OpcDataVariableNode <bool>(this, "ResetAnzahl");
            _resetBags.BeforeApplyChanges += _resetBags_BeforeApplyChanges;

            RegisterComponent(Abfüllung);
        }
コード例 #15
0
 public TemperaturSensor(IOpcNode parent, OpcName name, OpcContext context) : base(parent, name, context)
 {
     _unit                   = new OpcDataVariableNode <string>(this, "Unit", "°C");
     _range                  = new OpcDataVariableNode <string>(this, "Range", "0..0");
     _maxValue               = new OpcDataVariableNode <double>(this, "MaxValue");
     _tempValue              = new OpcDataVariableNode <double>(this, "Value");
     _upperLimit             = new OpcDataVariableNode <double>(this, "UpperLimit", 100.0);
     _upperLimit.AccessLevel = OpcAccessLevel.CurrentRead;
     _overtemp               = new OpcDataVariableNode <bool>(this, "AlarmÜbertemperatur");
     CreatePT1();
 }
コード例 #16
0
        public Kuehler(IOpcNode parent, OpcName name, OpcContext context) : base(parent, name, context)
        {
            Ventilators.Add(new Motor(this, "Ventilator1", Context));
            Ventilators.Add(new Motor(this, "Ventilator2", Context));
            Ventilators.Add(new Motor(this, "Ventilator3", Context));

            Ventilators.ForEach(v => RegisterComponent(v));

            tempSensor            = new TemperaturSensor(this, "Temperatur", context);
            tempSensor.UpperLimit = 120.0;

            RegisterComponent(tempSensor);
        }
コード例 #17
0
        public Drehrohrofen(IOpcNode parent, OpcName name, OpcContext context, Brennstoffzufuhr bsz) : base(parent, name, context)
        {
            Brennstoffzufuhr           = bsz;
            _heatOk                    = new OpcDataVariableNode <bool>(this, "TemperaturOk");
            _delayLengthMs             = new OpcDataVariableNode <int>(this, "SimDelayLength", 10000);
            _delayLengthMs.Description = "Simulierte Verzögerung von Einlauf zum Auslauf von Material";
            Brenner                    = new Brenner(this, "Brenner", Context);
            Motor           = new Motor(this, "Hauptmotor", Context);
            ValveWasteHeate = new Valve(this, "VentilAbwärme", Context);



            tempSensors.Add(new TemperaturSensor(this, "Temperatur_1,", Context)
            {
                UpperLimit = MaxTemp
            });
            tempSensors.Add(new TemperaturSensor(this, "Temperatur_2,", Context)
            {
                UpperLimit = MaxTemp
            });
            tempSensors.Add(new TemperaturSensor(this, "Temperatur_3,", Context)
            {
                UpperLimit = MaxTemp
            });
            tempSensors.Add(new TemperaturSensor(this, "Temperatur_4,", Context)
            {
                UpperLimit = MaxTemp
            });
            tempSensors.Add(new TemperaturSensor(this, "Temperatur_5,", Context)
            {
                UpperLimit = MaxTemp
            });
            tempSensors.Add(new TemperaturSensor(this, "Temperatur_4,", Context)
            {
                UpperLimit = MaxTemp
            });
            tempSensors.Add(new TemperaturSensor(this, "Temperatur_5,", Context)
            {
                UpperLimit = MaxTemp
            });

            tempSensors.ForEach(s => s.TempPt1.TimeConstant = 14000);

            RegisterComponent(Brenner);
            RegisterComponent(Motor);
            RegisterComponent(ValveWasteHeate);

            tempSensors.ForEach(s => RegisterComponent(s));
        }
コード例 #18
0
ファイル: Valve.cs プロジェクト: miboCloud/ZementTech
        public Valve(IOpcNode parent, OpcName name, OpcContext context) : base(parent, name, context)
        {
            _maxFlow = new OpcAnalogItemNode <double>(this, "MaxDurchfluss", 600.0);
            _maxFlow.BeforeApplyChanges += _maxFlow_BeforeApplyChanges;

            _flow = new OpcAnalogItemNode <double>(this, "Durchfluss");
            _flow.InstrumentRange      = new OpcValueRange(400.0, 0);
            _flow.EngineeringUnit      = new OpcEngineeringUnitInfo(4666675, "m3/min", "Kubikmeter pro Minute");
            _flow.EngineeringUnitRange = new OpcValueRange(400.0, 0);
            _flow.Description          = "Kubikmeter pro Minute";

            _open             = new OpcDataVariableNode <bool>(this, "Offen");
            _open.Description = "True = offen, False = zu";
            _movementAlarm    = new OpcDataVariableNode <bool>(this, "AlarmPosition");
            ManualControl     = new ManualControl(this, "Handbetrieb", Context);
        }
コード例 #19
0
        protected override void AddNode(
            OpcContext context,
            IOpcNode node,
            IEnumerable <IOpcNodeReferenceAware> references)
        {
            base.AddNode(context, node, references);

            // "Catch" nodes added by the client and "schedule" job nodes.
            if (node.Parent == this.jobsNode)
            {
                if (node is OpcDataVariableNode jobNode)
                {
                    this.jobs.Enqueue(jobNode);
                }
            }
        }
コード例 #20
0
ファイル: Motor.cs プロジェクト: miboCloud/ZementTech
        public Motor(IOpcNode parent, OpcName name, OpcContext context) : base(parent, name, context)
        {
            tempSensor = new TemperaturSensor(this, "Temperatur", context);
            tempSensor.AlarmEventChanged += TempSensor_AlarmEventChanged;
            tempSensor.UpperLimit         = 70.0;

            _speed       = new OpcDataVariableNode <double>(this, "Speed");
            _current     = new OpcDataVariableNode <double>(this, "Current");
            _power       = new OpcDataVariableNode <double>(this, "Power");
            _running     = new OpcDataVariableNode <bool>(this, "Running");
            _overcurrent = new OpcDataVariableNode <bool>(this, "AlarmÜberlast");

            ManualControl = new ManualControl(this, "Handbetrieb", Context);

            CreateSpeedPt1();
            PowerPt1   = new PT1_Floating(5000);
            CurrentPt1 = new PT1_Floating(12.5);
            CurrentPt1.TimeConstant = 200;
        }
コード例 #21
0
        public RohMaterialGewinnung(IOpcNode parent, OpcName name, OpcContext context) : base(parent, name, context)
        {
            _truckReadyToUnload             = new OpcDataVariableNode <bool>(this, "TruckBereitZumAbladen");
            _truckReadyToUnload.Description = "Truck is ready to unload.";
            _truckReadyToUnload.AccessLevel = OpcAccessLevel.CurrentRead;

            _unloadingActive             = new OpcDataVariableNode <bool>(this, "TruckAbladenAktiv");
            _unloadingActive.Description = "Truck is ready to unload.";
            _unloadingActive.AccessLevel = OpcAccessLevel.CurrentRead;

            _timeUnloading             = new OpcDataVariableNode <int>(this, "ZeitAbladen");
            _timeUnloading.Description = "Zeit des Abladevorgangs";

            _timeWaitTruck             = new OpcDataVariableNode <int>(this, "ZeitWartenAufTruck");
            _timeWaitTruck.Description = "Wartezeit nächster Truck";

            _simTruckIntervalMs   = new OpcDataVariableNode <int>(this, "Z_SimTruckIntervallMs", 10000);
            _simTruckLoadCapacity = new OpcDataVariableNode <double>(this, "Z_SimTruckKapazität", 10000.0);
            _simTruckUnloadTimeMs = new OpcDataVariableNode <int>(this, "Z_SimTruckAbladeZeitMs", 8000);
        }
コード例 #22
0
        protected override void AddNode(
            OpcContext context,
            IOpcNode node,
            IEnumerable <IOpcNodeReferenceAware> references)
        {
            base.AddNode(context, node, references);

            // "Catch" nodes added by the client and "attach" the on-demand timestamp determination
            // (see HandleWriteVariableValue) and a simple in-memory historian which shall
            // automatically fill its historical values whenever a node value is written.
            if (node is OpcVariableNode variableNode && variableNode.AccessLevel.HasFlag(OpcAccessLevel.HistoryRead))
            {
                variableNode.WriteVariableValueCallback = this.HandleWriteVariableValue;
                variableNode.IsHistorizing = true;

                var historian = new OpcNodeHistorian(this, variableNode);
                historian.AutoUpdateHistory = true;

                this.historians.Add(node, historian);
            }
        }
コード例 #23
0
        public OpcSimModule(IOpcNode parent, OpcName name, OpcContext context) : base(parent, name, context)
        {
            _start             = new OpcDataVariableNode <bool>(this, "Start");
            _start.Description = "Eine steigende Flanke startet die Anlage.";

            _stop             = new OpcDataVariableNode <bool>(this, "Stop");
            _stop.Description = "Eine steigende Flanke stoppt die Anlage.";

            _warningPending             = new OpcDataVariableNode <bool>(this, "WarnungAktiv");
            _warningPending.Description = "Zeigt eine anstehende Warnung.";
            _warningPending.AccessLevel = OpcAccessLevel.CurrentRead;

            _acknowledge             = new OpcDataVariableNode <bool>(this, "Quittieren");
            _acknowledge.Description = "Eine steigende Flanke quittiert die Anlage.";

            _stop.BeforeApplyChanges        += _stop_BeforeApplyChanges;
            _start.BeforeApplyChanges       += _start_BeforeApplyChanges;
            _acknowledge.BeforeApplyChanges += _acknowledge_BeforeApplyChanges;

            _receiverReady             = new OpcDataVariableNode <bool>(this, "EmpfangenBereit");
            _receiverReady.AccessLevel = OpcAccessLevel.CurrentRead;
        }
コード例 #24
0
 public MySimpleVariableNode(IOpcNode parent, OpcName name, int value)
     : base(parent, name, value)
 {
 }
コード例 #25
0
ファイル: Brenner.cs プロジェクト: miboCloud/ZementTech
 public Brenner(IOpcNode parent, OpcName name, OpcContext context) : base(parent, name, context)
 {
     _fuelMissing = new OpcDataVariableNode <bool>(this, "AlarmBrennstoffFehlt");
 }
コード例 #26
0
 public Brecher(IOpcNode parent, OpcName name, OpcContext context) : base(parent, name, context)
 {
     motors.ForEach(m => RegisterComponent(m));
 }
コード例 #27
0
 public OpcSimComponentControl(IOpcNode parent, OpcName name, OpcContext context) : base(parent, name, context)
 {
 }
コード例 #28
0
 public MySimpleObjectNode(IOpcNode parent, OpcName name)
     : base(parent, name)
 {
 }
コード例 #29
0
 public MyComplexObjectNode(IOpcNode parent, OpcName name)
     : base(parent, name)
 {
     this.InitializeChildren();
 }
コード例 #30
0
 protected static void AddConfig(IOpcNode node)
 {
     _timeLapse         = new OpcDataVariableNode <TimeMultiplier>(node, "Zeitraffer");
     _clock             = new OpcDataVariableNode <int>(node, "Clock", 100);
     _clock.Description = "Clock in Millisekunden";
 }