/// <summary>
 /// 启动算法TCP客户端心跳
 /// </summary>
 public void StartHeartBeat()
 {
     Task.Factory.StartNew(() =>
     {
         Thread.Sleep(TimeSpan.FromSeconds(1));  //预留1秒钟连接时间
         if (management.IsConn)
         {
             WriteLogRealize.GetInstance().WriteTo_rTxtLog("算法服务器连接成功!");
         }
         while (management.IsConn)
         {
             Thread.Sleep(TimeSpan.FromSeconds(1));
             string base64txt = Convert.ToBase64String(new byte[] { CODE_HEARTBEAT });
             SendMsg(CODE_HEARTBEAT, Encoding.UTF8.GetBytes(base64txt));
             WriteLogRealize.GetInstance().WriteTo_rTxtHeart(true, CODE_HEARTBEAT, new byte[] { CODE_HEARTBEAT });
         }
     });
 }
 /// <summary>
 /// 启动算法TCP客户端心跳
 /// </summary>
 private void StartHeartBeat()
 {
     Task.Factory.StartNew(() =>
     {
         WriteLogRealize.GetInstance().WriteTo_rTxtLog("Java服务器连接成功!");
         while (IsConnected)
         {
             Thread.Sleep(TimeSpan.FromSeconds(3));
             short heart = 0x01;
             JavaHeartInfo javaHeartInfo = new JavaHeartInfo()
             {
                 deviceId    = "2933642251331350",
                 taskId      = "1",
                 chargeState = 50,
                 updateTime  = "20180811"
             };
             string jsonStr = SerializeHelper.SerializeObjectToJson(javaHeartInfo);
             byte[] bytes   = Encoding.UTF8.GetBytes(jsonStr);
             JavaClientControl.GetInstance().SendDataToJava(heart, bytes).Wait();
         }
     });
 }
 public override async Task OnServerDisconnected()
 {
     WriteLogRealize.GetInstance().WriteTo_rTxtLog("算法服务器中断连接!");
     AlgorithmClientControl.GetInstance().ConnectServer(MainForm.GetInstance().aIP, MainForm.GetInstance().aPort);
 }