public ASdu(TypeId typeId, bool isSequenceOfElements, CauseOfTransmission causeOfTransmission, bool test, bool negativeConfirm, int originatorAddress, int commonAddress, InformationObject[] informationObjects) { IsSequenceOfElements = isSequenceOfElements; this.typeId = typeId; this.causeOfTransmission = causeOfTransmission; this.test = test; this.negativeConfirm = negativeConfirm; this.originatorAddress = originatorAddress; this.commonAddress = commonAddress; this.informationObjects = informationObjects; privateInformation = null; sequenceLength = isSequenceOfElements ? informationObjects[0].GetInformationElements().Length : informationObjects.Length; }
public ASdu(BinaryReader reader, ConnectionSettings settings, int aSduLength) { int typeIdCode = reader.ReadByte(); typeId = (TypeId)typeIdCode; int tempbyte = reader.ReadByte(); IsSequenceOfElements = (tempbyte & 0x80) == 0x80; int numberOfSequenceElements; int numberOfInformationObjects; sequenceLength = tempbyte & 0x7f; if (IsSequenceOfElements) { numberOfSequenceElements = sequenceLength; numberOfInformationObjects = 1; } else { numberOfInformationObjects = sequenceLength; numberOfSequenceElements = 1; } tempbyte = reader.ReadByte(); causeOfTransmission = (CauseOfTransmission)(tempbyte & 0x3f); test = (tempbyte & 0x80) == 0x80; negativeConfirm = (tempbyte & 0x40) == 0x40; if (settings.CotFieldLength == 2) { originatorAddress = reader.ReadByte(); aSduLength--; } else { originatorAddress = -1; } if (settings.CommonAddressFieldLength == 1) { commonAddress = reader.ReadByte(); } else { commonAddress = reader.ReadByte() + (reader.ReadByte() << 8); aSduLength--; } if (typeIdCode < 128) { informationObjects = new InformationObject[numberOfInformationObjects]; for (var i = 0; i < numberOfInformationObjects; i++) { informationObjects[i] = new InformationObject(reader, typeId, numberOfSequenceElements, settings); } privateInformation = null; } else { informationObjects = null; privateInformation = reader.ReadBytes(aSduLength - 4); } }
public void SynchronizeClocks(int commonAddress, IeTime56 time) { var io = new InformationObject(0, new[] {new InformationElement[] {time}}); InformationObject[] ios = {io}; var aSdu = new ASdu(TypeId.C_CS_NA_1, false, CauseOfTransmission.ACTIVATION, false, false, originatorAddress, commonAddress, ios); Send(aSdu); }
public ASdu(BinaryReader reader, ConnectionSettings settings, int aSduLength) { int typeIdCode = reader.ReadByte(); typeId = (TypeId) typeIdCode; int tempbyte = reader.ReadByte(); IsSequenceOfElements = (tempbyte & 0x80) == 0x80; int numberOfSequenceElements; int numberOfInformationObjects; sequenceLength = tempbyte & 0x7f; if (IsSequenceOfElements) { numberOfSequenceElements = sequenceLength; numberOfInformationObjects = 1; } else { numberOfInformationObjects = sequenceLength; numberOfSequenceElements = 1; } tempbyte = reader.ReadByte(); causeOfTransmission = (CauseOfTransmission) (tempbyte & 0x3f); test = (tempbyte & 0x80) == 0x80; negativeConfirm = (tempbyte & 0x40) == 0x40; if (settings.CotFieldLength == 2) { originatorAddress = reader.ReadByte(); aSduLength--; } else { originatorAddress = -1; } if (settings.CommonAddressFieldLength == 1) { commonAddress = reader.ReadByte(); } else { commonAddress = reader.ReadByte() + (reader.ReadByte() << 8); aSduLength--; } if (typeIdCode < 128) { informationObjects = new InformationObject[numberOfInformationObjects]; for (var i = 0; i < numberOfInformationObjects; i++) { informationObjects[i] = new InformationObject(reader, typeId, numberOfSequenceElements, settings); } privateInformation = null; } else { informationObjects = null; privateInformation = reader.ReadBytes(aSduLength - 4); } }