AcsPushBuild.cs 2.43 KB
using HslCommunication.Enthernet;
using XingYe_ACS.BaseStruct;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace XingYe_ACS.WebApi
{
    public static class AcsPushBuild
    {
        private static NetPushServer netPushServer;
        public static void AcsPushBuildInit()
        {
            netPushServer = new NetPushServer();
            //netPushServer.Token = new Guid("WcsPushServer");
            netPushServer.ServerStart(94);
        }
        public static void PushAgv(Agv agv)
        {
            //PushAgv pushAgv = new PushAgv();
            //pushAgv.strAgvNo = agv.strAgvNo;
            //pushAgv.agvState = (int)agv.agvState;
            //Point currentPoint = App.PointList.Find(a => a.strBarcode == agv.strBarcode);
            //if (currentPoint != null)
            //{
            //    pushAgv.strBarcode = currentPoint.strBarcode;
            //    pushAgv.intX = currentPoint.intX;
            //    pushAgv.intY = 1000 - currentPoint.intY;
            //}
            //pushAgv.pointLength = agv.pointLength;
            //pushAgv.intRunDistance = agv.intRunDistance;
            //pushAgv.heightState = (int)agv.heightState;
            //pushAgv.currentCharge = agv.currentCharge;
            //pushAgv.agvHeart = agv.agvHeart;
            //pushAgv.strAgvError = agv.strAgvError;
            //if (agv.agvTask != null)
            //{
            //    pushAgv.taskNo = agv.agvTask.strTaskNo;
            //    Point nextPoint = App.PointList.Find(a => a.strBarcode == agv.nextPoint);
            //    if (nextPoint != null)
            //    {
            //        pushAgv.intNextX = nextPoint.intX;
            //        pushAgv.intNextY = 1000 - nextPoint.intY;
            //    }
            //}
            //string json = JsonConvert.SerializeObject(pushAgv);
            //netPushServer.PushString("PushAgv", json);
        }

        public static void PushLift(Station station,string status)
        {
            PushLift pushLift = new PushLift();
            pushLift.stationNo = station.strStationNo;
            pushLift.stationType = Enum.Parse(typeof(EnumMsg.StationType), station.stationType.ToString(), true).ToString();
            pushLift.status = "运行";
            pushLift.error = "";
            string json = JsonConvert.SerializeObject(pushLift);
            netPushServer.PushString("PushLift", json);
        }
    }
}