public override NodeDevice Build() { var device = NodeDevice.BuildWith( new FieldIdentifier(CODE), new FieldGuid(TYPE_ID), new FieldString(string.Empty), new FieldBase64(string.Empty), new FieldDeviceName(this.Name)); device = device.NodeStringInputChildren.Append( NodeStringInput.BuildWith( new FieldIdentifier(STRING_INPUT_0_CODE), new FieldString(string.Empty), new FieldSignalName(Resources.Strings.UserStatusMonitor_StringInput0))); device = device.NodeDiscreteInputChildren.Append( NodeDiscreteInput.BuildWith( new FieldIdentifier(DISCRETE_INPUT_0_CODE), new FieldString(string.Empty), new FieldSignalName(Resources.Strings.UserStatusMonitor_DiscreteInput0))); 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); }