Exemplo n.º 1
0
        public void handleDemoPacket(ESPPacket _packet)
        {
            switch (_packet.PacketIdentifier)
            {
            case PacketId.respVersion:
                m_versionPackets.Add(_packet.Origin, (ResponseVersion)_packet);
                break;

            case PacketId.respSerialNumber:
                m_V1SerialPackets.Add(_packet.Origin, (ResponseSerialNumber)_packet);
                break;

            case PacketId.respSavvyStatus:
                m_SavvyConfiguration = (ResponseSavvyStatus)_packet;
                break;

            case PacketId.respUserBytes:
                m_V1Configuration = (ResponseUserBytes)_packet;
                if ((m_V1ConfigObject != null) && (m_V1ConfigFunction != null))
                {
                    Utilities.Utilities.doCallback(m_V1ConfigObject, m_V1ConfigFunction, UserSettings.GetType(), (UserSettings)m_V1Configuration.getResponseData());
                }
                break;

            case PacketId.respSweepSections:
                m_CustomSweepSections.Add((ResponseSweepSections)_packet);
                break;

            case PacketId.respSweepDefinition:
                m_ResponseSweepDefinitions.Add((ResponseSweepDefinitions)_packet);
                break;

            case PacketId.respMaxSweepIndex:
                m_MaximumCustomSweepIndex = (ResponseMaxSweepIndex)_packet;
                break;

            case PacketId.respBatteryVoltage:
                m_BatteryVoltage = (ResponseBatteryVoltage)_packet;
                break;

            case PacketId.respVehicleSpeed:
                m_VehicleSpeed = (ResponseVehicleSpeed)_packet;
                break;

            case PacketId.reqVersion:
                PacketQueue.pushInputPacketOntoQueue(m_versionPackets[_packet.Destination]);
                break;

            case PacketId.reqSerialNumber:
                PacketQueue.pushInputPacketOntoQueue(m_V1SerialPackets[_packet.Destination]);
                break;

            case PacketId.reqUserBytes:
                PacketQueue.pushInputPacketOntoQueue(m_V1Configuration);
                break;

            case PacketId.reqAllSweepDefinitions:
            case PacketId.reqSetSweepsToDefault:
                for (int i = 0; i < m_ResponseSweepDefinitions.Count; i++)
                {
                    PacketQueue.pushInputPacketOntoQueue(m_ResponseSweepDefinitions[i]);
                }
                break;

            case PacketId.reqDefaultSweepDefinitions:
            case PacketId.respDefaultSweepDefinition:
                // Ignore these packets in the demo mode file.
                break;

            case PacketId.reqMaxSweepIndex:
                PacketQueue.pushInputPacketOntoQueue(m_MaximumCustomSweepIndex);
                break;

            case PacketId.reqSweepSections:
                for (int i = 0; i < m_CustomSweepSections.Count; i++)
                {
                    PacketQueue.pushInputPacketOntoQueue(m_CustomSweepSections[i]);
                }
                break;

            case PacketId.reqBatteryVoltage:
                PacketQueue.pushInputPacketOntoQueue(m_BatteryVoltage);
                break;

            case PacketId.reqSavvyStatus:
                PacketQueue.pushInputPacketOntoQueue(m_SavvyConfiguration);
                break;

            case PacketId.reqVehicleSpeed:
                PacketQueue.pushInputPacketOntoQueue(m_VehicleSpeed);
                break;



            case PacketId.reqTurnOffMainDisplay:
            case PacketId.reqTurnOnMainDisplay:
            case PacketId.respDataReceived:
            case PacketId.reqStartAlertData:
            case PacketId.reqStopAlertData:
            case PacketId.reqChangeMode:
            case PacketId.reqMuteOn:
            case PacketId.reqMuteOff:
            case PacketId.reqFactoryDefault:
            case PacketId.reqWriteUserBytes:
            case PacketId.reqWriteSweepDefinition:
            case PacketId.reqOverrideThumbwheel:
            case PacketId.reqSetSavvyUnmuteEnable:
            case PacketId.respDataError:
            case PacketId.respUnsupportedPacket:
            case PacketId.respRequestNotProcessed:
            case PacketId.infV1Busy:
            case PacketId.respSweepWriteResult:
                break;

            case PacketId.respAlertData:
            case PacketId.infDisplayData:
                PacketQueue.pushInputPacketOntoQueue(_packet);
                break;

            case PacketId.unknownPacketType:
                // There is nothing to do with an unknown packet type in demo mode
                break;
            }
        }
Exemplo n.º 2
0
        public static ESPPacket getPacket(PacketId _id)
        {
            ESPPacket rc = null;

            if (_id != null)
            {
                switch (_id)
                {
                //basic data
                case PacketId.reqVersion:
                    rc = new RequestVersion(Devices.UNKNOWN, Devices.UNKNOWN);
                    break;

                case PacketId.respVersion:
                    rc = new ResponseVersion(Devices.UNKNOWN);
                    break;

                case PacketId.reqSerialNumber:
                    rc = new RequestSerialNumber(Devices.UNKNOWN, Devices.UNKNOWN);
                    break;

                case PacketId.respSerialNumber:
                    rc = new ResponseSerialNumber(Devices.UNKNOWN);
                    break;

                case PacketId.reqUserBytes:
                    rc = new RequestUserBytes(Devices.UNKNOWN);
                    break;

                case PacketId.respUserBytes:
                    rc = new ResponseUserBytes(Devices.UNKNOWN);
                    break;

                case PacketId.reqWriteUserBytes:
                    rc = new RequestWriteUserBytes(null, Devices.UNKNOWN);
                    break;

                case PacketId.reqFactoryDefault:
                    rc = new RequestFactoryDefault(Devices.UNKNOWN, Devices.UNKNOWN);
                    break;

                case PacketId.reqDefaultSweepDefinitions:
                    rc = new RequestDefaultSweepDefinitions(Devices.UNKNOWN);
                    break;

                case PacketId.respDefaultSweepDefinition:
                    rc = new ResponseDefaultSweepDefinitions(Devices.UNKNOWN);
                    break;

                //custom sweep data
                case PacketId.reqWriteSweepDefinition:
                    rc = new RequestWriteSweepDefinition(null, Devices.UNKNOWN);
                    break;

                case PacketId.reqAllSweepDefinitions:
                    rc = new RequestAllSweepDefinitions(Devices.UNKNOWN);
                    break;

                case PacketId.respSweepDefinition:
                    rc = new ResponseSweepDefinitions(Devices.UNKNOWN);
                    break;

                case PacketId.reqSetSweepsToDefault:
                    rc = new RequestSetSweepsToDefault(Devices.UNKNOWN);
                    break;

                case PacketId.reqMaxSweepIndex:
                    rc = new RequestMaxSweepIndex(Devices.UNKNOWN);
                    break;

                case PacketId.respMaxSweepIndex:
                    rc = new ResponseMaxSweepIndex(Devices.UNKNOWN);
                    break;

                case PacketId.respSweepWriteResult:
                    rc = new ResponseSweepWriteResult(Devices.UNKNOWN);
                    break;

                case PacketId.reqSweepSections:
                    rc = new RequestSweepSections(Devices.UNKNOWN);
                    break;

                case PacketId.respSweepSections:
                    rc = new ResponseSweepSections(Devices.UNKNOWN);
                    break;

                //informational packets
                case PacketId.infDisplayData:
                    rc = new InfDisplayData(Devices.UNKNOWN);
                    break;

                case PacketId.reqTurnOffMainDisplay:
                    rc = new RequestTurnOffMainDisplay(Devices.UNKNOWN);
                    break;

                case PacketId.reqTurnOnMainDisplay:
                    rc = new RequestTurnOnMainDisplay(Devices.UNKNOWN);
                    break;

                case PacketId.reqMuteOn:
                    rc = new RequestMuteOn(Devices.UNKNOWN);
                    break;

                case PacketId.reqMuteOff:
                    rc = new RequestMuteOff(Devices.UNKNOWN);
                    break;

                case PacketId.reqChangeMode:
                    rc = new RequestChangeMode((byte)0, Devices.UNKNOWN);
                    break;

                case PacketId.reqStartAlertData:
                    rc = new RequestStartAlertData(Devices.UNKNOWN);
                    break;

                case PacketId.reqStopAlertData:
                    rc = new RequestStopAlertData(Devices.UNKNOWN);
                    break;

                case PacketId.respAlertData:
                    rc = new ResponseAlertData(Devices.UNKNOWN);
                    break;

                case PacketId.respDataReceived:
                    rc = new ResponseDataReceived(Devices.UNKNOWN);
                    break;

                case PacketId.reqBatteryVoltage:
                    rc = new RequestBatteryVoltage(Devices.UNKNOWN);
                    break;

                case PacketId.respBatteryVoltage:
                    rc = new ResponseBatteryVoltage(Devices.UNKNOWN);
                    break;

                //unspported and error
                case PacketId.respUnsupportedPacket:
                    rc = new ResponseUnsupported(Devices.UNKNOWN);
                    break;

                case PacketId.respRequestNotProcessed:
                    rc = new ResponseRequestNotProcessed(Devices.UNKNOWN);
                    break;

                case PacketId.infV1Busy:
                    rc = new InfV1Busy(Devices.UNKNOWN);
                    break;

                case PacketId.respDataError:
                    rc = new ResponseDataError(Devices.UNKNOWN);
                    break;

                //Savvy
                case PacketId.reqSavvyStatus:
                    rc = new RequestSavvyStatus(Devices.UNKNOWN, Devices.UNKNOWN);
                    break;

                case PacketId.respSavvyStatus:
                    rc = new ResponseSavvyStatus(Devices.UNKNOWN);
                    break;

                case PacketId.reqVehicleSpeed:
                    rc = new RequestVehicleSpeed(Devices.UNKNOWN, Devices.UNKNOWN);
                    break;

                case PacketId.respVehicleSpeed:
                    rc = new ResponseVehicleSpeed(Devices.UNKNOWN);
                    break;

                case PacketId.reqOverrideThumbwheel:
                    rc = new RequestOverrideThumbwheel(Devices.UNKNOWN, (byte)0, Devices.UNKNOWN);
                    break;

                case PacketId.reqSetSavvyUnmuteEnable:
                    rc = new RequestSetSavvyUnmute(Devices.UNKNOWN, false, Devices.UNKNOWN);
                    break;

                default:
                    rc = new UnknownPacket(Devices.UNKNOWN);
                    break;
                }
            }
            return(rc);
        }