public RuntimeApplicationItem(ISolutionItem parent, NodeRuntimeApplication runtimeApplication)
            : base(parent, runtimeApplication.Code.ToString())
        {
            ContextMenu = extensionService.Sort(contextMenu);
            RuntimeApplication = runtimeApplication;
            SetItems();

            SetIconFromBitmap(Resources.Images.Disconnected);
        }
Exemplo n.º 2
0
        public static NodeRuntimeApplication BuildWith(
            FieldIdentifier Code, FieldGuid TypeId, FieldGuid RuntimeId,
            FieldString Address, FieldBase64 Configuration, FieldBool ExecuteOnStartup,
            NodePageCollection Logic, NodeDeviceConfiguration DeviceConfiguration)
        {
            var rta = NodeRuntimeApplication.BuildWith(
                Code, TypeId, RuntimeId, Address, Configuration, ExecuteOnStartup);

            rta = rta.SetLogic(Logic);
            return(rta.SetDeviceConfiguration(DeviceConfiguration));
        }
Exemplo n.º 3
0
        public static NodeRuntimeApplication BuildWith(
            FieldIdentifier Code, FieldGuid TypeId, FieldGuid RuntimeId,
            FieldString Address, FieldBase64 Configuration, FieldBool ExecuteOnStartup)
        {
            //build fields
            Dictionary <FieldIdentifier, FieldBase> mutableFields =
                new Dictionary <FieldIdentifier, FieldBase>();

            mutableFields.Add(new FieldIdentifier(m_CodeName), Code);
            mutableFields.Add(new FieldIdentifier(m_TypeIdName), TypeId);
            mutableFields.Add(new FieldIdentifier(m_RuntimeIdName), RuntimeId);
            mutableFields.Add(new FieldIdentifier(m_AddressName), Address);
            mutableFields.Add(new FieldIdentifier(m_ConfigurationName), Configuration);
            mutableFields.Add(new FieldIdentifier(m_ExecuteOnStartupName), ExecuteOnStartup);
            mutableFields.Add(new FieldIdentifier(m_TryModeName), new FieldBool(false));
            //Add Fields here: mutableFields.Add(new FieldIdentifier("Code"), Code);

            //build children
            KeyedNodeCollection <NodeBase> mutableChildren =
                new KeyedNodeCollection <NodeBase>();
            var pc = NodePageCollection.BuildWith(
                new FieldPageCollectionName(m_LogicName)
                );

            pc = pc.SetLogicRoot(new FieldBool(true));
            mutableChildren.Add(pc);
            mutableChildren.Add(
                NodeDeviceConfiguration.BuildWith(
                    new ReadOnlyCollection <NodeDriver>(new Collection <NodeDriver>())
                    ));
            //Add Children here: mutableChildren.Add(SomeChild);

            //build node
            NodeRuntimeApplication Builder = new NodeRuntimeApplication(
                new ReadOnlyDictionary <FieldIdentifier, FieldBase>(mutableFields),
                new ReadOnlyCollection <NodeBase>(mutableChildren));

            return(Builder);
        }
Exemplo n.º 4
0
 /// <summary>
 /// The value that should be output to the actual hardware
 /// and takes the forced status into account.  Threadsafe.
 /// </summary>
 public Decimal GetValue(NodeRuntimeApplication runtimeApplication)
 {
     if (runtimeApplication == null)
     {
         throw new ArgumentNullException();
     }
     if (Forced.BoolValue)
     {
         return((Decimal)ForcedValue.Value);
     }
     else
     {
         var nValue = SignalIn.GetValue(runtimeApplication);
         if (nValue != null && nValue.DataType.DataType == FieldDataType.DataTypeEnum.NUMBER)
         {
             return((Decimal)nValue.Value);
         }
         else
         {
             return((Decimal)FieldDataType.DefaultValue(FieldDataType.DataTypeEnum.NUMBER));
         }
     }
 }
 /// <summary>
 /// The value that should be output to the actual hardware
 /// and takes the forced status into account.  Threadsafe.
 /// </summary>
 public bool GetValue(NodeRuntimeApplication runtimeApplication)
 {
     if (runtimeApplication == null)
     {
         throw new ArgumentNullException();
     }
     if (Forced.BoolValue)
     {
         return(ForcedValue.BoolValue);
     }
     else
     {
         var nValue = SignalIn.GetValue(runtimeApplication);
         if (nValue != null && nValue.DataType.DataType == FieldDataType.DataTypeEnum.BOOL)
         {
             return((bool)nValue.Value);
         }
         else
         {
             return(false);
         }
     }
 }
Exemplo n.º 6
0
 public NodeValue GetValue(NodeRuntimeApplication runtimeApplication)
 {
     if (runtimeApplication == null)
     {
         throw new ArgumentNullException();
     }
     if (SignalId != null)
     {
         var signal = runtimeApplication.FindSignal(SignalId);
         if (signal != null)
         {
             return(signal.Storage);
         }
         else
         {
             return(null);
         }
     }
     else if (Literal != null)
     {
         NodeValue retVal = null;
         lock (m_LiteralNodeValue_Lock)
         {
             if (m_LiteralNodeValue == null)
             {
                 m_LiteralNodeValue       = NodeValue.BuildWith(new FieldDataType(Literal.DataType));
                 m_LiteralNodeValue.Value = Literal.Value;
             }
             retVal = m_LiteralNodeValue;
         }
         return(retVal);
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 7
0
 public void Load()
 {
     runtimeApplication = loadRuntimeApplication();
     if (runtimeApplication != null &&
         runtimeApplication.ExecuteOnStartup.BoolValue)
     {
         Start();
     }
 }
Exemplo n.º 8
0
 public InstructionGroupExecutorContextLD ScanInstruction(NodeRuntimeApplication rta, NodeInstruction instruction, InstructionGroupExecutorContextLD context)
 {
     var retVal = new InstructionGroupExecutorContextLD(false);
     if (m_instructionExecutors.ContainsKey(instruction.InstructionType))
     {
         var executor = m_instructionExecutors[instruction.InstructionType];
         retVal = executor.ScanInstruction(rta, instruction, context);
     }
     else
     {
         // FIXME - throw some kind of exception?
     }
     return retVal;
 }
Exemplo n.º 9
0
 public void ScanInstructionGroup(NodeRuntimeApplication rta, NodeInstructionGroup instructionGroup)
 {
     var contextIterator = new InstructionGroupExecutorContextLD(true); // rung condition at the beginning of a rung is always true
     // A rung only ever has one series instruction as a child, so the foreach is kind of overkill, but should work
     foreach (var instruction in instructionGroup.NodeInstructionChildren)
     {
         contextIterator = ScanInstruction(rta, instruction, contextIterator);
     }
 }
Exemplo n.º 10
0
        public void ScanOutputs(NodeDriver driver, NodeRuntimeApplication runtimeApplication)
        {
            // No outputs yet
            //foreach (var device in driver.NodeDeviceChildren.Items)
            //{

            //}
        }
Exemplo n.º 11
0
 public IRuntime OpenRuntime(NodeRuntimeApplication rta)
 {
     IRuntime retVal = null;
     foreach (var rt in Runtimes)
     {
         retVal = rt;
         break;
     }
     return retVal;
 }
Exemplo n.º 12
0
 public void ScanOutputs(NodeDriver driver, NodeRuntimeApplication runtimeApplication)
 {
     foreach (var device in driver.NodeDeviceChildren.Items)
     {
         if (device.Address.ToString() != string.Empty)
         {
             switch(device.Code.ToString())
             {
                 case Phidget_InterfaceKit_004.CODE:
                 case Phidget_InterfaceKit_008.CODE:
                 case Phidget_InterfaceKit_488.CODE:
                 case Phidget_InterfaceKit_888.CODE:
                 case Phidget_InterfaceKit_0_16_16.CODE:
                     var ifKit = OpenInterfaceKit(device);
                     if (ifKit.Attached)
                     {
                         for (int i = 0; i < ifKit.outputs.Count; i++)
                         {
                             foreach (var output in device.NodeDiscreteOutputChildren.Items)
                             {
                                 if (Int32.Parse(output.Address.ToString()) == i)
                                 {
                                     try
                                     {
                                         ifKit.outputs[i] = output.GetValue(runtimeApplication);
                                     }
                                     catch
                                     {
                                         // FIXME - tie in to error reporting mechanism
                                     }
                                 }
                             }
                         }
                     }
                     break;
                 case Phidget_ServoMotor_1.CODE:
                 case Phidget_ServoMotor_4.CODE:
                 case Phidget_ServoMotor_8.CODE:
                     var mtrControl = OpenServo(device);
                     if (mtrControl.Attached)
                     {
                         for (int i = 0; i < mtrControl.servos.Count; i++)
                         {
                             foreach (var output in device.NodeAnalogOutputChildren.Items)
                             {
                                 if (Int32.Parse(output.Address.ToString()) == i)
                                 {
                                     try
                                     {
                                         mtrControl.servos[i].Position = Convert.ToDouble(output.GetValue(runtimeApplication));
                                     }
                                     catch
                                     {
                                         // FIXME - tie in to error reporting mechanism
                                     }
                                 }
                             }
                         }
                     }
                     break;
                 case Phidget_AdvancedServo.CODE:
                     var advServo = OpenAdvancedServo(device);
                     if (advServo.Attached)
                     {
                         for (int i = 0; i < advServo.servos.Count; i++)
                         {
                             var enable =
                                 (from o in device.NodeDiscreteOutputChildren.Items
                                  where Int32.Parse(o.Address.ToString()) == i
                                  select o).FirstOrDefault();
                             if (enable != null)
                             {
                                 try
                                 {
                                     advServo.servos[i].Engaged = enable.GetValue(runtimeApplication);
                                 }
                                 catch
                                 {
                                     // FIXME - tie in to error reporting mechanism
                                 }
                             }
                             var output =
                                 (from o in device.NodeAnalogOutputChildren.Items
                                  where Int32.Parse(o.Address.ToString()) == i
                                  select o).FirstOrDefault();
                             if (output != null)
                             {
                                 try
                                 {
                                     advServo.servos[i].Position = Convert.ToDouble(output.GetValue(runtimeApplication));
                                 }
                                 catch
                                 {
                                     // FIXME - tie in to error reporting mechanism
                                 }
                             }
                         }
                     }
                     break;
                 case Phidget_TextLCD_2x20.CODE:
                     var textLCD = OpenTextLCD(device);
                     if (textLCD.Attached)
                     {
                         for (int i = 0; i < textLCD.rows.Count; i++)
                         {
                             foreach (var output in device.NodeStringOutputChildren.Items)
                             {
                                 if (Int32.Parse(output.Address.ToString()) == i)
                                 {
                                     var text = output.GetValue(runtimeApplication);
                                     if (text.Length > textLCD.rows[i].MaximumLength)
                                     {
                                         text = text.Substring(0, textLCD.rows[i].MaximumLength);
                                     }
                                     try
                                     {
                                         textLCD.rows[i].DisplayString = text;
                                     }
                                     catch
                                     {
                                         // FIXME - tie in to error reporting mechanism
                                     }
                                 }
                             }
                         }
                     }
                     break;
             }
         }
     }
 }
Exemplo n.º 13
0
        private void saveRuntimeApplication(NodeRuntimeApplication runtimeApplicationToSave)
        {
            try
            {
                if (!Directory.Exists(COMMON_APPLICATION_DATA_FOLDER))
                {
                    Directory.CreateDirectory(COMMON_APPLICATION_DATA_FOLDER);
                }

                string fileName = Path.Combine(COMMON_APPLICATION_DATA_FOLDER, RUNTIME_APPLICATION_FILENAME);
                string signalFileName = Path.Combine(COMMON_APPLICATION_DATA_FOLDER, SIGNAL_STATE_FILENAME);
                if (runtimeApplicationToSave != null)
                {
                    byte[] byteArray = Encoding.Unicode.GetBytes(runtimeApplicationToSave.ToXml());
                    File.WriteAllBytes(fileName, byteArray);
                    byte[] signalByteArray = Encoding.Unicode.GetBytes(signalStateToBlob(runtimeApplicationToSave));
                    File.WriteAllBytes(signalFileName, signalByteArray);
                }
                else
                {
                    if (File.Exists(fileName))
                    {
                        File.Delete(fileName);
                    }
                    if (File.Exists(signalFileName))
                    {
                        File.Delete(signalFileName);
                    }
                }
            }
            catch
            {
                //FIXME - tie into error reporting feature, to be written
            }
        }
Exemplo n.º 14
0
 private void ScanIO(NodeRuntimeApplication rta, Action<IRuntimeDriver, NodeDriver> action)
 {
     foreach (var nDriver in rta.DeviceConfiguration.NodeDriverChildren)
     {
         if (nDriver.Running.BoolValue)
         {
             var nDriverGuid = new Guid(nDriver.TypeId.ToString());
             foreach (IRuntimeDriver driver in drivers) // NOT threadsafe: won't support recomposition
             {
                 if (driver.TypeId == nDriverGuid)
                 {
                     action(driver, nDriver);
                 }
             }
         }
     }
 }
Exemplo n.º 15
0
 public NodeValue GetValue(NodeRuntimeApplication runtimeApplication)
 {
     if (runtimeApplication == null)
     {
         throw new ArgumentNullException();
     }
     if (SignalId != null)
     {
         var signal = runtimeApplication.FindSignal(SignalId);
         if (signal != null)
         {
             return signal.Storage;
         }
         else
         {
             return null;
         }
     }
     else if (Literal != null)
     {
         NodeValue retVal = null;
         lock (m_LiteralNodeValue_Lock)
         {
             if (m_LiteralNodeValue == null)
             {
                 m_LiteralNodeValue = NodeValue.BuildWith(new FieldDataType(Literal.DataType));
                 m_LiteralNodeValue.Value = Literal.Value;
             }
             retVal = m_LiteralNodeValue;
         }
         return retVal;
     }
     else
     {
         return null;
     }
 }
Exemplo n.º 16
0
 public void ScanOutputs(NodeDriver driver, NodeRuntimeApplication runtimeApplication)
 {
 }
Exemplo n.º 17
0
 public IRuntime OpenRuntime(NodeRuntimeApplication rta)
 {
     var comPort = rta.Address.ToString().ToUpper();
     foreach (var rt in Runtimes)
     {
         var arduinoRuntimeProxy = rt as ArduinoRuntimeProxy;
         if (arduinoRuntimeProxy != null
             && arduinoRuntimeProxy.ComPort.ToUpper() == comPort.ToUpper())
         {
             return arduinoRuntimeProxy;
         }
     }
     ArduinoRuntimeProxy retVal = null;
     try
     {
         retVal = new ArduinoRuntimeProxy(
             this,
             comPort,
             this.m_runtimeService,
             this.messagingService);
         this.m_Runtimes.Add(retVal);
     }
     catch (ProtocolException ex)
     {
         this.messagingService.ShowMessage(
             ex.Message,
             "Error connecting to Runtime");
     }
     return retVal;
 }
Exemplo n.º 18
0
 /// <summary>
 /// Restores the state of all signals from a blob string created by signalStateToBlob
 /// </summary>
 /// <param name="rta">Runtime application to restore to</param>
 /// <param name="blob">blob</param>
 private static void restoreSignalStateFromBlob(NodeRuntimeApplication rta, string blob)
 {
     if (rta == null)
     {
         throw new ArgumentNullException("rta");
     }
     if (blob == null)
     {
         return;
     }
     var signalValues = EncodedSignalValue.ParseEncodedSignals(blob, rta.Signals);
     foreach (var signalTuple in signalValues)
     {
         NodeSignal signal = signalTuple.Item1;
         object value = signalTuple.Item2;
         try
         {
             signal.Value = value;
         }
         catch
         {
             // FIXME - tie into error reporting feature, to be developed
         }
     }
 }
Exemplo n.º 19
0
 private void ScanPageCollection(NodeRuntimeApplication rta, NodePageCollection pageCollection)
 {
     foreach (var childPageCollection in pageCollection.NodePageCollectionChildren)
     {
         ScanPageCollection(rta, childPageCollection);
     }
     foreach (var childPage in pageCollection.NodePageChildren)
     {
         ScanPage(rta, childPage);
     }
 }
Exemplo n.º 20
0
 /// <summary>
 /// Stores the state of all signals into a string that can be saved to a file.
 /// </summary>
 /// <param name="rta">Runtime application to store the state of</param>
 /// <returns>blob</returns>
 private static string signalStateToBlob(NodeRuntimeApplication rta)
 {
     if (rta == null)
     {
         throw new ArgumentNullException("rta");
     }
     var encodedSignals = from signal in rta.Signals select EncodedSignalValue.EncodeSignalValue(signal);
     return string.Join(string.Empty, encodedSignals);
 }
Exemplo n.º 21
0
 /// <summary>
 /// The value that should be output to the actual hardware
 /// and takes the forced status into account.  Threadsafe.
 /// </summary>
 public Decimal GetValue(NodeRuntimeApplication runtimeApplication)
 {
     if (runtimeApplication == null)
     {
         throw new ArgumentNullException();
     }
     if (Forced.BoolValue)
     {
         return (Decimal)ForcedValue.Value;
     }
     else
     {
         var nValue = SignalIn.GetValue(runtimeApplication);
         if (nValue != null && nValue.DataType.DataType == FieldDataType.DataTypeEnum.NUMBER)
         {
             return (Decimal)nValue.Value;
         }
         else
         {
             return (Decimal)FieldDataType.DefaultValue(FieldDataType.DataTypeEnum.NUMBER);
         }
     }
 }
Exemplo n.º 22
0
        private void ScanInstructionGroup(NodeRuntimeApplication rta, NodeInstructionGroup instructionGroup)
        {
            string language = instructionGroup.Language.ToString();
            IGroupExecutor executor = null;
            if (m_groupExecutors.ContainsKey(language))
            {
                executor = m_groupExecutors[language];
            }
            else
            {
                // this only instantiates new language modules if we're actually using that language
                foreach (var executorSearch in groupExecutorsImported)
                {
                    if (executorSearch.Metadata.Language == language)
                    {
                        executor = executorSearch.Value;
                        m_groupExecutors.Add(language, executor);
                        break;
                    }
                }
            }

            if (executor != null)
            {
                executor.ScanInstructionGroup(rta, instructionGroup);
            }
            else
            {
                // FIXME - should report the error - we can't execute it
            }
        }
Exemplo n.º 23
0
        public void BuildSignalTable(NodeRuntimeApplication runtimeApplication)
        {
            // initialize signal table to empty
            for (int i = 0; i < this.m_information.Booleans; i++)
            {
                this.m_booleanSignalsByAddress[i] = null;
            }
            for (int i = 0; i < this.m_information.Numerics; i++)
            {
                this.m_numericSignalsByAddress[i] = null;
            }
            this.m_booleanAddressBySignal.Clear();
            this.m_numericAddressBySignal.Clear();
            this.m_booleanJumpers.Clear();
            this.m_numericJumpers.Clear();

            // build the table
            Int16 maxBooleanAddress = 0;
            Byte maxNumericAddress = 0;
            foreach (var keyValuePair in runtimeApplication.DeviceConfiguration.GetChildrenRecursive())
            {
                if (keyValuePair.Value is NodeDiscreteInput)
                {
                    var nodeDiscreteInput = keyValuePair.Value as NodeDiscreteInput;
                    var address = Int16.Parse(nodeDiscreteInput.Address.ToString());
                    this.m_booleanSignalsByAddress[address] = nodeDiscreteInput.Signal;
                    var signalId = Guid.Parse(nodeDiscreteInput.Signal.SignalId.ToString());
                    this.m_booleanAddressBySignal.Add(signalId, address);
                    if (address > maxBooleanAddress) maxBooleanAddress = address;
                }
                else if (keyValuePair.Value is NodeDiscreteOutput)
                {
                    var nodeDiscreteOutput = keyValuePair.Value as NodeDiscreteOutput;
                    var address = Int16.Parse(nodeDiscreteOutput.Address.ToString());
                    if (address > maxBooleanAddress) maxBooleanAddress = address;
                }
                else if (keyValuePair.Value is NodeAnalogInput)
                {
                    var nodeAnalogInput = keyValuePair.Value as NodeAnalogInput;
                    var address = Byte.Parse(nodeAnalogInput.Address.ToString());
                    this.m_numericSignalsByAddress[address] = nodeAnalogInput.Signal;
                    var signalIdGuid = Guid.Parse(nodeAnalogInput.Signal.SignalId.ToString());
                    this.m_numericAddressBySignal.Add(signalIdGuid, address);
                    if (address > maxNumericAddress) maxNumericAddress = address;
                }
                else if (keyValuePair.Value is NodeAnalogOutput)
                {
                    var nodeAnalogOutput = keyValuePair.Value as NodeAnalogOutput;
                    var address = Byte.Parse(nodeAnalogOutput.Address.ToString());
                    if (address > maxNumericAddress) maxNumericAddress = address;
                }
            }

            // now add the other signals
            foreach (var signal in runtimeApplication.Signals)
            {
                var signalId = Guid.Parse(signal.SignalId.ToString());
                if (!this.m_booleanAddressBySignal.ContainsKey(signalId)
                    && !this.m_numericAddressBySignal.ContainsKey(signalId))
                {
                    switch (signal.DataType.DataType)
                    {
                        case FieldDataType.DataTypeEnum.BOOL:
                            Int16 booleanAddress = (Int16)(maxBooleanAddress + 1);
                            maxBooleanAddress = booleanAddress;
                            this.m_booleanAddressBySignal.Add(signalId, booleanAddress);
                            this.m_booleanSignalsByAddress[booleanAddress] = signal;
                            break;
                        case FieldDataType.DataTypeEnum.NUMBER:
                            Byte numericAddress = (Byte)(maxNumericAddress + 1);
                            maxNumericAddress = numericAddress;
                            this.m_numericAddressBySignal.Add(signalId, numericAddress);
                            this.m_numericSignalsByAddress[numericAddress] = signal;
                            break;
                        default:
                            throw new Exception("Arduino runtime only supports BOOL and NUMBER datatypes.");
                    }
                }
            }

            // now put in the jumpers between internal signals and outputs
            foreach (var keyValuePair in runtimeApplication.DeviceConfiguration.GetChildrenRecursive())
            {
                if (keyValuePair.Value is NodeDiscreteOutput)
                {
                    var nodeDiscreteOutput = keyValuePair.Value as NodeDiscreteOutput;
                    var address = Int16.Parse(nodeDiscreteOutput.Address.ToString());
                    var signalId = nodeDiscreteOutput.SignalIn.SignalId;
                    if (signalId != null)
                    {
                        var signal = runtimeApplication.FindSignal(signalId);
                        this.m_booleanSignalsByAddress[address] = signal;
                        var signalIdGuid = Guid.Parse(signal.SignalId.ToString());
                        this.m_booleanJumpers.Add(
                            new Tuple<Int16, Int16>(
                                this.m_booleanAddressBySignal[signalIdGuid], address));
                    }
                }
                else if (keyValuePair.Value is NodeAnalogOutput)
                {
                    var nodeAnalogOutput = keyValuePair.Value as NodeAnalogOutput;
                    var address = Byte.Parse(nodeAnalogOutput.Address.ToString());
                    var signalId = nodeAnalogOutput.SignalIn.SignalId;
                    if (signalId != null)
                    {
                        var signal = runtimeApplication.FindSignal(signalId);
                        this.m_numericSignalsByAddress[address] = signal;
                        var signalIdGuid = Guid.Parse(signal.SignalId.ToString());
                        this.m_numericJumpers.Add(
                            new Tuple<byte, byte>(
                                this.m_numericAddressBySignal[signalIdGuid], address));
                    }
                }
            }
        }
Exemplo n.º 24
0
 private void ScanPage(NodeRuntimeApplication rta, NodePage page)
 {
     foreach (var instructionGroup in page.NodeInstructionGroupChildren)
     {
         ScanInstructionGroup(rta, instructionGroup);
     }
 }
Exemplo n.º 25
0
        public static NodeRuntimeApplication BuildWith(
            FieldIdentifier Code, FieldGuid TypeId, FieldGuid RuntimeId,
            FieldString Address, FieldBase64 Configuration, FieldBool ExecuteOnStartup)
        {
            //build fields
            Dictionary<FieldIdentifier, FieldBase> mutableFields =
                new Dictionary<FieldIdentifier, FieldBase>();
            mutableFields.Add(new FieldIdentifier(m_CodeName), Code);
            mutableFields.Add(new FieldIdentifier(m_TypeIdName), TypeId);
            mutableFields.Add(new FieldIdentifier(m_RuntimeIdName), RuntimeId);
            mutableFields.Add(new FieldIdentifier(m_AddressName), Address);
            mutableFields.Add(new FieldIdentifier(m_ConfigurationName), Configuration);
            mutableFields.Add(new FieldIdentifier(m_ExecuteOnStartupName), ExecuteOnStartup);
            mutableFields.Add(new FieldIdentifier(m_TryModeName), new FieldBool(false));
            //Add Fields here: mutableFields.Add(new FieldIdentifier("Code"), Code);

            //build children
            KeyedNodeCollection<NodeBase> mutableChildren =
                new KeyedNodeCollection<NodeBase>();
            var pc = NodePageCollection.BuildWith(
                    new FieldPageCollectionName(m_LogicName)
                );
            pc = pc.SetLogicRoot(new FieldBool(true));
            mutableChildren.Add(pc);
            mutableChildren.Add(
                NodeDeviceConfiguration.BuildWith(
                    new ReadOnlyCollection<NodeDriver>(new Collection<NodeDriver>())
                ));
            //Add Children here: mutableChildren.Add(SomeChild);

            //build node
            NodeRuntimeApplication Builder = new NodeRuntimeApplication(
                new ReadOnlyDictionary<FieldIdentifier, FieldBase>(mutableFields),
                new ReadOnlyCollection<NodeBase>(mutableChildren));

            return Builder;
        }
Exemplo n.º 26
0
 private void SolveLogic(NodeRuntimeApplication rta)
 {
     ScanPageCollection(rta, rta.Logic);
 }
Exemplo n.º 27
0
 /// <summary>
 /// The value that should be output to the actual hardware
 /// and takes the forced status into account.  Threadsafe.
 /// </summary>
 public bool GetValue(NodeRuntimeApplication runtimeApplication)
 {
     if (runtimeApplication == null)
     {
         throw new ArgumentNullException();
     }
     if (Forced.BoolValue)
     {
         return ForcedValue.BoolValue;
     }
     else
     {
         var nValue = SignalIn.GetValue(runtimeApplication);
         if (nValue != null && nValue.DataType.DataType == FieldDataType.DataTypeEnum.BOOL)
         {
             return (bool)nValue.Value;
         }
         else
         {
             return false;
         }
     }
 }