public void Reconnect(bool ForNextProcessOnly) { if (!this.IsConnected) { FSUIPCConnection.AddOffset((IOffset)this); } this.onceOnly = ForNextProcessOnly; }
private void initDataInfo(string DataGroupName, int Address, int length, bool WriteOnly) { this.connected = true; this.address = Address; this.dataType = fsuipcDataType.TypeUnknown; this.writeOnly = WriteOnly; switch (typeof(DataType).Name) { case "Byte": this.dataType = fsuipcDataType.TypeByte; this.dataLength = 1; break; case "SByte": this.dataType = fsuipcDataType.TypeSByte; this.dataLength = 1; break; case "Int16": this.dataType = fsuipcDataType.TypeInt16; this.dataLength = 2; break; case "Int32": this.dataType = fsuipcDataType.TypeInt32; this.dataLength = 4; break; case "Int64": this.dataType = fsuipcDataType.TypeInt64; this.dataLength = 8; break; case "UInt16": this.dataType = fsuipcDataType.TypeUInt16; this.dataLength = 2; break; case "UInt32": this.dataType = fsuipcDataType.TypeUInt32; this.dataLength = 4; break; case "UInt64": this.dataType = fsuipcDataType.TypeUInt64; this.dataLength = 8; break; case "Double": this.dataType = fsuipcDataType.TypeDouble; this.dataLength = 8; break; case "Single": this.dataType = fsuipcDataType.TypeFloat; this.dataLength = 4; break; case "Byte[]": this.dataType = fsuipcDataType.TypeByteArray; this.dataValue = (DataType) new byte[length]; this.oldValue = (DataType) new byte[length]; this.dataLength = length; break; case "String": this.dataType = fsuipcDataType.TypeString; this.dataLength = length; break; case "BitArray": this.dataType = fsuipcDataType.TypeBitArray; this.dataLength = length; this.dataValue = (DataType) new BitArray(length * 8); this.oldValue = (DataType) new BitArray(length * 8); break; default: throw new Exception("Tried to create an Offset with an invalid type."); } if (this.dataType == fsuipcDataType.TypeByteArray || this.dataType == fsuipcDataType.TypeString || this.dataType == fsuipcDataType.TypeBitArray) { if (length <= 0) { throw new Exception("Must set a size set for ArrayOrStringLength for Byte[], BitArray or String."); } } else if (length > 0) { throw new Exception("Cannot specify an ArrayOrStringLength for datatypes other than Byte[], BitArray and String."); } this.group = DataGroupName; this.id = Guid.NewGuid(); FSUIPCConnection.AddOffset((IOffset)this); }