Gurux.DLMS.GXByteBuffer.Set C# (CSharp) Method

Set() public method

public Set ( GXByteBuffer value ) : void
value GXByteBuffer
return void
        public void Set(GXByteBuffer value)
        {
            if (value != null)
            {
                Set(value, value.Size - value.Position);
            }
        }

Same methods

GXByteBuffer::Set ( GXByteBuffer value, int count ) : void
GXByteBuffer::Set ( byte value ) : void
GXByteBuffer::Set ( byte value, int index, int count ) : void
GXByteBuffer::Set ( int index, byte value ) : void

Usage Example

Esempio n. 1
0
        /// <summary>
        /// Generates discover report.
        /// </summary>
        /// <param name="systemTitle">System title</param>
        /// <param name="newMeter">Is this a new meter.</param>
        /// <returns>Generated bytes.</returns>
        public byte[] DiscoverReport(byte[] systemTitle, bool newMeter)
        {
            GXByteBuffer bb = new GXByteBuffer();

            if (settings.InterfaceType != Enums.InterfaceType.Plc &&
                settings.InterfaceType != Enums.InterfaceType.PlcHdlc)
            {
                throw new ArgumentOutOfRangeException("Invalid interface type.");
            }
            byte alarmDescription;

            if (settings.InterfaceType == Enums.InterfaceType.Plc)
            {
                alarmDescription = (byte)(newMeter ? 1 : 0x82);
            }
            else
            {
                alarmDescription = 0;
            }
            if (settings.InterfaceType == Enums.InterfaceType.PlcHdlc)
            {
                bb.Set(GXCommon.LLCReplyBytes);
            }
            bb.SetUInt8((byte)Command.DiscoverReport);
            bb.SetUInt8(1);
            bb.Set(systemTitle);
            if (alarmDescription != 0)
            {
                bb.SetUInt8(1);
            }
            bb.SetUInt8(alarmDescription);
            int    clientAddress    = settings.ClientAddress;
            int    serverAddress    = settings.ServerAddress;
            UInt16 macSourceAddress = settings.Plc.MacSourceAddress;
            UInt16 macTargetAddress = settings.Plc.MacDestinationAddress;

            try
            {
                //10.4.6.4 Source and destination APs and addresses of CI-PDUs
                //Client address is No-station in discoverReport.
                if (settings.InterfaceType == Enums.InterfaceType.PlcHdlc)
                {
                    settings.Plc.MacDestinationAddress = (UInt16)PlcHdlcSourceAddress.Initiator;
                }
                else
                {
                    settings.ClientAddress = 0;
                    settings.ServerAddress = 0xFD;
                }
                return(GXDLMS.GetMacFrame(settings, 0x13, 0, bb));
            }
            finally
            {
                settings.ClientAddress             = clientAddress;
                settings.ServerAddress             = serverAddress;
                settings.Plc.MacSourceAddress      = macSourceAddress;
                settings.Plc.MacDestinationAddress = macTargetAddress;
            }
        }
All Usage Examples Of Gurux.DLMS.GXByteBuffer::Set