Пример #1
0
        public static MemoryStream Serialize(Session mSession, IRadioTrio myRadio)
        {
            mSession.AuthMessageCounter++;
            MemoryStream packet = new MemoryStream();

            packet.WriteByte(0xc0);
            packet.WriteByte(0x00);
            packet.Write(myRadio.SerialNumberParse());
            packet.WriteByte(0x00);
            packet.WriteByte(0x00);
            packet.WriteByte(0x01);
            packet.WriteByte(0x47);
            packet.WriteByte(0x00);
            packet.WriteByte(0x62);
            packet.WriteByte(0x00);
            packet.WriteByte(0xc6);
            packet.WriteByte(0x00);
            packet.WriteByte(0x03);
            packet.WriteByte(0x00);
            packet.WriteByte(0x06);
            packet.WriteByte(0x00);
            packet.WriteByte(0x09);
            packet.WriteByte(0x00);
            packet.WriteByte(0x0f);
            packet.WriteByte(0x00);
            packet.WriteByte(0x0c);
            packet.WriteByte(0x00);
            packet.WriteByte(0x12);
            packet.WriteByte(Program.CheckSum8Xor(packet.ToArray().Skip(1).ToArray(), packet.ToArray().Skip(1).ToArray().Length));
            packet.WriteByte(0xc0);
            return(packet);
        }
Пример #2
0
        public IRadioTrio GetRadioFromSN(int sn)
        {
            IRadioTrio wantedRadio = LoadedRadios.Find(x => x.SerialNumber == sn);

            if (!wantedRadio.Equals(null))
            {
                return(wantedRadio);
            }
            return(null);
        }
Пример #3
0
        public IRadioTrio GetNextRadio()
        {
            IRadioTrio myRadio = Radios[cycleCounter];

            if (cycleCounter == Radios.Count - 1)
            {
                cycleCounter = 0;
            }
            else
            {
                cycleCounter++;
            }
            return(myRadio);
        }
Пример #4
0
        public IRadioTrio GetRadioForId(int id)
        {
            IRadioTrio myRadio = null;

            if (!LoadedRadios.Exists(x => x.Id == id))
            {
                //TODO: Tentar carregar o rádio
            }
            else
            {
                myRadio = LoadedRadios.Find(x => x.Id == id);
            }

            return(myRadio);
        }
Пример #5
0
        public IRadioTrio LoadRadio(int sn)
        {
            DataRow    data  = null;
            IRadioTrio radio = null;

            if (!LoadedRadios.Exists(x => x.SerialNumber == sn))
            {
                using (IQueryAdapter dbClient = Core.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("SELECT * FROM radios WHERE serial_number = @sn LIMIT 1;");
                    dbClient.AddParameter("sn", sn);
                    data = dbClient.getRow();

                    radio = LoadRadio(data);
                }
            }
            else
            {
                radio = LoadedRadios.Find(x => x.SerialNumber == sn);
            }

            return(radio);
        }
Пример #6
0
        public IRadioTrio LoadRadio(DataRow data)
        {
            IRadioTrio    radio = null;
            RadioType     radioType;
            OperationMode opMode;

            if (data != null)
            {
                int sn = Convert.ToInt32(data["serial_number"]);

                if (!LoadedRadios.Exists(x => x.SerialNumber == sn))
                {
                    if (data != null)
                    {
                        string type = Convert.ToString(data["radiotype"]);

                        if (type == "qr")
                        {
                            radioType = RadioType.QR;
                        }
                        else if (type == "qb")
                        {
                            radioType = RadioType.QB;
                        }
                        else if (type == "e")
                        {
                            radioType = RadioType.E;
                        }
                        else
                        {
                            radioType = RadioType.MR;
                        }

                        if (Convert.ToChar(data["opmod"]) == 'm')
                        {
                            opMode = OperationMode.Mode_M;
                        }

                        else
                        {
                            opMode = OperationMode.Mode_Q;
                        }

                        radio = new Radio(
                            Convert.ToInt32(data["id"]),
                            Convert.ToInt32(data["serial_number"]),
                            Convert.ToString(data["desc"]),
                            radioType,
                            opMode,
                            Convert.ToInt32(data["master_id"]),
                            Convert.ToInt32(data["channel_id"]));

                        LoadedRadios.Add(radio);
                    }
                }

                else
                {
                    radio = LoadedRadios.Find(x => x.SerialNumber == sn);
                }
            }

            return(radio);
        }