/// <summary>
        /// 接收事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        private void Client_DataReceived(object sender, DataReceivedEventArgs eventArgs)
        {
            byte[]        received = eventArgs.ReceivedData;
            ProtoInfoType type     = (ProtoInfoType)ProtobufNetWrapper.ReadValueFromByteArray(received, 0);

            _errorMessage = string.Empty;
            try
            {
                switch (type)
                {
                case ProtoInfoType.GNSS:
                    Const.GnssInfo = ProtobufNetWrapper.DeserializeFromBytes <GnssProtoInfo>(received);
                    Const.GnssInfo.CopyPropertyValueTo(ref Const.OpcDatasource);
                    break;

                case ProtoInfoType.RADAR:
                    Const.RadarInfo = ProtobufNetWrapper.DeserializeFromBytes <RadarProtoInfo>(received);
                    Const.RadarInfo.CopyPropertyValueTo(ref Const.OpcDatasource);
                    //Const.OpcDatasource.SetWheelBeyondStack(Const.RadarInfo.DistWheelLeft, Const.RadarInfo.DistWheelRight);
                    Const.OpcDatasource.UpdateCoalOnBeltLevel(Const.RadarInfo.DistBelt);
                    //TODO 高于静止无料以及皮带运动无料的级别才判断为有料
                    //if (!Config.DistBeltThresholdEnabled || (Config.DistBeltThresholdEnabled && Const.OpcDatasource.CoalOnBeltLevel > 1))
                    if (Const.OpcDatasource.CoalOnBeltLevel > 1)
                    {
                        _raiser.Click();
                    }
                    //if (!Config.DistBeltThresholdEnabled || (Config.DistBeltThresholdEnabled && Const.RadarInfo.DistBelt < Config.DistBeltThreshold))
                    //    _raiser.Click();
                    break;
                }
            }
            catch (Exception e) { _errorMessage = e.Message; }
        }
Exemple #2
0
 private void Timer1_Tick(object sender, EventArgs e)
 {
     this.UpdateBeidouInfo();
     //this.GnssProtoInfo.LocalCoor_Tipx = this.GnssProtoInfo.LocalCoor_Tipy = 111.55;
     //this.GnssProtoInfo.LocalCoor_Tipz = 44.99;
     //this.GnssProtoInfo.WalkingPosition = 1049.124;
     //this.GnssProtoInfo.PitchAngle = -1.42;
     //this.GnssProtoInfo.YawAngle = -59.44;
     //byte[] bytes = ProtobufNetWrapper.SerializeToBytes(this.GnssProtoInfo);
     //GnssProtoInfo info = ProtobufNetWrapper.DeserializeFromBytes<GnssProtoInfo>(bytes);
     byte[] array = ProtobufNetWrapper.SerializeToBytes(this.GnssProtoInfo, (int)ProtoInfoType.GNSS);
     this.tcpServerMain.SendData(array);
 }