public void FindChildTest() { using (BoilerState _boilerState = new BoilerState(null, "browseName")) { Assert.IsNotNull(_boilerState.FindChild(null, new List <QualifiedName>() { _boilerState.CustomController.BrowseName }, 0)); Assert.IsNotNull(_boilerState.FindChild(null, new List <QualifiedName>() { _boilerState.FlowController.BrowseName }, 0)); Assert.IsNotNull(_boilerState.FindChild(null, new List <QualifiedName>() { _boilerState.Drum.BrowseName }, 0)); Assert.IsNotNull(_boilerState.FindChild(null, new List <QualifiedName>() { _boilerState.InputPipe.BrowseName }, 0)); Assert.IsNotNull(_boilerState.FindChild(null, new List <QualifiedName>() { _boilerState.LevelController.BrowseName }, 0)); Assert.IsNotNull(_boilerState.FindChild(null, new List <QualifiedName>() { _boilerState.OutputPipe.BrowseName }, 0)); Assert.IsNotNull(_boilerState.FindChild(null, new List <QualifiedName>() { _boilerState.Simulation.BrowseName }, 0)); } }
public void StartSimulationTest() { ISystemContext _context = new SystemContextFixture(); TraceSourceFixture _log = new TraceSourceFixture(); List <Tuple <string, object> > _callBackCount = new List <Tuple <string, object> >(); Range _startRange = null; int _valueChangeCount = 0; using (BoilerState _boilerState = new BoilerState(null, "browseName")) { _boilerState.RegisterVariable(new List <BaseInstanceState>(), (x, y) => { _callBackCount.Add(Tuple.Create <string, object>(String.Join("_", y), ((BaseVariableState)x).Value)); x.OnStateChanged += (q, w, e) => _valueChangeCount++; }); Range _level = _boilerState.Drum.LevelIndicator.Output.EURange.Value; _startRange = ModelExtensions.CreateRange(_level.High, _level.Low); double _startSetPoint = _boilerState.LevelController.SetPoint.Value; _boilerState.Logger = _log; _boilerState.ClearChangeMasks(_context, true); _boilerState.StartSimulation(); _boilerState.OnStateChanged += (x, y, z) => Assert.Fail(); System.Threading.Thread.Sleep(10000); Assert.AreEqual <int>(20, _callBackCount.Count); _boilerState.ClearChangeMasks(_context, true); Assert.AreEqual <Range>(_level, _boilerState.Drum.LevelIndicator.Output.EURange.Value); Assert.AreEqual <double>(_startSetPoint, _boilerState.LevelController.SetPoint.Value); } Assert.IsTrue(_log.TraceLog.Count > 10); Assert.IsTrue(_log.ErrorTraceLog.Count == 0); Assert.AreEqual <int>(20, _callBackCount.Count); Assert.IsTrue(600 < _valueChangeCount, $"_valueChangeCount = {_valueChangeCount}"); }
public void GetChildrenTest() { using (BoilerState _boilerState = new BoilerState(null, "browseName")) { List <BaseInstanceState> _children = new List <BaseInstanceState>(); _boilerState.GetChildren(_children); Assert.AreEqual <int>(7, _children.Count); } }
public M4CoffeeMakerApi() { warmerPlateStatus = WarmerPlateStatus.WARMER_EMPTY; boilerStatus = BoilerStatus.EMPTY; boilerState = BoilerState.OFF; brewButtonStatus = BrewButtonStatus.NOT_PUSHED; warmerState = WarmerState.OFF; indicatorState = IndicatorState.OFF; reliefValveState = ReliefValveState.CLOSED; }
public void SetBoilerState(BoilerState state) { if (state == BoilerState.On) { _boilerStatus = BoilerStatus.NotEmpty; _warmerStatus = WarmerPlateStatus.PotEmpty; _brewButtonStatus = BrewButtonStatus.Pushed; return; } _boilerStatus = BoilerStatus.Empty; _warmerStatus = WarmerPlateStatus.PotNotEmpty; _brewButtonStatus = BrewButtonStatus.NotPushed; }
protected void HandleBoilerState(BoilerState boilerState) { State = boilerState; switch (State) { case BoilerState.Empty: ControlPanel.Ready(); break; case BoilerState.NotEmpty: break; default: throw new ArgumentOutOfRangeException("boilerState"); } }
private void CreateBoiler() { Boiler = new BoilerState(null); Boiler.Create(m_nodeManager.SystemContext, new NodeId(countBoilers, m_namespaceindex), new QualifiedName(m_BoilerName, m_nodeManager.NamespaceIndexes[0]), null, true); IList <BaseInstanceState> children = new List <BaseInstanceState>(); Boiler.GetChildren(m_nodeManager.SystemContext, children); RecursiveNodeIdChanger(children); List <IReference> references = new List <IReference>(); references.Add(new NodeStateReference(ReferenceTypeIds.Organizes, false, Boiler.NodeId)); m_parentNode.AddChild(Boiler); }
/// <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) { LoadPredefinedNodes(SystemContext, externalReferences); // find the untyped Boiler1 node that was created when the model was loaded. BaseObjectState passiveNode = (BaseObjectState)FindPredefinedNode(new NodeId(Objects.Boiler1, NamespaceIndexes[0]), typeof(BaseObjectState)); // convert the untyped node to a typed node that can be manipulated within the server. m_boiler1 = new BoilerState(null); m_boiler1.Create(SystemContext, passiveNode); // replaces the untyped predefined nodes with their strongly typed versions. AddPredefinedNode(SystemContext, m_boiler1); // create a boiler node. m_boiler2 = new BoilerState(null); // initialize it from the type model and assign unique node ids. m_boiler2.Create( SystemContext, null, new QualifiedName("Boiler #2", NamespaceIndexes[1]), null, true); // link root to objects folder. IList <IReference> references = null; if (!externalReferences.TryGetValue(Opc.Ua.ObjectIds.ObjectsFolder, out references)) { externalReferences[Opc.Ua.ObjectIds.ObjectsFolder] = references = new List <IReference>(); } references.Add(new NodeStateReference(Opc.Ua.ReferenceTypeIds.Organizes, false, m_boiler2.NodeId)); // store it and all of its children in the pre-defined nodes dictionary for easy look up. AddPredefinedNode(SystemContext, m_boiler2); // start a simulation that changes the values of the nodes. m_simulationTimer = new Timer(DoSimulation, null, 1000, 1000); } }
public void RegisterVariableTest() { TraceSourceFixture _log = new TraceSourceFixture(); using (BoilerState _boilerState = new BoilerState(null, "browseName")) { _boilerState.Logger = _log; Dictionary <string, BaseInstanceState> _vars = new Dictionary <string, BaseInstanceState>(); _boilerState.RegisterVariable(new List <BaseInstanceState>(), (x, y) => _vars.Add(String.Join("_", y), x)); foreach (KeyValuePair <string, BaseInstanceState> _item in _vars) { BaseVariableState _var = _item.Value as BaseVariableState; Assert.IsNotNull(_var); string _type = _var.Value == null ? "not set" : _var.Value.GetType().Name; Debug.WriteLine($"{_item} {_type}"); } Assert.AreEqual <int>(20, _vars.Count); } Assert.IsTrue(_log.TraceLog.Count == 0); Assert.IsTrue(_log.ErrorTraceLog.Count == 0); }
public void Constructor2Test() { using (BoilerState _boilerState = new BoilerState(null, "browseName")) { Assert.IsNotNull(_boilerState.BrowseName); Assert.AreEqual <string>("browseName", _boilerState.BrowseName.Name); Assert.IsFalse(_boilerState.BrowseName.NamespaceIndexSpecified); Assert.IsNotNull(_boilerState.CustomController); Assert.IsNotNull(_boilerState.Drum); Assert.IsNotNull(_boilerState.FlowController); Assert.IsNotNull(_boilerState.InputPipe); Assert.IsNotNull(_boilerState.LevelController); Assert.IsNotNull(_boilerState.OutputPipe); Assert.IsNull(_boilerState.Parent); Assert.IsNotNull(_boilerState.Simulation); Assert.AreEqual <NodeClass>(NodeClass.Object_1, _boilerState.NodeClass); Assert.AreEqual <NodeStateChangeMasks>(NodeStateChangeMasks.Children, _boilerState.ChangeMasks); Assert.IsNotNull(_boilerState.FindChild(null, new List <QualifiedName>() { _boilerState.CustomController.BrowseName }, 0)); } }
public void SetBoilerState(BoilerState s) { throw new System.NotImplementedException(); }
/// <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) { LoadPredefinedNodes(SystemContext, externalReferences); // find the untyped Boiler1 node that was created when the model was loaded. BaseObjectState passiveNode = (BaseObjectState)FindPredefinedNode(new NodeId(Objects.Boiler1, NamespaceIndexes[0]), typeof(BaseObjectState)); // convert the untyped node to a typed node that can be manipulated within the server. m_boiler1 = new BoilerState(null); m_boiler1.Create(SystemContext, passiveNode); // replaces the untyped predefined nodes with their strongly typed versions. AddPredefinedNode(SystemContext, m_boiler1); // create a boiler node. m_boiler2 = new BoilerState(null); // initialize it from the type model and assign unique node ids. m_boiler2.Create( SystemContext, null, new QualifiedName("Boiler #2", NamespaceIndexes[1]), null, true); // link root to objects folder. IList<IReference> references = null; if (!externalReferences.TryGetValue(Opc.Ua.ObjectIds.ObjectsFolder, out references)) { externalReferences[Opc.Ua.ObjectIds.ObjectsFolder] = references = new List<IReference>(); } references.Add(new NodeStateReference(Opc.Ua.ReferenceTypeIds.Organizes, false, m_boiler2.NodeId)); // store it and all of its children in the pre-defined nodes dictionary for easy look up. AddPredefinedNode(SystemContext, m_boiler2); // start a simulation that changes the values of the nodes. m_simulationTimer = new Timer(DoSimulation, null, 1000, 1000); } }
public void ConstructorTest() { using (BoilerState _boilerState = new BoilerState(null)) { } }
public void SetBoilerState(BoilerState boilerState) { this.BoilerState = boilerState; }
public void CheckBoiler(BoilerState boilerState) { HandleBoilerState(BoilerState.Empty); }
/* * This function turns the heating element in the boiler * on or off. */ public void SetBoilerState(BoilerState s) { boilerState = s; }
public void SetBoilerState(BoilerState boilerState) { boilerOn = boilerState == BoilerState.ON; }
public void SetBoilerState(BoilerState s) { this.BoilerState = s; }
public void SetBoilerState(BoilerState boilerState) { BoilerState = boilerState; }