コード例 #1
0
        private void SubSendData3()
        {
            this.serialPort1.DiscardInBuffer();
            this.serialPort1.Write("AT^MONSC\r");

            LogisTrac.WriteLog("开机先查询4g模块信息");

            Thread.Sleep(100);



            this.serialPort1.DiscardInBuffer();

            this.serialPort1.Write("AT^HCSQ?\r");

            Thread.Sleep(100);

            this.serialPort1.DiscardInBuffer();

            this.serialPort1.Write("AT^SYSINFOEX\r");

            Thread.Sleep(100);


            this.serialPort1.DiscardInBuffer();

            this.serialPort1.Write("AT^ICCID?\r");

            Thread.Sleep(100);
        }
コード例 #2
0
        private void netcheck_fun()
        {
            try
            {
                //检测多次网络是否畅通
                if (Init_Check_Neting)
                {
                    return;
                }
                int  count = 5;
                bool flag  = false;
                Init_Check_Neting = true;
                while (count > 0)
                {
                    count--;
                    flag = Internet.IsConnectInternet();
                    if (!flag)
                    {
                        Thread.Sleep(1000);
                    }
                    else
                    {
                        count = 0;
                    }
                }
                this.Init_Check_Net = flag;


                Init_Check_Neting = false;
            }
            catch (Exception ex)
            {
                LogisTrac.WriteLog(ex.Message);
            }
        }
コード例 #3
0
ファイル: Start.cs プロジェクト: 0000duck/kangjia
 /// <summary>
 /// 全局线程异常处理事件
 /// </summary>
 /// <param name="sender"> </param>
 /// <param name="e"> </param>
 public static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     LogisTrac.WriteLog("系统捕获异常---" + e.Exception);
     if (e.Exception.Message.IndexOf("内存") >= 0)
     {
         update_start();
     }
     //  Functions.ShowMessageBox("系统异常,请联系管理员! ", Const.EVENT_INFO);
 }
コード例 #4
0
ファイル: Start.cs プロジェクト: 0000duck/kangjia
 public static void CurrentDomain_UnhandledException(object sender, System.UnhandledExceptionEventArgs e)
 {
     LogisTrac.WriteLog("系统捕获异常,未知异常---" + e.ExceptionObject.ToString());
     if (e.ExceptionObject.ToString().IndexOf("内存") >= 0)
     {
         update_start();
     }
     // Functions.ShowMessageBox("系统异常,请联系管理员! ", Const.EVENT_INFO);
 }
コード例 #5
0
ファイル: Start.cs プロジェクト: 0000duck/kangjia
        /// <summary>
        /// 全局线程异常处理事件
        /// </summary>
        /// <param name="sender"> </param>
        /// <param name="e"> </param>
        public static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            // 显示全局异常提示
            //ServerCommon.ServerFunctions serverFunction = new ServerCommon.ServerFunctions();
            //serverFunction.WriteLog(e.Exception.Message);


            LogisTrac.WriteLog(e.Exception);
            //  Functions.ShowMessageBox("系统异常,请联系管理员! ", Const.EVENT_INFO);
        }
コード例 #6
0
        //判断4g版本
        private void Chenck_4g()
        {  //通过WMI获取COM端口
            string[] ss = MulGetHardwareInfo(HardwareEnum.Win32_PnPEntity, "Name");

            int j = -1;

            for (int i = 0; i < ss.Length; i++)
            {
                string[] sArray  = ss[i].Split('(');
                string   comname = sArray[0];

                if (sArray[0] == "HUAWEI Mobile Connect - PC UI Interface ")//华为
                {
                    string[] sArray1 = sArray[1].Split(')');
                    com_4g = sArray1[0];

                    iweb_type = 1;
                    j         = i;
                    break;
                }

                if (sArray[0] == "Quectel USB AT Port ")//移远
                {
                    string[] sArray1 = sArray[1].Split(')');
                    com_4g = sArray1[0];

                    iweb_type = 2;
                    j         = i;
                    break;
                }

                if (comname == "Prolific USB-to-Serial Comm Port ")//测试
                {
                    string[] sArray1 = sArray[1].Split(')');
                    com_4g = sArray1[0];

                    iweb_type = 3;
                    j         = i;
                    break;
                }
            }


            if (j != -1)
            {
                LogisTrac.WriteLog("4g模块名称:" + ss[j] + "  com: " + com_4g);
                // MessageBox.Show(ss[j]);
            }
            else
            {
                LogisTrac.WriteLog("判断4g模块版本错误,未找到匹配串口");
                // MessageBox.Show("no");
                return;
            }
        }
コード例 #7
0
 /// <summary>
 /// 定时检查网络
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void netcheckTimer_Tick(object sender, EventArgs e)
 {
     try
     {
         netcheck_fun();
     }
     catch (Exception ex)
     {
         LogisTrac.WriteLog(ex.Message);
     }
 }
コード例 #8
0
 /// <summary>
 /// 触发flash声音提示
 /// </summary>
 /// <param name="o"></param>
 private void flash_Play(object o)
 {
     try
     {
         string url = (string)o;
         axShockwaveFlash1.CallFunction(url);
     }
     catch (Exception ex)
     {
         LogisTrac.WriteLog(ex.Message);
     }
 }
コード例 #9
0
 //自检
 private bool Init_Com2()
 {
     try
     {
         devicemanager.Write(new Cmd_S_Check());
         return(false);
     }
     catch (Exception ex)
     {
         LogisTrac.WriteLog(ex.Message);
         return(false);
     }
 }
コード例 #10
0
ファイル: 借据.cs プロジェクト: lingfengstar/-
        private async void button3_Click(object sender, EventArgs e)
        {
            try
            {
                args = await Task.Run(() => ReadArgs.button_Click());

                tjkr.Text     = args.Name;
                tjkrsfzh.Text = args.IDC;
            }
            catch (Exception ex)
            {
                LogisTrac.WriteLog(typeof(借据), ex);
            }
        }
コード例 #11
0
 /// <summary>
 /// 播放按钮声音
 /// </summary>
 private void flash_playButton()
 {
     try
     {
         string flash = "<invoke name=\"button\" returntype=\"xml\"></invoke>";
         Thread tt    = new Thread(flash_Play);
         tt.Start(flash);
         tt.Join();
     }
     catch (Exception ex)
     {
         LogisTrac.WriteLog(ex.Message);
     }
 }
コード例 #12
0
 //初始化定时器
 private void Init_AllTimer()
 {
     try
     {
         //定时检查网络
         netcheckTimer           = new System.Timers.Timer(5000);
         netcheckTimer.Elapsed  += new System.Timers.ElapsedEventHandler((s, e) => netcheckTimer_Tick(s, e));
         netcheckTimer.AutoReset = true; //设置是执行一次(false)还是一直执行(true)
         netcheckTimer.Enabled   = true; //是否执行System.Timers.Timer.Elapsed事件
     }
     catch (Exception ex)
     {
         LogisTrac.WriteLog(ex.Message);
     }
 }
コード例 #13
0
ファイル: ReadTxt.cs プロジェクト: lingfengstar/-
        static public string[] ReadTXT(string a)
        {
            try
            {
                string[] TXT;
                //该方法返回一个字符串数组。每一行都是一个数组元素。

                TXT = File.ReadAllLines(a, Encoding.UTF8);

                return(TXT);
            }
            catch (Exception ex)
            {
                LogisTrac.WriteLog(typeof(ReadTxt), ex);
            }
            return(null);
        }
コード例 #14
0
ファイル: Start.cs プロジェクト: 0000duck/kangjia
 /// <summary>
 /// 关闭进程
 /// </summary>
 /// <param name="processName">进程名</param>
 private static void KillProcess(string processName)
 {
     try
     {
         Process[] myproc = Process.GetProcesses();
         foreach (Process item in myproc)
         {
             if (item.ProcessName == processName)
             {
                 LogisTrac.WriteLog("删除" + processName);
                 item.Kill();
                 item.Dispose();
                 break;
             }
         }
     }
     catch { }
 }
コード例 #15
0
        /// <summary>
        /// 间隔时间执行画面切换
        /// </summary>
        /// <param name="stepname"></param>
        /// <param name="time"></param>
        private void netcheck_delay()
        {
            try
            {
                if (Init_Check_Neting)
                {
                    return;
                }

                System.Timers.Timer t = new System.Timers.Timer(500); //实例化Timer类,设置时间间隔
                t.Elapsed  += new System.Timers.ElapsedEventHandler((s, e) => netcheck_delay_fun(s, e));
                t.AutoReset = false;                                  //设置是执行一次(false)还是一直执行(true)
                t.Enabled   = true;                                   //是否执行System.Timers.Timer.Elapsed事件
            }
            catch (Exception ex)
            {
                LogisTrac.WriteLog(ex.Message);
            }
        }
コード例 #16
0
ファイル: Start.cs プロジェクト: 0000duck/kangjia
        private static void update_start()
        {
            try
            {
                // 升级完成,启动主程序
                string StrExe = yoyoConst.KANGJIA_MAIN_PATH + "kangjiamain.exe";
                if (System.IO.File.Exists(StrExe))
                {
                    System.Diagnostics.Process.Start(StrExe);
                }

                //关闭升级程序
                System.Environment.Exit(0);
            }
            catch (Exception ex)
            {
                LogisTrac.WriteLog(ex.Message);
            }
        }
コード例 #17
0
        private bool cmdReset()
        {
            //升级过程中异常中断的时候处理
            string filename = FileHelper.getFilename(this.up_mcpVersion_url, ".bin");

            if (!string.IsNullOrEmpty(filename))
            {
                FileInfo file = new FileInfo(filename);
                yoyoConst.VERSION = file.Name.Substring(0, 17);
                testuploadByte    = FileHelper.GetFileData(filename);
                cmdnew.hardLength = FileHelper.FileSize(filename);
                return(true);
            }
            else
            {
                LogisTrac.WriteLog("kangjiamain--固件升级文件不是bin文件");
                return(false);
            }
        }
コード例 #18
0
        /// <summary>
        /// 切换flash
        /// </summary>
        /// <param name="step"></param>
        /// <param name="para"></param>
        private void flash_change2(yoyoConst.YoyoStep step, params string[] para)
        {
            try
            {
                if (yoyoConst.currtenStep != null && step == yoyoConst.currtenStep.step)
                {
                    //首页点击按钮无效
                    return;
                }

                flashmodel mode = new flashmodel();
                bool       falg = yoyoConst.dict.TryGetValue(step, out mode);
                yoyoConst.currtenStep = mode;
                string url = mode.url;
                if (para != null && para.Length > 0)
                {
                    url = String.Format(mode.url, para[0]);
                }
                if (falg)
                {
                    if (yoyoConst.currtenStep != null)
                    {
                        if (!string.IsNullOrEmpty(url))
                        {
                            try
                            {
                                axShockwaveFlash1.CallFunction(url);
                            }
                            catch
                            {
                                flash_change2(yoyoConst.YoyoStep.yoyo);
                                return;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogisTrac.WriteLog(ex.Message);
            }
        }
コード例 #19
0
 //打开串口
 private bool Init_Com1()
 {
     try
     {
         ////打开串口
         devicemanager.PortName = OperateIniFile.ReadVersionIniData("COM_PORT");
         bool comcheck = devicemanager.Start();
         if (comcheck)
         {
             //串口读取事件
             devicemanager.CmdMngr.CommandReceivedHandler = new CommandManager.CommandReceivedDelegate(this.CommandReceivedDelegate);
         }
         Init_Check_Device1ing = false;
         return(comcheck);
     }
     catch (Exception ex)
     {
         LogisTrac.WriteLog(ex.Message);
         return(false);
     }
 }
コード例 #20
0
 private void update_start()
 {
     try
     {
         this.devicemanager.Stop();
         this.devicemanager = null;
         // 升级完成,启动主程序
         string StrExe = yoyoConst.KANGJIA_PATH + "kangjia.exe";
         LogisTrac.WriteLog(StrExe);
         if (File.Exists(StrExe))
         {
             System.Diagnostics.Process.Start(StrExe);
         }
         this.Hide();
         //关闭升级程序
         System.Environment.Exit(0);
     }
     catch (Exception ex)
     {
         LogisTrac.WriteLog(ex.Message);
     }
 }
コード例 #21
0
        string zhname;                                          //支行名称
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                chname = textBox1.Text;
                zhname = textBox3.Text;
                string[] arr = { chname, zhname, iPort };

                if (Config.WriteConfig(path, arr))
                {
                    MessageBox.Show("修改配置成功!");
                }
                else
                {
                    MessageBox.Show("请重试!");
                }
            }
            catch (Exception ex)
            {
                LogisTrac.WriteLog(typeof(Main), ex);
            }
        }
コード例 #22
0
 /// <summary>
 /// 先把需要更新的文件下载到本地,并且解压
 /// </summary>
 /// <param name="url"></param>
 /// <returns></returns>
 private bool update_downloadAndUnZipFile(string url, string tagetpath)
 {
     try
     {
         String onlyFileName = Path.GetFileName(url);
         //下载
         bool falg = FtpUpLoadFiles.Download(url, tagetpath, onlyFileName);
         if (!falg)
         {
             yoyoConst.WriteLog("文件下载失败" + url);
         }
         //TODO解压
         string name = tagetpath + onlyFileName;
         falg = update_Unzip(name, tagetpath);
         if (falg)
         {
             bool del = true;
             while (del)
             {
                 try
                 {
                     File.Delete(name);//解压后删除
                     del = false;
                 }
                 catch
                 {
                     Thread.Sleep(200);
                 }
             }
         }
         return(falg);
     }
     catch (Exception ex)
     {
         LogisTrac.WriteLog(ex.Message);
         return(false);
     }
 }
コード例 #23
0
ファイル: Start.cs プロジェクト: 0000duck/kangjia
        private static void Main()
        {
            try
            {
                // 注册全局线程异常处理事件侦听
                Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
                Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

                Process instance = Start.RunningInstance();
                if (instance == null)
                {
                    yoyoConst.Initproject(true);
                    LogisTrac.WriteLog("程序启动");

                    string mainversion = OperateIniFile.ReadIniData_main("MAIN_VERSION");

                    string res = OperateIniFile.ReadVersionIniData("RES_VERSION");

                    LogisTrac.WriteLog("kangjia版本V" + mainversion);

                    LogisTrac.WriteLog("res版本V" + res);

                    LogisTrac.WriteLog("StartupPath" + Application.StartupPath);
                    LogisTrac.WriteLog("GetCurrentDirectory" + System.IO.Directory.GetCurrentDirectory());
                    //  Application.Run(new indexform());
                    Application.Run(new indexForm2());//indexForm2
                    KillProcess("kangjiamain");
                    return;
                }
                Start.HandleRunningInstance(instance);
            }
            catch (Exception ex)
            {
                Application.Run(new indexForm2());
                LogisTrac.WriteLog(ex.Message);
            }
        }
コード例 #24
0
        //初始化失败后定时器调用
        private void init_Tick(object sender, EventArgs e)
        {
            try
            {
                totalcount--;
                if (totalcount > 0)
                {
                    LogisTrac.WriteLog("main倒数第" + totalcount + "次,尝试启动");
                    Init_Main();
                }
                else
                {
                    Init_timer.Enabled = false;//停止自动检测
                    LogisTrac.WriteLog("main无法启动,停止启动线程");

                    update_start();
                }
            }
            catch (Exception ex)
            {
                LogisTrac.WriteLog(ex.Message);
            }
        }
コード例 #25
0
ファイル: Start.cs プロジェクト: 0000duck/kangjia
        private static void Main()
        {
            try
            {
                // 注册全局线程异常处理事件侦听
                Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
                Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException, true);
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

                KillProcess("kangjia");
                Process instance = Start.RunningInstance();
                if (instance == null)
                {
                    yoyoConst.Initproject(false);

                    LogisTrac.WriteLog("更新启动");
                    string mainversion = OperateIniFile.ReadIniData("MAIN_VERSION");
                    if (string.IsNullOrEmpty(mainversion))
                    {
                        LogisTrac.WriteLog("kangjiamain版本V1.1");
                    }
                    else
                    {
                        LogisTrac.WriteLog("kangjiamain版本V" + mainversion);
                    }
                    Application.Run(new upindexForm2());//indexForm2

                    return;
                }
                Start.HandleRunningInstance(instance);
            }
            catch (Exception ex) {
                Application.Run(new upindexForm2());
                LogisTrac.WriteLog(ex.Message);
            }
        }
コード例 #26
0
        public void SendData3()
        {
            if (this.serialPort1.IsOpen)
            {
                //发送数据
                SubSendData3();
                this.serialPort1.Close();
            }
            else
            {
                this.serialPort1.Open();

                if (this.serialPort1.IsOpen)
                { //发送数据
                    SubSendData3();
                    this.serialPort1.Close();
                }
                else
                {
                    LogisTrac.WriteLog("串口打开失败");
                }
            }
            this.serialPort1.Close();
        }
コード例 #27
0
ファイル: Start.cs プロジェクト: 0000duck/kangjia
 public static Process RunningInstance()
 {
     try
     {
         Process   current   = Process.GetCurrentProcess();
         Process[] processes = Process.GetProcessesByName(current.ProcessName);
         Process[] array     = processes;
         for (int i = 0; i < array.Length; i++)
         {
             Process process = array[i];
             if (process.Id != current.Id && Assembly.GetExecutingAssembly().Location.Replace("/", "\\") == current.MainModule.FileName)
             {
                 process.Kill();
                 break;
                 //return process;
             }
         }
     }
     catch (Exception ex)
     {
         LogisTrac.WriteLog(ex.Message);
     }
     return(null);
 }
コード例 #28
0
        /// <summary>
        /// 检测升级
        /// </summary>
        private bool update_Main()
        {
            try
            {
                LogisTrac.WriteLog("kangjiamain--开始检查升级状态");
                string basth = yoyoConst.KANGJIA_PATH;

                model = htt_Upload();

                bool doflag = false;
                if (model == null)
                {
                    LogisTrac.WriteLog("kangjiamain--无法连接服务判断");
                    return(true);
                }
                string resVersion = OperateIniFile.ReadVersionIniData("RES_VERSION");
                string appVersion = OperateIniFile.ReadVersionIniData("MAIN_VERSION");
                string mcpVersion = OperateIniFile.ReadVersionIniData("HARD_VERSION");
                if (model.data.resVersion != null && resVersion != null && model.data.resVersion.Trim() != resVersion.Trim())
                {
                    //下载解压
                    doflag = update_downloadAndUnZipFile(model.data.resUrl, this.up_resVersion_url);
                    if (!doflag)
                    {
                        LogisTrac.WriteLog("kangjiamain--资源文件下载解压失败,版本" + model.data.resVersion);
                        return(doflag);
                    }
                    LogisTrac.WriteLog("kangjiamain--资源文件下载解压成功" + resVersion + "end");//model.data.
                    //复制到指定目录,删除原始文件
                    doflag = update_replaceFile(this.up_resVersion_url, basth + "\\res");
                    if (!doflag)
                    {
                        LogisTrac.WriteLog("kangjiamain--资源文件替换失败,版本" + model.data.resVersion + "end");
                        return(doflag);
                    }
                    FileHelper.DeleteFolder(this.up_resVersion_url);
                    OperateIniFile.WriteVersionIniData("RES_VERSION", model.data.resVersion);
                    LogisTrac.WriteLog("kangjiamain--资源文件更新成功,版本" + model.data.resVersion + "end");
                }
                if (model.data.appVersion != null && appVersion != null && model.data.appVersion.Trim() != appVersion.Trim())
                {
                    //下载解压
                    doflag = update_downloadAndUnZipFile(model.data.appUrl, this.up_appVersion_url);
                    if (!doflag)
                    {
                        LogisTrac.WriteLog("kangjiamain--主程序文件下载解压失败,版本" + model.data.appVersion + "end");
                        return(doflag);
                    }
                    //复制到指定目录,删除原始文件
                    doflag = update_replaceFile(this.up_appVersion_url, basth);
                    if (!doflag)
                    {
                        LogisTrac.WriteLog("kangjiamain--主程序文件替换失败,版本" + model.data.appVersion + "end");
                        return(doflag);
                    }
                    FileHelper.DeleteFolder(this.up_appVersion_url);
                    OperateIniFile.WriteVersionIniData("MAIN_VERSION", model.data.appVersion);
                    LogisTrac.WriteLog("kangjiamain--主程序文件更新成功,版本" + model.data.appVersion + "end");
                }
                if (model.data.mcpVersion.Length <= 9 || yoyoConst.VERSION.Length <= 9)
                {
                    return(false);
                }
                //if (model.data.mcpVersion != yoyoConst.VERSION.Substring(9))//TODO

                string[] list1 = new string[2];//yoyoConst.VERSION.Split('H');
                list1[0] = yoyoConst.VERSION.Substring(0, 9);
                list1[1] = yoyoConst.VERSION.Substring(9);

                string[] list2 = new string[2];//model.data.mcpVersion.Split('H');
                list2[0] = model.data.mcpVersion.Trim().Substring(0, 9);
                list2[1] = model.data.mcpVersion.Trim().Substring(9);

                if (list1.Length == 2 && list1.Length == list2.Length && list1[0] != list2[0] && list1[1] == list2[1])
                {
                    //下载解压
                    doflag = update_downloadAndUnZipFile(model.data.mcpUrl, this.up_mcpVersion_url);
                    if (!doflag)
                    {
                        LogisTrac.WriteLog("kangjiamain--固件文件下载解压失败,版本" + model.data.mcpVersion + "end");
                        return(doflag);
                    }
                    string filename = FileHelper.getFilename(this.up_mcpVersion_url, ".bin");

                    if (!string.IsNullOrEmpty(filename))
                    {
                        Init_Device_doing = true;
                        testuploadByte    = FileHelper.GetFileData(filename);
                        cmdnew.hardLength = FileHelper.FileSize(filename);
                        devicemanager.Write(new Cmd_S_Ready());
                    }
                    else
                    {
                        LogisTrac.WriteLog("kangjiamain--固件升级文件不是bin文件");
                        return(true);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                LogisTrac.WriteLog(ex.Message);
                return(false);
            }
        }
コード例 #29
0
ファイル: Start.cs プロジェクト: 0000duck/kangjia
 public static void CurrentDomain_UnhandledException(object sender, System.UnhandledExceptionEventArgs e)
 {
     LogisTrac.WriteLog(e.ExceptionObject.ToString());
     // Functions.ShowMessageBox("系统异常,请联系管理员! ", Const.EVENT_INFO);
 }
コード例 #30
0
        //串口设备不同状态下与程序间通信
        private void CommandReceivedDelegate(Command cmd)
        {
            try
            {
                //if (cmd is Cmd_X_Check)
                //{
                //    #region 上位机请求下位机自检的协议
                //    //2.10	上位机请求下位机自检的协议
                //    //0x00:生物电绿光自检均不正常
                //    //0x01:生物电自检正常
                //    //0x02:绿光自检正常
                //    //0x03:生物电、绿光自检均正常

                //    if (cmd.GetData()[4] == 0x03)
                //    {
                //        this.Init_Check_Device1 = true;
                //    }
                //    this.Init_Check_Device2ing = false;
                //    #endregion
                //}
                //else
                if (cmd is Cmd_X_SN)
                {
                    #region 3.2	上位机查询下位机固件版本和SN的协议
                    byte[] list = cmd.GetData();
                    string x    = "";
                    for (int i = 4; i < list.Length - 2; i++)
                    {
                        x += "," + list[i];
                    }
                    // Console.WriteLine("report--" + x);
                    //this.textBox2.Text = x;
                    byte[] list2 = DeviceHelper.Com_getSubData(list);

                    ASCIIEncoding encoder = new ASCIIEncoding();
                    string        tmp     = encoder.GetString(list2, 0, list2.Length);
                    //  this.textBox2.Text = tmp;
                    yoyoConst.VERSION = tmp.Substring(0, 17);               //版本号
                    yoyoConst.EQU_SN  = tmp.Substring(17, tmp.Length - 17); //设备信息(SN码)
                    if (!DeviceHelper.Com_checkSN())
                    {
                        devicemanager.Write(new Cmd_S_SN());
                        this.Init_Check_SN    = false;
                        this.Init_Check_SNing = false;
                    }
                    else
                    {
                        this.Init_Check_SN    = true;
                        this.Init_Check_SNing = false;
                    }

                    #endregion
                }

                else if (cmd is Cmd_X_GetNew)
                {
                    //3.4	下位机查向上位机请求新版固件信息的协议

                    //temp.hardLength = FileHelper.FileSize(testuploadfile);
                    if (string.IsNullOrEmpty(yoyoConst.EQU_SN) && cmdnew.hardLength <= 0)
                    {
                        bool flag = cmdReset();
                        if (flag)
                        {
                            devicemanager.Write(cmdnew);
                        }
                    }
                    else if (!string.IsNullOrEmpty(yoyoConst.EQU_SN))
                    {
                        devicemanager.Write(cmdnew);
                    }
                }
                else if (cmd is Cmd_X_GetData)
                {
                    if (string.IsNullOrEmpty(yoyoConst.EQU_SN) && cmdnew.hardLength <= 0)
                    {
                        bool flag = cmdReset();
                    }
                    else
                    {
                        #region 3.5	下位机向上位机请求固件数据的协议
                        // string x = cmd.GetData()[4].ToString();
                        byte[] cmddata = cmd.GetData();
                        cmd.show(cmddata);
                        byte[] intBuff = new byte[2];
                        intBuff[0] = cmddata[5];
                        intBuff[1] = cmddata[4];
                        int pos   = BitConverter.ToInt16(intBuff, 0);//取得包数
                        int start = pos * testuploadbaselength;
                        int end   = (start + testuploadbaselength) >= testuploadByte.Length ? testuploadByte.Length : (start + testuploadbaselength);

                        Cmd_S_GetData data = new Cmd_S_GetData();
                        data.packagePos = pos;
                        data.package    = new byte[end - start];
                        int packagepos = 0;
                        for (int i = start; i < end; i++)
                        {
                            data.package[packagepos] = testuploadByte[i];
                            packagepos++;
                        }
                        devicemanager.Write(data);
                        #endregion
                    }
                }
                else if (cmd is Cmd_X_Success)
                {
                    //3.6	下位机告知上位机固件下载成功的协议
                    devicemanager.Write(new Cmd_S_Success());
                }
                else if (cmd is Cmd_X_UpdateSuccess)
                {
                    //3.7	下位机通知上位机升级成功的协议
                    devicemanager.Write(new Cmd_S_UpdateSuccess());
                    //更新为最新版本
                    FileHelper.DeleteFolder(this.up_mcpVersion_url);
                    Init_Device_doing = false;
                    LogisTrac.WriteLog("固件文件更新成功,版本" + model.data.mcpVersion);
                    update_start();
                    //flash_change2(yoyoConst.YoyoStep.version);
                }
            }
            catch (Exception ex)
            {
                yoyoConst.WriteLog(ex.ToString());
            }
        }