Example #1
0
        public MultiServiceReply(EncapsReply reply)
        {
            EncapsRRData rrData = new EncapsRRData();
            CommonPacket cpf    = new CommonPacket();

            int temp = 0;

            rrData.Expand(reply.EncapsData, 0, out temp);
            cpf = rrData.CPF;

            MessageRouterResponse response = new MessageRouterResponse();

            response.Expand(cpf.DataItem.Data, 2, out temp);

            if (response.GeneralStatus == 0x1E)
            {
                IsPartial = true;
            }

            ReplyService = response.ReplyService;
            GenSTS       = response.GeneralStatus;

            ServiceReplies = new List <ServiceReply>();

            if (response.ResponseData != null)
            {
                Expand(response.ResponseData);
            }
        }
Example #2
0
        public ReadDataServiceReply(EncapsReply reply)
        {
            //First we have to get the data item...
            EncapsRRData rrData = new EncapsRRData();

            CommonPacket cpf  = new CommonPacket();
            int          temp = 0;

            rrData.Expand(reply.EncapsData, 0, out temp);
            cpf = rrData.CPF;

            //The data item contains the information in an MR_Response
            MR_Response response = new MR_Response();

            response.Expand(cpf.DataItem.Data, 2, out temp);

            Service = response.ReplyService;
            Status  = response.GeneralStatus;

            byte[] bbTemp = new byte[4];
            Buffer.BlockCopy(BitConverter.GetBytes(Status), 0, bbTemp, 0, 2);

            if (Status == 0xFF)
            {
                if (response.AdditionalStatus_Size > 0)
                {
                    Buffer.BlockCopy(response.AdditionalStatus, 0, bbTemp, 2, 2);
                }
            }

            ByteStatus = bbTemp;

            //Now check the response code...
            if (response.GeneralStatus != 0 && response.GeneralStatus != 0x06)
            {
                return;
            }

            if (response.ResponseData != null)
            {
                //Now we suck out the data type...
                DataType = BitConverter.ToUInt16(response.ResponseData, 0);
                byte[] tempB = new byte[response.ResponseData.Length - 2];
                Buffer.BlockCopy(response.ResponseData, 2, tempB, 0, tempB.Length);
                Data = tempB;
            }
            else
            {
                DataType = 0x0000;
            }
        }
        /// <summary>
        /// Sets the processor to be in the PROGRAM mode
        /// </summary>
        /// <remarks>The keyswitch must be in the REM position for this to work.</remarks>
        public void SetProgramMode()
        {
            //lock (_lockObject)
            {
                CommonPacket cpf = new CommonPacket();
                cpf.AddressItem = CommonPacketItem.GetConnectedAddressItem(_session.ConnectionParameters.O2T_CID);

                byte[] request = new byte[] { 0x07, 0x02, 0x20, 0x8E, 0x24, 0x01 };

                cpf.DataItem = CommonPacketItem.GetConnectedDataItem(request, SequenceNumberGenerator.SequenceNumber);

                _session.SendUnitData(cpf.AddressItem, cpf.DataItem);
            }
        }
        public ReadDataServiceReply(EncapsReply reply)
        {
            //First we have to get the data item...
            EncapsRRData rrData = new EncapsRRData();

            CommonPacket cpf = new CommonPacket();
            int temp = 0;
            rrData.Expand(reply.EncapsData, 0, out temp);
            cpf = rrData.CPF;

            //The data item contains the information in an MR_Response
            MR_Response response = new MR_Response();
            response.Expand(cpf.DataItem.Data, 2, out temp);

            Service = response.ReplyService;
            Status = response.GeneralStatus;

            byte[] bbTemp = new byte[4];
            Buffer.BlockCopy(BitConverter.GetBytes(Status), 0, bbTemp, 0, 2);

            if (Status == 0xFF)
            {
                if (response.AdditionalStatus_Size > 0)
                    Buffer.BlockCopy(response.AdditionalStatus, 0, bbTemp, 2, 2);
            }

            ByteStatus = bbTemp;

            //Now check the response code...
            if (response.GeneralStatus != 0 && response.GeneralStatus != 0x06)
                return;

            if (response.ResponseData != null)
            {
                //Now we suck out the data type...
                DataType = BitConverter.ToUInt16(response.ResponseData, 0);
                byte[] tempB = new byte[response.ResponseData.Length - 2];
                Buffer.BlockCopy(response.ResponseData, 2, tempB, 0, tempB.Length);
                Data = tempB;
            }
            else
            {
                DataType = 0x0000;
            }
        }
        public WriteDataServiceReply(EncapsReply reply)
        {
            EncapsRRData rrData = new EncapsRRData();

            CommonPacket cpf = new CommonPacket();
            int temp = 0;
            rrData.Expand(reply.EncapsData, 0, out temp);
            cpf = rrData.CPF;

            MR_Response response = new MR_Response();
            response.Expand(cpf.DataItem.Data, 2, out temp);

            if (response.GeneralStatus != 0)
                return;

            Service = response.ReplyService;
            Status = response.GeneralStatus;
        }
        public WriteDataServiceReply(EncapsReply reply)
        {
            EncapsRRData rrData = new EncapsRRData();

            CommonPacket cpf  = new CommonPacket();
            int          temp = 0;

            rrData.Expand(reply.EncapsData, 0, out temp);
            cpf = rrData.CPF;

            MessageRouterResponse response = new MessageRouterResponse();

            response.Expand(cpf.DataItem.Data, 2, out temp);

            if (response.GeneralStatus != 0)
            {
                return;
            }

            Service = response.ReplyService;
            Status  = response.GeneralStatus;
        }
Example #7
0
        static public void Update()
        {
            NetworkSocket.ReceiveData();

            if (Environment.TickCount >= tcpTick + 1000)
            {
                if (!Common.Configuration.Disconnected)
                {
                    NetworkSocket.DiscoverServer(NetworkSocketEnum.LoginServer);
                    NetworkSocket.DiscoverServer(NetworkSocketEnum.WorldServer);
                    NetworkSocket.DiscoverServer(NetworkSocketEnum.GameServer);
                }

                tcpTick = Environment.TickCount;
            }

            //ping
            if (GameState == 6)
            {
                if (Environment.TickCount >= pingTick + 1000)
                {
                    CommonPacket.RequestPing();
                    pingTick = Environment.TickCount;
                }
            }

            if (Environment.TickCount >= tickFPS + 1000)
            {
                FPS  = pFPS;
                pFPS = 0;

                tickFPS = Environment.TickCount;
            }
            else
            {
                pFPS++;
            }
        }
        public MultiServiceReply(EncapsReply reply)
        {
            EncapsRRData rrData = new EncapsRRData();
            CommonPacket cpf = new CommonPacket();

            int temp = 0;
            rrData.Expand(reply.EncapsData, 0, out temp);
            cpf = rrData.CPF;

            MR_Response response = new MR_Response();
            response.Expand(cpf.DataItem.Data, 2, out temp);

            if (response.GeneralStatus == 0x1E)
                IsPartial = true;

            ReplyService = response.ReplyService;
            GenSTS = response.GeneralStatus;

            ServiceReplies = new List<ServiceReply>();

            if (response.ResponseData != null)
                Expand(response.ResponseData);
        }
        private static TemplateInfo ReadStructAttributes(ushort structureId, LogixProcessor processor)
        {
            //First we have to get the template info...
            GetStructAttribsRequest attribsReq = new GetStructAttribsRequest(structureId);
            CommonPacketItem addressItem = CommonPacketItem.GetNullAddressItem();

            UnconnectedSend ucmm = new UnconnectedSend();
            ucmm.Priority_TimeTick = 0x07;
            ucmm.Timeout_Ticks = 0x9B;
            ucmm.RoutePath = processor.Path;
            ucmm.MessageRequest = new MR_Request();
            ucmm.MessageRequest.Request_Path = new byte[] { 0x20, 0x6C, 0x25, 0x00, (byte)((structureId & 0x00FF)), (byte)((structureId & 0xFF00) >> 8) };
            ucmm.MessageRequest.Service = 0x03;
            ucmm.MessageRequest.Request_Data = new byte[] { 0x04, 0x00, 0x04, 0x00, 0x03, 0x00, 0x02, 0x00, 0x01, 0x00 };
            ucmm.RequestPath = CommonPaths.ConnectionManager;

            CommonPacketItem dataItem = CommonPacketItem.GetUnconnectedDataItem(ucmm.Pack());

            EncapsReply reply = processor.SessionInfo.SendRRData(addressItem, dataItem);

            if (reply.Status != 0x00)
                return null;

            //We have to get the data out...
            EncapsRRData rrData = new EncapsRRData();
            CommonPacket cpf = new CommonPacket();
            int temp = 0;
            rrData.Expand(reply.EncapsData, 0, out temp);
            cpf = rrData.CPF;

            byte[] replyData = new byte[28];
            Buffer.BlockCopy(cpf.DataItem.Data, 4, replyData, 0, 28);

            GetStructAttribsReply structAttribs = new GetStructAttribsReply(replyData);

            //Great... now we can request the structure template and be able to read it!
            ucmm.MessageRequest.Service = 0x4C;
            
            //We can only read about 480 bytes at a time, so we may have to break it up...
            uint bytesRemaining = (structAttribs.TemplateSize - 5) * 4;
            uint offset = 0;
            List<byte> structInfoBytes = new List<byte>();

            while (bytesRemaining > 0)
            {
                ushort bytesToRead;
                if (bytesRemaining < 480)
                {
                    bytesToRead = (ushort)bytesRemaining;
                    bytesRemaining = 0;
                }
                else
                {
                    bytesToRead = 480;
                    bytesRemaining -= 480;
                }

                byte[] tempB = new byte[6];
                Buffer.BlockCopy(BitConverter.GetBytes(offset), 0, tempB, 0, 4);
                Buffer.BlockCopy(BitConverter.GetBytes(bytesToRead), 0, tempB, 4, 2);

                ucmm.MessageRequest.Request_Data = tempB;

                dataItem = CommonPacketItem.GetUnconnectedDataItem(ucmm.Pack());

                reply = processor.SessionInfo.SendRRData(addressItem, dataItem);

                if (reply.Status != 0x00)
                    continue;

                rrData.Expand(reply.EncapsData, 0, out temp);
                cpf = rrData.CPF;

                //get the data out...
                tempB = new byte[cpf.DataItem.Data.Length - 4];
                Buffer.BlockCopy(cpf.DataItem.Data, 4, tempB, 0, cpf.DataItem.Data.Length - 4);
                structInfoBytes.AddRange(tempB);
                offset += bytesToRead;
            }

            //Now we have all the data!!!!

            return new TemplateInfo(structInfoBytes.ToArray(), structAttribs);
        }