private void readNumericSignal(NodeSignal signal, byte numericAddress) { var readNumericResponse = this.m_arduinoRuntimeProtocol.ReadNumeric(numericAddress); signal.Value = readNumericResponse.Value; this.m_runtimeService.Value.NotifyValueChanged(signal, readNumericResponse.Value); }
private CompiledBooleanSignal booleanSignal(NodeSignal signal, SignalTable signalTable) { var signalAddress = signalTable.GetBooleanSignalAddress(signal); var compiledSignal = new CompiledBooleanSignal(false, signalAddress, signalTable.BooleanAddressBits); return(compiledSignal); }
private void readBooleanSignal(NodeSignal signal, Int16 booleanAddress) { var readBooleanResponse = this.m_arduinoRuntimeProtocol.ReadBoolean(booleanAddress); signal.Value = readBooleanResponse.Value; this.m_runtimeService.Value.NotifyValueChanged(signal, readBooleanResponse.Value); }
void runtimeService_ValuesChanged(NodeSignal signal, object value) { if (Signal != null && Signal.SignalId == signal.SignalId) { setText(value); } }
private void readTextBox() { var tb = textBox; var selectedText = tb.SelectedText; string unselectedText; if (selectedText.Length > 0) { unselectedText = tb.Text.Replace(selectedText, string.Empty); } else { unselectedText = tb.Text; } if (unselectedText.Length > 0) { // check to see if the value entered is a valid literal object parseResult; if (Signal.DataType.TryParse(unselectedText, out parseResult)) { tb.Text = parseResult.ToString(); } else { m_editedSignal = Signal; } } else { m_editedSignal = Signal; } }
private InstructionLDCoil(IEditorItem parent, NodeInstruction instruction) : base(parent, m_InstructionType) { if (instruction == null) { var newInstruction = NodeInstruction.BuildWith(InstructionType); // Output signal: Named boolean - the coil signal newInstruction = newInstruction.NodeSignalChildren.Append( NodeSignal.BuildWith( new FieldSignalName(Resources.Strings.LD_Snap_Coil_DefaultCoilName), new FieldDataType(FieldDataType.DataTypeEnum.BOOL), new FieldBool(false), FieldConstant.Constants.BOOL.LOW) // not forced ); Instruction = newInstruction; } else { if (instruction.InstructionType != InstructionType) { throw new InvalidOperationException("Tried to instantiate InstructionLDCoil but passed a different instruction type."); } Instruction = instruction; } // Build the context menu if (extensionService != null) { ContextMenu = extensionService.SortAndJoin(ldInstructionContextMenu, m_staticMenuItemSeparator, contextMenu); ContextMenuEnabled = true; } }
/// <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 } } }
protected InstructionLDAbstractEdge(IEditorItem parent, NodeInstruction instruction, FieldInstructionType instructionType) : base(parent, instructionType) { if (instruction == null) { var newInstruction = NodeInstruction.BuildWith(InstructionType); // Output signal: Named boolean - memory of last rung in newInstruction = newInstruction.NodeSignalChildren.Append( NodeSignal.BuildWith( new FieldSignalName(InstructionName), new FieldDataType(FieldDataType.DataTypeEnum.BOOL), new FieldBool(false), // not forced FieldConstant.Constants.BOOL.LOW) ); Instruction = newInstruction; } else { if (instruction.InstructionType != InstructionType) { throw new InvalidOperationException("Tried to instantiate an edge but passed a different instruction type."); } Instruction = instruction; } // Build the context menu if (extensionService != null) { ContextMenu = extensionService.SortAndJoin(ldInstructionContextMenu, m_staticMenuItemSeparator, contextMenu); ContextMenuEnabled = true; } }
public void RegisterValueWatcher(INodeWrapper nodeItem, NodeSignal signal) { if (nodeItem == null) { throw new ArgumentNullException("nodeItem"); } if (signal == null) { throw new ArgumentNullException("signal"); } var rta = FindParentRuntimeApplicationItem(nodeItem); if (rta != null) { lock (m_valueWatchers_Lock) { if (!m_valueWatchers.ContainsKey(rta)) { m_valueWatchers.Add(rta, new Dictionary <NodeSignal, int>()); } if (!m_valueWatchers[rta].ContainsKey(signal)) { m_valueWatchers[rta].Add(signal, 1); m_rtaLookup[nodeItem] = rta; } else { m_valueWatchers[rta][signal] += 1; } } } }
void runtimeService_SignalChanged(NodeSignal signal) { if (SignalIn != null && SignalIn.SignalId == signal.SignalId) { setText(); } }
void runtimeService_ValueChanged(NodeSignal signal, object value) { if (signal.SignalId == DiscreteInput.Signal.SignalId && value.GetType() == typeof(bool)) { setIcons((bool)value); } }
private CompiledNumericSignal numericSignal(NodeSignal signal, SignalTable signalTable) { var signalAddress = signalTable.GetNumericSignalAddress(signal); var compiledSignal = new CompiledNumericSignal(false, signalAddress, signalTable.NumericAddressBits); return(compiledSignal); }
public SignalValue(INodeWrapper nodeItem, NodeSignal initialSignal, double maxWidth, TextAlignment textAlignment, string formatString) { Signal = initialSignal; NodeItem = nodeItem; MaxWidth = maxWidth; TextAlignment = textAlignment; FormatString = formatString; }
protected InstructionLDAbstractCounter(IEditorItem parent, NodeInstruction instruction, FieldInstructionType instructionType) : base(parent, instructionType) { if (instruction == null) { var newInstruction = NodeInstruction.BuildWith(InstructionType); // Output signal: Named boolean - the counter done signal newInstruction = newInstruction.NodeSignalChildren.Append( NodeSignal.BuildWith( new FieldSignalName(Resources.Strings.LD_Snap_Ctr_DefaultName), new FieldDataType(FieldDataType.DataTypeEnum.BOOL), new FieldBool(false), // not forced FieldConstant.Constants.BOOL.LOW) ); newInstruction = newInstruction.NodeSignalChildren.Append( // memory of counter value NodeSignal.BuildWith( new FieldSignalName(Resources.Strings.LD_Snap_Ctr_DefaultName + SEPARATOR + Resources.Strings.LD_Snap_Ctr_CountName), new FieldDataType(FieldDataType.DataTypeEnum.NUMBER), new FieldBool(false), // not forced FieldConstant.Constants.NUMBER.ZERO) ); newInstruction = newInstruction.NodeSignalChildren.Append( // previous rung-in condition NodeSignal.BuildWith( new FieldSignalName(Resources.Strings.LD_Snap_Ctr_DefaultName + SEPARATOR + Resources.Strings.LD_Snap_Ctr_OneshotStateName), new FieldDataType(FieldDataType.DataTypeEnum.BOOL), new FieldBool(false), // not forced FieldConstant.Constants.BOOL.LOW) ); // Input signal: setpoint newInstruction = newInstruction.NodeSignalInChildren.Append( NodeSignalIn.BuildWith( new FieldDataType(FieldDataType.DataTypeEnum.NUMBER), new FieldConstant(FieldDataType.DataTypeEnum.NUMBER, 0))); // Input signal: reset newInstruction = newInstruction.NodeSignalInChildren.Append( NodeSignalIn.BuildWith( new FieldDataType(FieldDataType.DataTypeEnum.BOOL), new FieldConstant(FieldDataType.DataTypeEnum.BOOL, false))); Instruction = newInstruction; } else { if (instruction.InstructionType != InstructionType) { throw new InvalidOperationException("Tried to instantiate a Counter but passed a different instruction type."); } Instruction = instruction; } // Build the context menu if (extensionService != null) { ContextMenu = extensionService.SortAndJoin(ldInstructionContextMenu, m_staticMenuItemSeparator, contextMenu); ContextMenuEnabled = true; } }
public bool TryGetNumericSignalByAddress(Byte address, out NodeSignal signal) { if (address < 0 || address >= this.m_numericSignalsByAddress.Length) { signal = null; return(false); } signal = this.m_numericSignalsByAddress[address]; return(signal != null); }
public SignalTreeItem(SignalChooserDialog dlg, string text, NodeSignal sig) { if (dlg == null) { throw new ArgumentNullException("dlg"); } m_dlg = dlg; Text = text; m_NodeSignal = sig; }
public bool TryGetBooleanSignalByAddress(Int16 address, out NodeSignal signal) { if (address < 0 || address >= this.m_booleanSignalsByAddress.Length) { signal = null; return(false); } signal = this.m_booleanSignalsByAddress[address]; return(signal != null); }
public bool TryGetNumericAddressBySignal(NodeSignal signal, out Byte?numericAddress) { var signalId = Guid.Parse(signal.SignalId.ToString()); if (this.m_numericAddressBySignal.ContainsKey(signalId)) { numericAddress = this.m_numericAddressBySignal[signalId]; return(true); } numericAddress = null; return(false); }
protected InstructionLDMathBase(IEditorItem parent, FieldInstructionType instructionType, NodeInstruction instruction, string defaultName, bool factory, string instructionName, string firstSignalName, string secondSignalName) : base(parent, instructionType) { if (factory) { return; } this.InstructionName = instructionName; this.FirstSignalName = firstSignalName; this.SecondSignalName = secondSignalName; if (instruction == null) { var newInstruction = NodeInstruction.BuildWith(InstructionType); // Output signal: Named number - result newInstruction = newInstruction.NodeSignalChildren.Append( NodeSignal.BuildWith( new FieldSignalName(defaultName), new FieldDataType(FieldDataType.DataTypeEnum.NUMBER), new FieldBool(false), // not forced FieldConstant.Constants.NUMBER.ZERO) ); // Input signal: First newInstruction = newInstruction.NodeSignalInChildren.Append( NodeSignalIn.BuildWith( new FieldDataType(FieldDataType.DataTypeEnum.NUMBER), new FieldConstant(FieldDataType.DataTypeEnum.NUMBER, 0))); // Input signal: Second newInstruction = newInstruction.NodeSignalInChildren.Append( NodeSignalIn.BuildWith( new FieldDataType(FieldDataType.DataTypeEnum.NUMBER), new FieldConstant(FieldDataType.DataTypeEnum.NUMBER, 0))); Instruction = newInstruction; } else { if (instruction.InstructionType != InstructionType) { throw new InvalidOperationException("Tried to instantiate a different instruction type."); } Instruction = instruction; } // Build the context menu if (extensionService != null) { ContextMenu = extensionService.SortAndJoin(ldInstructionContextMenu, m_staticMenuItemSeparator, contextMenu); ContextMenuEnabled = true; } }
public Int16 GetBooleanSignalAddress(NodeSignal signal) { if (signal == null) { throw new ArgumentNullException("signal"); } Int16 result; if (!this.TryGetBooleanAddressBySignal(signal, out result)) { throw new Exception("Signal not found."); } return(result); }
public byte GetNumericSignalAddress(NodeSignal signal) { if (signal == null) { throw new ArgumentNullException("signal"); } Byte?result; if (!this.TryGetNumericAddressBySignal(signal, out result)) { throw new Exception("Signal not found."); } return(result.Value); }
public bool TryGetBooleanAddressBySignal(NodeSignal signal, out Int16 booleanAddress) { if (signal == null) { throw new ArgumentNullException("signal"); } var signalId = Guid.Parse(signal.SignalId.ToString()); if (this.m_booleanAddressBySignal.ContainsKey(signalId)) { booleanAddress = this.m_booleanAddressBySignal[signalId]; return(true); } booleanAddress = -1; return(false); }
protected InstructionLDStringContains(IEditorItem parent, NodeInstruction instruction) : base(parent, m_InstructionType) { if (instruction == null) { var newInstruction = NodeInstruction.BuildWith(InstructionType); // Output signal: Named boolean - result of the comparison newInstruction = newInstruction.NodeSignalChildren.Append( NodeSignal.BuildWith( new FieldSignalName(Resources.Strings.LD_Snap_StringContains_DefaultName), new FieldDataType(FieldDataType.DataTypeEnum.BOOL), new FieldBool(false), // not forced FieldConstant.Constants.BOOL.LOW) ); // Input signal: string to search newInstruction = newInstruction.NodeSignalInChildren.Append( NodeSignalIn.BuildWith( new FieldDataType(FieldDataType.DataTypeEnum.STRING), new FieldConstant(FieldDataType.DataTypeEnum.STRING, string.Empty))); // Input signal: string to find newInstruction = newInstruction.NodeSignalInChildren.Append( NodeSignalIn.BuildWith( new FieldDataType(FieldDataType.DataTypeEnum.STRING), new FieldConstant(FieldDataType.DataTypeEnum.STRING, string.Empty))); // Input signal: case sensitive newInstruction = newInstruction.NodeSignalInChildren.Append( NodeSignalIn.BuildWith( new FieldDataType(FieldDataType.DataTypeEnum.BOOL), new FieldConstant(FieldDataType.DataTypeEnum.BOOL, false))); Instruction = newInstruction; } else { if (instruction.InstructionType != InstructionType) { throw new InvalidOperationException("Tried to instantiate a StringContains but passed a different instruction type."); } Instruction = instruction; } // Build the context menu if (extensionService != null) { ContextMenu = extensionService.SortAndJoin(ldInstructionContextMenu, m_staticMenuItemSeparator, contextMenu); ContextMenuEnabled = true; } }
public void DeregisterValueWatcher(INodeWrapper nodeItem, NodeSignal signal) { if (nodeItem == null) { throw new ArgumentNullException("nodeItem"); } if (signal == null) { throw new ArgumentNullException("signal"); } var rta = FindParentRuntimeApplicationItem(nodeItem); if (rta == null) { lock (m_valueWatchers_Lock) { if (m_rtaLookup.ContainsKey(nodeItem)) { rta = m_rtaLookup[nodeItem]; } } } if (rta != null) { lock (m_valueWatchers_Lock) { if (m_valueWatchers.ContainsKey(rta)) { if (m_valueWatchers[rta].ContainsKey(signal)) { m_valueWatchers[rta][signal] -= 1; if (m_valueWatchers[rta][signal] <= 0) { m_rtaLookup.Remove(nodeItem); m_valueWatchers[rta].Remove(signal); if (m_valueWatchers[rta].Count == 0) { m_valueWatchers.Remove(rta); } } } } } } }
public void NotifyValueChanged(NodeSignal signal, object value) { if (signal != null) { ValueChangedHandler evt; lock (m_valuesChanged_Lock) { evt = m_valueChanged; } // Fire the event on the UI thread mainWindow.Value.Dispatcher.BeginInvoke(new Action(delegate() { if (evt != null) { evt(signal, value); } })); } }
// Encodes it as: // SignalId (guid) followed by a comma (,) // DataType (BOOL, NUMBER, DATETIME, STRING) followed by a comma (,) // Value Length (uint) followed by a comma (,) // Data Value as string - fixed length public static string EncodeSignalValue(NodeSignal signal) { if (signal != null) { string value = signal.Value.ToString(); var retVal = new StringBuilder(); retVal.Append(signal.SignalId.ToString()); retVal.Append(SEPARATOR); retVal.Append(signal.DataType.DataType.ToString()); retVal.Append(SEPARATOR); retVal.Append(value.Length.ToString()); retVal.Append(SEPARATOR); retVal.Append(value); // don't really need this, but it makes the resultant string a big easier to work with and debug retVal.Append(END_OF_LINE); return(retVal.ToString()); } else { return(string.Empty); } }
// Encodes it as: // SignalId (guid) followed by a comma (,) // DataType (BOOL, NUMBER, DATETIME, STRING) followed by a comma (,) // Value Length (uint) followed by a comma (,) // Data Value as string - fixed length public static string EncodeSignalValue(NodeSignal signal) { if (signal != null) { string value = signal.Value.ToString(); var retVal = new StringBuilder(); retVal.Append(signal.SignalId.ToString()); retVal.Append(SEPARATOR); retVal.Append(signal.DataType.DataType.ToString()); retVal.Append(SEPARATOR); retVal.Append(value.Length.ToString()); retVal.Append(SEPARATOR); retVal.Append(value); // don't really need this, but it makes the resultant string a big easier to work with and debug retVal.Append(END_OF_LINE); return retVal.ToString(); } else { return string.Empty; } }
public static void SetControlFillColorBySignal(DependencyObject target, NodeSignal value) { target.SetValue(SignalValueBehavior.ControlFillColorBySignalProperty, value); }
public NodeAnalogInput SetSignal(NodeSignal NewSignal) { if (NewSignal == null) { throw new ArgumentNullException(m_SignalName); } return m_Signal.Set(NewSignal); }
public void RegisterValueWatcher(INodeWrapper nodeItem, NodeSignal signal) { if (nodeItem == null) { throw new ArgumentNullException("nodeItem"); } if (signal == null) { throw new ArgumentNullException("signal"); } var rta = FindParentRuntimeApplicationItem(nodeItem); if (rta != null) { lock (m_valueWatchers_Lock) { if (!m_valueWatchers.ContainsKey(rta)) { m_valueWatchers.Add(rta, new Dictionary<NodeSignal, int>()); } if (!m_valueWatchers[rta].ContainsKey(signal)) { m_valueWatchers[rta].Add(signal,1); m_rtaLookup[nodeItem] = rta; } else { m_valueWatchers[rta][signal] += 1; } } } }
public byte GetNumericSignalAddress(NodeSignal signal) { if (signal == null) throw new ArgumentNullException("signal"); Byte? result; if (!this.TryGetNumericAddressBySignal(signal, out result)) { throw new Exception("Signal not found."); } return result.Value; }
public bool TryGetNumericSignalByAddress(Byte address, out NodeSignal signal) { if (address < 0 || address >= this.m_numericSignalsByAddress.Length) { signal = null; return false; } signal = this.m_numericSignalsByAddress[address]; return signal != null; }
public bool TryGetBooleanSignalByAddress(Int16 address, out NodeSignal signal) { if (address < 0 || address >= this.m_booleanSignalsByAddress.Length) { signal = null; return false; } signal = this.m_booleanSignalsByAddress[address]; return signal != null; }
public bool TryGetNumericAddressBySignal(NodeSignal signal, out Byte? numericAddress) { var signalId = Guid.Parse(signal.SignalId.ToString()); if (this.m_numericAddressBySignal.ContainsKey(signalId)) { numericAddress = this.m_numericAddressBySignal[signalId]; return true; } numericAddress = null; return false; }
public bool TryGetBooleanAddressBySignal(NodeSignal signal, out Int16 booleanAddress) { if (signal == null) throw new ArgumentNullException("signal"); var signalId = Guid.Parse(signal.SignalId.ToString()); if (this.m_booleanAddressBySignal.ContainsKey(signalId)) { booleanAddress = this.m_booleanAddressBySignal[signalId]; return true; } booleanAddress = -1; return false; }
public Int16 GetBooleanSignalAddress(NodeSignal signal) { if (signal == null) throw new ArgumentNullException("signal"); Int16 result; if (!this.TryGetBooleanAddressBySignal(signal, out result)) { throw new Exception("Signal not found."); } return result; }