Exemplo n.º 1
0
 /// <summary>
 /// 自动发送船对应的组件到消息中心
 /// </summary>
 /// <param name="info"></param>
 private static void SendInitData(ComponentInfo info)
 {
     if (ManagerHelp.IsShipPort && !ManagerHelp.isInit)
     {
         InitManger im = new InitManger();
         if (info.type == ComponentInfo.Type.MED || info.type == ComponentInfo.Type.HKD)
         {
             //发送设备请求
             bool flag = im.InitDevice();
             if (flag)
             {
                 Task.Factory.StartNew(t =>
                 {
                     while (ManagerHelp.DeviceResult == "")
                     {
                         Thread.Sleep(1000);
                     }
                     //收到设备后发送算法请求
                     im.InitAlgorithm();
                     ManagerHelp.isFaceAlgorithm = true;
                     ManagerHelp.DeviceResult    = "";
                 }, TaskCreationOptions.LongRunning);
             }
         }
         else if (info.type == ComponentInfo.Type.AI)
         {
             im.InitAlgorithm(info.cname);
             ManagerHelp.isFaceAlgorithm = true;
         }
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// AIS数据
 /// </summary>
 /// <param name="ais"></param>
 public void AisAdd(Ais ais)
 {
     if (ais != null)
     {
         try
         {
             using (var context = new MyContext())
             {
                 var  ship = context.Ship.FirstOrDefault();
                 bool flag = ais.status == 0 ? true : false;
                 //当航行状态为自动时才将AIS的状态保存到数据库中
                 if (ship != null && ship.type == 0 && ship.Flag != flag)
                 {
                     ship.Flag = flag;
                     context.Update(ship);
                     context.SaveChanges();
                     //船状态修改时要推送消息给算法
                     InitManger im = new InitManger();
                     im.InitStatus();
                 }
             }
         }
         catch (Exception ex)
         {
             AddReceiveLog("AIS", "", "写入数据失败!" + ex.Message);
         }
     }
 }