public NodeTelegram SetMessageId(FieldGuid MessageId) { if (MessageId == null) { throw new ArgumentNullException(m_MessageIdName); } return(new NodeTelegram(this.SetField(new FieldIdentifier(m_MessageIdName), MessageId), ChildCollection)); }
internal NodeBase ReceiveDeltaFromPeer(NodePeer FromPeer, FieldGuid BasedOnMessageID) { if (CommunicationManager.LocalPeerList.Peers.Contains(this)) { return(OnReceiveDelta(FromPeer, BasedOnMessageID)); } else { return(null); } }
public NodePeer FindPeerByID(FieldGuid id) { if (GetChildrenRecursive().ContainsKey(id)) { NodeBase find = GetChildrenRecursive()[id]; return((NodePeer)find); } else { return(null); } }
public static NodeDevice StaticBuild() { FieldIdentifier code; FieldGuid typeId; FieldString address; FieldBase64 configuration; FieldDeviceName deviceName; code = new FieldIdentifier(CODE); typeId = new FieldGuid(TYPE_ID); address = new FieldString(string.Empty); configuration = new FieldBase64(string.Empty); deviceName = new FieldDeviceName(Resources.Strings.Unknown_Phidget_Name); NodeDevice device = NodeDevice.BuildWith(code, typeId, address, configuration, deviceName); return device; }
public static NodeTelegram BuildWith(FieldGuid MessageId, FieldString MessageType, FieldBase64 Payload) { //build fields Dictionary <FieldIdentifier, FieldBase> mutableFields = new Dictionary <FieldIdentifier, FieldBase>(); mutableFields.Add(new FieldIdentifier(m_MessageIdName), MessageId); mutableFields.Add(new FieldIdentifier(m_MessageTypeName), MessageType); mutableFields.Add(new FieldIdentifier(m_PayloadName), Payload); //Add Fields here: mutableFields.Add(new FieldIdentifier(m_CodeName), Code); //build children KeyedNodeCollection <NodeBase> mutableChildren = new KeyedNodeCollection <NodeBase>(); //Add Children here: mutableChildren.Add(SomeChild); //build node NodeTelegram Builder = new NodeTelegram( new ReadOnlyDictionary <FieldIdentifier, FieldBase>(mutableFields), new ReadOnlyCollection <NodeBase>(mutableChildren)); return(Builder); }
public static IEnumerable<Tuple<NodeSignal, object>> ParseEncodedSignals(string encoded, IEnumerable<NodeSignal> signals) { // parse it all into values var dict = new Dictionary<FieldGuid, object>(); int index = 0; bool found = true; while (found) { found = false; int commaPos1 = encoded.IndexOf(SEPARATOR, index); if (commaPos1 > 0) // signalId { int commaPos2 = encoded.IndexOf(SEPARATOR, commaPos1 + 1); if (commaPos2 > 0) // DataType { int commaPos3 = encoded.IndexOf(SEPARATOR, commaPos2 + 1); if (commaPos3 > 0) // value length { string valueLengthString = encoded.Substring(commaPos2 + 1, commaPos3 - commaPos2 - 1); int valueLength; if (int.TryParse(valueLengthString, out valueLength)) { string valueString = encoded.Substring(commaPos3 + 1, valueLength); if (valueString.Length == valueLength) { string guidString = encoded.Substring(index, commaPos1 - index); if (FieldGuid.CheckSyntax(guidString)) { var signalId = new FieldGuid(guidString); string dataTypeString = encoded.Substring(commaPos1 + 1, commaPos2 - commaPos1 - 1); FieldDataType.DataTypeEnum dataType; if (Enum.TryParse<FieldDataType.DataTypeEnum>(dataTypeString, out dataType)) { if (FieldConstant.CheckSyntax(dataType + FieldConstant.SEPARATOR + valueString)) { var constant = new FieldConstant(dataType + FieldConstant.SEPARATOR + valueString); found = true; index = commaPos3 + valueLength + 1 + END_OF_LINE.Length; dict.Add(signalId, constant.Value); } } } } } } } } } // match it up to the signals var retVal = new List<Tuple<NodeSignal, object>>(); foreach (var signal in signals) { if (dict.ContainsKey(signal.SignalId)) { retVal.Add(new Tuple<NodeSignal, object>(signal, dict[signal.SignalId])); } } return retVal; }
private Collection<SignalTreeItem> BuildSignalTree(SignalChooserDialog dlg, NodeBase n, NodePage pg, FieldGuid selectedSignalId, FieldDataType.DataTypeEnum dataTypeFilter) { var items = new Collection<SignalTreeItem>(); foreach (var child in n.ChildCollection) { var nPageCollection = child as NodePageCollection; var nPage = child as NodePage; var nInstructionGroup = child as NodeInstructionGroup; var nInstruction = child as NodeInstruction; var nSignal = child as NodeSignal; var nDeviceConfiguration = child as NodeDeviceConfiguration; var nDriver = child as NodeDriver; var nDevice = child as NodeDevice; var nDiscreteInput = child as NodeDiscreteInput; var nAnalogInput = child as NodeAnalogInput; var nStringInput = child as NodeStringInput; // the following logic sets one or the other, or neither SignalTreeItem item = null; NodeBase searchChildren = null; bool sort = false; var adjustedChild = child; if (nPageCollection != null) { item = new SignalTreeItem(dlg, nPageCollection.PageCollectionName.ToString(), null); } else if (nPage != null) { var pgToUse = nPage; if (pg != null && nPage.PageId == pg.PageId) { pgToUse = pg; adjustedChild = pg; } item = new SignalTreeItem(dlg, pgToUse.PageName.ToString(), null); sort = true; } else if (nInstructionGroup != null || nInstruction != null || nDiscreteInput != null || nAnalogInput != null || nStringInput != null) { searchChildren = adjustedChild; } else if (nSignal != null) { if (nSignal.DataType.IsOfType(dataTypeFilter)) { item = new SignalTreeItem(dlg, nSignal.SignalName.ToString(), nSignal); if (nSignal.SignalId == selectedSignalId) { item.IsSelected = true; } } } else if (nDeviceConfiguration != null) { item = new SignalTreeItem(dlg, Resources.Strings.Solution_Pad_DeviceConfigurationItem_Header, null); } else if (nDriver != null) { item = new SignalTreeItem(dlg, nDriver.DriverName.ToString(), null); } else if (nDevice != null) { item = new SignalTreeItem(dlg, nDevice.DeviceName.ToString(), null); } if (searchChildren != null) { var childItems = BuildSignalTree(dlg, searchChildren, pg, selectedSignalId, dataTypeFilter); if(childItems != null) { foreach (var childItem in childItems) { items.Add(childItem); } } } if (item != null) { items.Add(item); var childItems = BuildSignalTree(dlg, adjustedChild, pg, selectedSignalId, dataTypeFilter); if (childItems != null) { if (sort) { var sorted = from c in childItems orderby c.Text select c; childItems = new Collection<SignalTreeItem>(); foreach (var c in sorted) { childItems.Add(c); } } // make sure to have this branch of the tree expanded if the selected node is somewhere down there if (childItems.Count((SignalTreeItem ti) => ti.IsSelected) > 0 || childItems.Count((SignalTreeItem ti) => ti.IsExpanded) > 0) { item.IsExpanded = true; } item.SetItems(childItems); } } } if (items.Count > 0) { return items; } else { return null; } }
internal NodeBase ReceiveDeltaFromPeer(NodePeer FromPeer, FieldGuid BasedOnMessageID) { if (CommunicationManager.LocalPeerList.Peers.Contains(this)) { return OnReceiveDelta(FromPeer, BasedOnMessageID); } else { return null; } }
/// <summary> /// Searches the tree for a signal matching this signal ID. /// </summary> public NodeSignal FindSignal(FieldGuid signalId) { if (m_signalLookup.ContainsKey(signalId.ToString())) { return m_signalLookup[signalId.ToString()]; } else { return null; } }
public NodeRuntimeApplication SetRuntimeId(FieldGuid RuntimeId) { if (RuntimeId == null) { throw new ArgumentNullException(m_RuntimeIdName); } return new NodeRuntimeApplication(this.SetField(new FieldIdentifier(m_RuntimeIdName), RuntimeId), ChildCollection); }
public static NodeTelegram BuildWith(FieldGuid MessageId, FieldString MessageType, FieldBase64 Payload) { //build fields Dictionary<FieldIdentifier, FieldBase> mutableFields = new Dictionary<FieldIdentifier, FieldBase>(); mutableFields.Add(new FieldIdentifier(m_MessageIdName), MessageId); mutableFields.Add(new FieldIdentifier(m_MessageTypeName), MessageType); mutableFields.Add(new FieldIdentifier(m_PayloadName), Payload); //Add Fields here: mutableFields.Add(new FieldIdentifier(m_CodeName), Code); //build children KeyedNodeCollection<NodeBase> mutableChildren = new KeyedNodeCollection<NodeBase>(); //Add Children here: mutableChildren.Add(SomeChild); //build node NodeTelegram Builder = new NodeTelegram( new ReadOnlyDictionary<FieldIdentifier, FieldBase>(mutableFields), new ReadOnlyCollection<NodeBase>(mutableChildren)); return Builder; }
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); }
public NodeInstruction SetSignalInToSignalId(int index, FieldGuid signalId) { var oldSignalIn = this.NodeSignalInChildren[index]; var newSignalIn = NodeSignalIn.BuildWith(oldSignalIn.DataType, signalId); var newInstruction = this.NodeSignalInChildren.Replace(oldSignalIn, newSignalIn); return newInstruction; }
private static Tuple<string, NodeSignal> FindSignalAndName(NodeBase fromNode, string header, NodePage localRoot, FieldGuid signalId, Dictionary<NodePage, NodePage> edits) { const string SEPARATOR = "/"; string prevHeader; if (header.Length == 0) { prevHeader = string.Empty; } else { prevHeader = header + SEPARATOR; } var thisSig = fromNode as NodeSignal; if (thisSig != null && thisSig.SignalId == signalId) { return new Tuple<string, NodeSignal>(prevHeader + thisSig.SignalName, thisSig); } else { foreach (var child in fromNode.ChildCollection) { var nPageCollection = child as NodePageCollection; var nPage = child as NodePage; var nInstructionGroup = child as NodeInstructionGroup; var nInstruction = child as NodeInstruction; var nSignal = child as NodeSignal; var nDeviceConfiguration = child as NodeDeviceConfiguration; var nDriver = child as NodeDriver; var nDevice = child as NodeDevice; var nDiscreteInput = child as NodeDiscreteInput; var nAnalogInput = child as NodeAnalogInput; var nStringInput = child as NodeStringInput; Tuple<string, NodeSignal> found = null; if (nInstructionGroup != null || nInstruction != null || nDeviceConfiguration != null || nDriver != null || nDiscreteInput != null || nAnalogInput != null || nStringInput != null || nSignal != null) { found = FindSignalAndName(child, header, localRoot, signalId, edits); } else if (nPageCollection != null) { found = FindSignalAndName(child, prevHeader + nPageCollection.PageCollectionName, localRoot, signalId, edits); } else if (nPage != null) { string newHeader = prevHeader + nPage.PageName; if (nPage == localRoot) // first, search local page, if there is one { found = FindSignalAndName(child, string.Empty, localRoot, signalId, edits); } if (found == null && edits.ContainsKey(nPage)) // search edited page, if there is one { found = FindSignalAndName(edits[nPage], newHeader, localRoot, signalId, edits); } if (found == null) // search from the root otherwise { found = FindSignalAndName(child, newHeader, localRoot, signalId, edits); } } else if (nDevice != null) { found = FindSignalAndName(child, prevHeader + nDevice.DeviceName, localRoot, signalId, edits); } if (found != null) { return found; } } return null; } }
public NodeSignalIn SetSignalId(FieldGuid SignalId) { return new NodeSignalIn(this.SetField(new FieldIdentifier(m_SignalIdName), SignalId), ChildCollection); }
public static NodeDevice BuildWith( FieldIdentifier Code, FieldGuid TypeId, FieldString Address, FieldBase64 Configuration, FieldDeviceName DeviceName) { //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_AddressName), Address); mutableFields.Add(new FieldIdentifier(m_ConfigurationName), Configuration); mutableFields.Add(new FieldIdentifier(m_DeviceNameName), DeviceName); //Add Fields here: mutableFields.Add(new FieldIdentifier(m_CodeName), Code); //build children KeyedNodeCollection<NodeBase> mutableChildren = new KeyedNodeCollection<NodeBase>(); //Add Children here: mutableChildren.Add(SomeChild); //build node NodeDevice Builder = new NodeDevice( new ReadOnlyDictionary<FieldIdentifier, FieldBase>(mutableFields), new ReadOnlyCollection<NodeBase>(mutableChildren)); return Builder; }
public static NodeSignalIn BuildWith(FieldDataType DataType, FieldDataType CompatibleTypes, FieldGuid SignalId) { //build fields Dictionary<FieldIdentifier, FieldBase> mutableFields = new Dictionary<FieldIdentifier, FieldBase>(); mutableFields.Add(new FieldIdentifier(m_DataTypeName), DataType); mutableFields.Add(new FieldIdentifier(m_CompatibleTypesName), CompatibleTypes); mutableFields.Add(new FieldIdentifier(m_SignalIdName), SignalId); //Add Fields here: mutableFields.Add(new FieldIdentifier(m_CodeName), Code); //build children KeyedNodeCollection<NodeBase> mutableChildren = new KeyedNodeCollection<NodeBase>(); //Add Children here: mutableChildren.Add(SomeChild); //build node NodeSignalIn Builder = new NodeSignalIn( new ReadOnlyDictionary<FieldIdentifier, FieldBase>(mutableFields), new ReadOnlyCollection<NodeBase>(mutableChildren)); return Builder; }
public static NodeSignalIn BuildWith(FieldDataType DataType, FieldGuid SignalId) { return BuildWith(DataType, DataType, SignalId); }
private void Receive(string message) { //TextWriter tw = new StreamWriter("receive_" + this.ID.ToString() + ".txt", true); //tw.WriteLine(message); //tw.Close(); if (ValidateXmlToSchema(message)) { FieldGuid toPeerID = NodeBase.ToPeerFromXML(message); FieldGuid fromPeerID = NodeBase.FromPeerFromXML(message); if (toPeerID != null && fromPeerID != null) { //it's a peer-to-peer message //find the ToPeer in the local peer list NodePeer ToPeer = CommunicationManager.LocalPeerList.FindPeerByID(toPeerID); //find the FromPeer in the remote peer list NodePeer FromPeer = RemotePeerList.FindPeerByID(fromPeerID); if (ToPeer != null && FromPeer != null) { //see if this message is based on another node FieldGuid BasedOnNodeID = NodeBase.BasedOnNodeIDFromXML(message); NodeBase basedOnNode = null; if (BasedOnNodeID != null) { basedOnNode = ToPeer.ReceiveDeltaFromPeer(FromPeer, BasedOnNodeID); NodeBase msg = NodeBase.NodeFromXML(message, basedOnNode.GetChildrenRecursive()); CommunicationManager.SendDeltaToPeer(ToPeer, FromPeer, msg, basedOnNode); } else { NodeBase msg = NodeBase.NodeFromXML(message, null); CommunicationManager.SendToPeer(ToPeer, FromPeer, msg); } } else { //TODO - log this - undeliverable message (peer lists not up to date?) } } else { //it's a system message (not peer-to-peer) FieldNodeType nodeType = NodeBase.NodeTypeFromXML(message); if (nodeType.ToString() == typeof(NodePeerList).FullName) { lock (m_remotePeerList_Lock) //lock so we read/write in one operation { //When we receive a remote peer list, it is generally just a diff //from the last peer list. RemotePeerList = (NodePeerList)NodeBase.NodeFromXML( message, RemotePeerList.GetChildrenRecursive()); } } else { //TODO - log this? Unknown root message type? } } } else { //TODO - log this? Unknown garbage message? } }
/// <summary> /// Searches the runtime application for a signal matching the given signalId /// </summary> public Tuple<string, NodeSignal> FindSignal(INodeWrapper requester, FieldGuid signalId) { var tpl = FindParentPageAndRuntimeApp(requester); NodePage pg = tpl.Item1; NodeRuntimeApplication rta = tpl.Item2; if (rta != null) { var edits = new Dictionary<NodePage,NodePage>(); if (pg != null) { // Searches the local page first var tryLocal = FindSignalAndName(pg, string.Empty, pg, signalId, edits); if (tryLocal != null) { return tryLocal; } } // Make a list of edited page copies foreach (var d in layoutManager.Documents) { var pageEditor = d as PageEditor; if (pageEditor != null) { edits.Add(pageEditor.PageItemParent.Page, pageEditor.EditorRoot.WorkingCopy); } } return FindSignalAndName(rta, string.Empty, pg, signalId, edits); } else { return null; } }
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; }
private NodeTelegram readSignals(NodeTelegram request) { // incoming request should just be a bunch of Guids that represent signalIds var inPayload = request.Payload.Decode(); var outPayload = new StringBuilder(); if (runtimeApplication != null) { for (int index = 0; index < inPayload.Length; index += m_guidLength) { string oneGuidString = inPayload.Substring(index, m_guidLength); if (FieldGuid.CheckSyntax(oneGuidString)) { var signalId = new FieldGuid(oneGuidString); var signal = runtimeApplication.FindSignal(signalId); if (signal != null) { outPayload.Append(EncodedSignalValue.EncodeSignalValue(signal)); } } } } return request.SetPayload(FieldBase64.Encode(outPayload.ToString())); }
public NodeTelegram SetMessageId(FieldGuid MessageId) { if (MessageId == null) { throw new ArgumentNullException(m_MessageIdName); } return new NodeTelegram(this.SetField(new FieldIdentifier(m_MessageIdName), MessageId), ChildCollection); }
public NodeDevice SetTypeId(FieldGuid TypeId) { if (TypeId == null) { throw new ArgumentNullException(m_TypeIdName); } return new NodeDevice(this.SetField(new FieldIdentifier(m_TypeIdName), TypeId), ChildCollection); }
public static NodeDevice StaticBuildHelper(string deviceName, string typeId, Guid instanceId, string code, int buttons, int axes, int povhats) { FieldIdentifier c; FieldGuid typ; FieldString address; FieldBase64 configuration; FieldDeviceName dName; c = new FieldIdentifier(code); typ = new FieldGuid(typeId); address = new FieldString(instanceId.ToString()); configuration = new FieldBase64(string.Empty); dName = new FieldDeviceName(deviceName); NodeDevice device = NodeDevice.BuildWith(c, typ, address, configuration, dName); // Add the inputs var inputsMutable = new Collection<NodeDiscreteInput>(); for (int i = 0; i < buttons; i++) { int buttonNumber = i + 1; inputsMutable.Add(NodeDiscreteInput.BuildWith( new FieldIdentifier(Resources.Strings.Button + buttonNumber), new FieldString(i.ToString()), new FieldSignalName(Resources.Strings.Button + " " + buttonNumber))); } var inputs = new ReadOnlyCollection<NodeDiscreteInput>(inputsMutable); device = device.NodeDiscreteInputChildren.Append(inputs); var analogInputsMutable = new Collection<NodeAnalogInput>(); for (int i = 0; i < axes; i++) { if (i == 3) break; // only supports up to 3 axes int axisNumber = i + 1; string axisName = axisNumber == 1 ? "X" : axisNumber == 2 ? "Y" : axisNumber == 3 ? "Z" : null; analogInputsMutable.Add(NodeAnalogInput.BuildWith( new FieldIdentifier(axisName), new FieldString(axisName), new FieldSignalName(axisName))); string rotationName = "Rotation" + axisName; analogInputsMutable.Add(NodeAnalogInput.BuildWith( new FieldIdentifier(rotationName), new FieldString(rotationName), new FieldSignalName(rotationName))); } for (int i = 0; i < povhats; i++) { int povNumber = i + 1; analogInputsMutable.Add(NodeAnalogInput.BuildWith( new FieldIdentifier(Resources.Strings.PoVHat + povNumber.ToString()), new FieldString(i.ToString()), new FieldSignalName(Resources.Strings.PoVHat + " " + povNumber.ToString()))); } device = device.NodeAnalogInputChildren.Append(new ReadOnlyCollection<NodeAnalogInput>(analogInputsMutable)); return device; }
public static NodeDevice StaticBuildHelper(string deviceName, int serialNumber, string code, string typeId, int discreteInputs, int discreteOutputs, int analogInputs, int analogOutputs, int stringInputs, int stringOutputs, string analogOutputNameOverride, string discreteOutputNameOverride) { FieldIdentifier c; FieldGuid typ; FieldString address; FieldBase64 configuration; FieldDeviceName dName; c = new FieldIdentifier(code); typ = new FieldGuid(typeId); address = new FieldString(serialNumber.ToString()); configuration = new FieldBase64(string.Empty); dName = new FieldDeviceName(deviceName); NodeDevice device = NodeDevice.BuildWith(c, typ, address, configuration, dName); // Add the inputs var inputsMutable = new Collection<NodeDiscreteInput>(); for (int i = 0; i < discreteInputs; i++) { inputsMutable.Add(NodeDiscreteInput.BuildWith( new FieldIdentifier(Resources.Strings.Input + i), new FieldString(i.ToString()), new FieldSignalName(Resources.Strings.Input + " " + i))); } var inputs = new ReadOnlyCollection<NodeDiscreteInput>(inputsMutable); device = device.NodeDiscreteInputChildren.Append(inputs); var analogInputsMutable = new Collection<NodeAnalogInput>(); for (int i = 0; i < analogInputs; i++) { analogInputsMutable.Add(NodeAnalogInput.BuildWith( new FieldIdentifier(Resources.Strings.AnalogInput + i), new FieldString(i.ToString()), new FieldSignalName(Resources.Strings.AnalogInput + " " + i))); } device = device.NodeAnalogInputChildren.Append(new ReadOnlyCollection<NodeAnalogInput>(analogInputsMutable)); var stringInputsMutable = new Collection<NodeStringInput>(); for (int i = 0; i < stringInputs; i++) { stringInputsMutable.Add(NodeStringInput.BuildWith( new FieldIdentifier(Resources.Strings.StringInput + i), new FieldString(i.ToString()), new FieldSignalName(Resources.Strings.StringInput + " " + i))); } device = device.NodeStringInputChildren.Append(new ReadOnlyCollection<NodeStringInput>(stringInputsMutable)); // Add the outputs var outputsMutable = new Collection<NodeDiscreteOutput>(); for (int i = 0; i < discreteOutputs; i++) { outputsMutable.Add(NodeDiscreteOutput.BuildWith( new FieldIdentifier(Resources.Strings.Output + i), new FieldString(i.ToString()), new FieldSignalName(discreteOutputNameOverride + " " + i))); } var outputs = new ReadOnlyCollection<NodeDiscreteOutput>(outputsMutable); device = device.NodeDiscreteOutputChildren.Append(outputs); var analogOutputsMutable = new Collection<NodeAnalogOutput>(); for (int i = 0; i < analogOutputs; i++) { analogOutputsMutable.Add(NodeAnalogOutput.BuildWith( new FieldIdentifier(Resources.Strings.AnalogOutput + i), new FieldString(i.ToString()), new FieldSignalName(analogOutputNameOverride + " " + i))); } device = device.NodeAnalogOutputChildren.Append(new ReadOnlyCollection<NodeAnalogOutput>(analogOutputsMutable)); var stringOutputsMutable = new Collection<NodeStringOutput>(); for (int i = 0; i < stringOutputs; i++) { stringOutputsMutable.Add(NodeStringOutput.BuildWith( new FieldIdentifier(Resources.Strings.StringOutput + i), new FieldString(i.ToString()), new FieldSignalName(Resources.Strings.StringOutput + " " + i))); } device = device.NodeStringOutputChildren.Append(new ReadOnlyCollection<NodeStringOutput>(stringOutputsMutable)); return device; }
NodeBase peer_OnReceiveDelta(NodePeer FromPeer, FieldGuid BasedOnMessageID) { NodeBase originalMessage = null; IRuntime runtime = getRelationship(FromPeer); if (runtime != null) { originalMessage = runtime.DeltaReceivedFromPeer(BasedOnMessageID); } return originalMessage; }