Exemplo n.º 1
0
        internal static bool connect()
        {
            PortCommunication.senderMsg(BR3SendCode.connSendCode, BR3SendCode.connReciveCode, 1);
            MainForm.barEditItem3.Value = 1;

            PortCommunication.senderMsg(BR3SendCode.connSendSure, BR3SendCode.connReciveSure, 8);
            MainForm.barEditItem3.Value = 2;
            PortCommunication.senderMsg(BR3SendCode.connReSureCode, BR3SendCode.connReciveCode, 1);
            MainForm.barEditItem3.Value = 3;
            //lblConnect.Text = "握手完成";
            //progressBar1.Value = 4;
            //MsgBox.Show("握手成功");
            return(true);
        }
Exemplo n.º 2
0
        internal static bool BR3Write(Class.BR3Class br3)
        {
            string str;

            PortCommunication.senderMsg(BR3SendCode.writeSendCode + " " + Common.Common.decToHex(BR3SendCode.writeStartAdress + 0 * 8, 8) + " " + Common.Common.decToHex(BR3SendCode.writeAdressLenth) + " " + BR3SendCode.writeNull, BR3SendCode.connReciveCode, 1);
            PortCommunication.senderMsg(BR3SendCode.writeSendCode + " " + Common.Common.decToHex(BR3SendCode.writeStartAdress + 1 * 8, 8) + " " + Common.Common.decToHex(BR3SendCode.writeAdressLenth) + " " + BR3SendCode.writeNull, BR3SendCode.connReciveCode, 1);
            for (int i = 0; i < 99; i++)
            {
                if (i < br3.DtRowCount)
                {
                    if (br3.Channel.Rows[i][Class.ChannelBR3.TXFrequency] != null && br3.Channel.Rows[i][ChannelBR3.TXFrequency].ToString() != "")
                    {
                        PortCommunication.senderMsg(BR3SendCode.writeSendCode + " " + Common.Common.decToHex(BR3SendCode.writeStartAdress + (i + 1) * 16, 8) + " " + Common.Common.decToHex(BR3SendCode.writeAdressLenth)
                                                    + " " + decFrequencyToHex(Convert.ToDouble(br3.Channel.Rows[i][ChannelBR3.TXFrequency])) + " " + decFrequencyToHex(Convert.ToDouble(br3.Channel.Rows[i][ChannelBR3.RXFrequency]))
                                                    , BR3SendCode.connReciveCode, 1);
                        str = br3.Channel.Rows[i][ChannelBR3.Clone].ToString() == "Yes" ? "ff" : "fe";
                        PortCommunication.senderMsg(BR3SendCode.writeSendCode + " " + Common.Common.decToHex(BR3SendCode.writeStartAdress + (i + 1) * 16 + 8, 8) + " " + Common.Common.decToHex(BR3SendCode.writeAdressLenth)
                                                    + " " + CTCSToHex(br3.Channel.Rows[i][ChannelBR3.CTCSDec].ToString()) + " " + CTCSToHex(br3.Channel.Rows[i][ChannelBR3.CTCSEnc].ToString())
                                                    + " " + ChannelParam(br3.Channel.Rows[i]) + " " + str + " ff ff"
                                                    , BR3SendCode.connReciveCode, 1);
                    }
                    else
                    {
                        PortCommunication.senderMsg(BR3SendCode.writeSendCode + " " + Common.Common.decToHex(BR3SendCode.writeStartAdress + (i + 1) * 16, 8) + " " + Common.Common.decToHex(BR3SendCode.writeAdressLenth)
                                                    + " ff ff ff ff ff ff ff ff"
                                                    , BR3SendCode.connReciveCode, 1);

                        PortCommunication.senderMsg(BR3SendCode.writeSendCode + " " + Common.Common.decToHex(BR3SendCode.writeStartAdress + (i + 1) * 16 + 8, 8) + " " + Common.Common.decToHex(BR3SendCode.writeAdressLenth)
                                                    + " ff ff ff ff ff ff ff ff"
                                                    , BR3SendCode.connReciveCode, 1);
                    }
                }
                else
                {
                    PortCommunication.senderMsg(BR3SendCode.writeSendCode + " " + Common.Common.decToHex(BR3SendCode.writeStartAdress + (i + 1) * 16, 8) + " " + Common.Common.decToHex(BR3SendCode.writeAdressLenth)
                                                + " ff ff ff ff ff ff ff ff"
                                                , BR3SendCode.connReciveCode, 1);

                    PortCommunication.senderMsg(BR3SendCode.writeSendCode + " " + Common.Common.decToHex(BR3SendCode.writeStartAdress + (i + 1) * 16 + 8, 8) + " " + Common.Common.decToHex(BR3SendCode.writeAdressLenth)
                                                + " ff ff ff ff ff ff ff ff"
                                                , BR3SendCode.connReciveCode, 1);
                }

                MainForm.barEditItem3.Value = Convert.ToInt32(i / 1.2 + 4);//82.5+4
            }
            string[] dis = CodeToHex(br3.Display);
            //57 07 90 08
            PortCommunication.senderMsg(BR3SendCode.writeSendCode + " " + Common.Common.decToHex(BR3SendCode.dispalyAdress1, 8) + " " + Common.Common.decToHex(BR3SendCode.writeAdressLenth)
                                        + " " + dis[0] + " " + dis[1] + " " + dis[2] + " " + dis[3] + " " + dis[4] + " " + dis[5] + " " + dis[6] + " " + dis[7]
                                        , BR3SendCode.connReciveCode, 1);
            MainForm.barEditItem3.Value = 88;
            //57 07 98 08

            //PortCommunication.senderMsg(BR3SendCode.writeSendCode + " " + Common.Common.decToHex(BR3SendCode.dispalyAdress2, 8) + " " + Common.Common.decToHex(BR3SendCode.writeAdressLenth)
            //    + " " + dis[8] + " " + dis[9] + " ff ff ff ff ff "/*+Common.Common.decToHex(br3.RogerTone==true? 1:0 ) +" "*/+ Common.Common.decToHex((br3.StartupCh))
            //    , BR3SendCode.connReciveCode, 1);
            PortCommunication.senderMsg(BR3SendCode.writeSendCode + " " + Common.Common.decToHex(BR3SendCode.dispalyAdress2, 8) + " " + Common.Common.decToHex(BR3SendCode.writeAdressLenth)
                                        + " " + dis[8] + " " + dis[9] + " ff ff ff " + Common.Common.decToHex(br3.Brightness) + " " + Common.Common.decToHex(br3.RogerTone == true? 1:0) + " " + Common.Common.decToHex((br3.StartupCh))
                                        , BR3SendCode.connReciveCode, 1);
            MainForm.barEditItem3.Value = 90;
            //57 07 a0 08
            PortCommunication.senderMsg(BR3SendCode.writeSendCode + " " + Common.Common.decToHex(BR3SendCode.TxStartAdress, 8) + " " + Common.Common.decToHex(BR3SendCode.writeAdressLenth)
                                        + " " + TxCodeToHex(br3.TxStart)
                                        , BR3SendCode.connReciveCode, 1);
            MainForm.barEditItem3.Value = 92;
            //57 07 c0 08
            PortCommunication.senderMsg(BR3SendCode.writeSendCode + " " + Common.Common.decToHex(BR3SendCode.pragramAdress, 8) + " " + Common.Common.decToHex(BR3SendCode.writeAdressLenth)
                                        + " " + Common.Common.decToHex((br3.Ppt + br3.ScanMode * 4) * 16 + (br3.BeepSound?1:0) + (br3.PowerSaving?1:0) * 2 + br3.VoiceAnnouncements * 4)
                                        + " " + Common.Common.decToHex(br3.SquelchLevel) + " " + pressToHex(br3.ShotPress1) + " " + Common.Common.decToHex(br3.TxLimit) + " " + Common.Common.decToHex(br3.VoiceLevel) + " " + pressToHex(br3.ShotPress2) + " ff " + Common.Common.decToHex(br3.VoiceDelay)
                                        , BR3SendCode.connReciveCode, 1);
            MainForm.barEditItem3.Value = 94;
            //57 07 c8 08
            if (br3.Fto == 0)
            {
                //PortCommunication.senderMsg(BR3SendCode.writeSendCode + " " + Common.Common.decToHex(BR3SendCode.pragramAdress1, 8) + " " + Common.Common.decToHex(BR3SendCode.writeAdressLenth)
                //+ " " + pressToHex(br3.LongPress1) + " 0a " + Common.Common.decToHex(br3.DisplayMode) + " ff ff ff ff ff"
                //, BR3SendCode.connReciveCode, 1);
                PortCommunication.senderMsg(BR3SendCode.writeSendCode + " " + Common.Common.decToHex(BR3SendCode.pragramAdress1, 8) + " " + Common.Common.decToHex(BR3SendCode.writeAdressLenth)
                                            + " " + pressToHex(br3.LongPress1) + " " + pressToHex(br3.LongPress2) + " " + Common.Common.decToHex(br3.DisplayMode) + " ff ff ff ff ff"
                                            , BR3SendCode.connReciveCode, 1);
            }
            else if (br3.Fto == 1)
            {
                PortCommunication.senderMsg(BR3SendCode.writeSendCode + " " + Common.Common.decToHex(BR3SendCode.pragramAdress1, 8) + " " + Common.Common.decToHex(BR3SendCode.writeAdressLenth)
                                            + " " + pressToHex(br3.LongPress1) + " " + pressToHex(br3.LongPress2) + " " + Common.Common.decToHex(br3.DisplayMode) + " ff ff ff ff ff"
                                            , BR3SendCode.connReciveCode, 1);
            }
            MainForm.barEditItem3.Value = 96;
            //57 07 d8 08

            if (br3.Fto == 0)
            {
                PortCommunication.senderMsg(BR3SendCode.writeSendCode + " " + Common.Common.decToHex(BR3SendCode.Fto, 8) + " " + Common.Common.decToHex(BR3SendCode.writeAdressLenth)
                                            + " 60 44 80 44 ff ff ff ff"
                                            , BR3SendCode.connReciveCode, 1);
            }
            else if (br3.Fto == 1)
            {
                PortCommunication.senderMsg(BR3SendCode.writeSendCode + " " + Common.Common.decToHex(BR3SendCode.Fto, 8) + " " + Common.Common.decToHex(BR3SendCode.writeAdressLenth)
                                            + " 00 45 00 52 ff ff ff ff"
                                            , BR3SendCode.connReciveCode, 1);
            }
            MainForm.barEditItem3.Value = 98;


            //57 07 e0 08
            PortCommunication.senderMsg(BR3SendCode.writeSendCode + " " + Common.Common.decToHex(BR3SendCode.TxStopAdress, 8) + " " + Common.Common.decToHex(BR3SendCode.writeAdressLenth)
                                        + " " + TxCodeToHex(br3.TxStop)
                                        , BR3SendCode.connReciveCode, 1);
            MainForm.barEditItem3.Value = 100;
            PortCommunication.sendMassge("62");
            return(true);
        }