Пример #1
0
 public ShowMessageAction(EMessageType type, string title, string subtitle, string content)
     : base(EAJAXActionType.ShowMessage)
 {
     MessageType = type;
     MessageTitle = title;
     MessageSubtitle = subtitle;
     MessageContent = content;
 }
Пример #2
0
        public MessageBoxForm(string message, EMessageType type)
        {
            InitializeComponent();

            label1.Text = message;
            if (type == EMessageType.Alert)
                pictureBox1.Image = Properties.Resources.alert;
            if (type == EMessageType.Error)
                pictureBox1.Image = Properties.Resources.error;
        }
Пример #3
0
        /// <inheritdoc />
        public override void ReadRaw(byte[] raw)
        {
            if (raw.Length == 0)
            {
                throw new OptionLengthZeroException();
            }

            if (raw.Length != 1)
            {
                throw new OptionLengthNotExactException(string.Format("Invalid length: {0}. Should be 1.", raw.Length));
            }

            this.Type = (EMessageType)(byte)raw[0];
        }
 public STankWatererParameters(byte[] body)
 {
     type             = EMessageType.TankWatererParameters;
     AutoVent         = body[1] != 0;
     AutoDepth        = body[2] != 0;
     ValveTimeOut     = BitConverter.ToUInt16(body, 3);
     TankDepth        = BitConverter.ToUInt16(body, 5);
     SurfaceArea      = BitConverter.ToUInt16(body, 7);
     SensorDistance   = BitConverter.ToUInt16(body, 9);
     PulsesPerLitre   = BitConverter.ToUInt16(body, 11);
     AutoVentTime     = BitConverter.ToUInt16(body, 13);
     MaxValveOpenTime = BitConverter.ToUInt16(body, 15);
     MaxWater24Hours  = BitConverter.ToUInt16(body, 17);
 }
Пример #5
0
        public MessageBoxForm(string message, EMessageType type)
        {
            InitializeComponent();

            label1.Text = message;
            if (type == EMessageType.Alert)
            {
                pictureBox1.Image = Properties.Resources.alert;
            }
            if (type == EMessageType.Error)
            {
                pictureBox1.Image = Properties.Resources.error;
            }
        }
Пример #6
0
        /// <summary>
        /// 发布点对点消息
        /// </summary>
        /// <returns></returns>
        public bool Publish_Device(EMessageType messageType, ECmdType cmdType, string cmdName, string cmdInfo, List <CDevList> devList, out string er)
        {
            try
            {
                CMessage <CData_Cmd> message = new CMessage <CData_Cmd>();

                CHeader header = new CHeader()
                {
                    ID   = _pc_idNo,
                    Name = _pc_name,
                    Type = (int)ENodeType.主控端,
                    Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                };

                message.Header = header;

                message.Data = new List <CData_Cmd>();

                for (int i = 0; i < devList.Count; i++)
                {
                    message.Data.Add(new CData_Cmd()
                    {
                        ID      = devList[i].idNo,
                        Name    = devList[i].Name,
                        CmdType = (int)cmdType,
                        CmdName = cmdName,
                        CmdInfo = cmdInfo,
                        Remark1 = string.Empty,
                        Remark2 = string.Empty
                    });
                }

                string topic = _publishTopics[messageType];

                string cmd = CJSon.Serializer <CMessage <CData_Cmd> >(message);

                if (!_mqtt.Publish(topic, cmd, out er))
                {
                    return(false);
                }

                return(true);
            }
            catch (Exception ex)
            {
                er = ex.ToString();
                return(false);
            }
        }
Пример #7
0
    public static void Send(TcpClient client, EMessageType msgType, Type msgClass, Object message)
    {
        XmlSerializer serializer = new XmlSerializer(msgClass);
        StringBuilder stringBuilder = new StringBuilder();
        StringWriter writer = new StringWriter(stringBuilder);
        serializer.Serialize(writer, message);

        //string msgStr = msgTyp
        byte[] bytes = System.Text.Encoding.UTF8.GetBytes(writer.ToString());
        byte[] allBytes = new byte[bytes.Length + 1];
        allBytes[0] = (byte)msgType;
        bytes.CopyTo(allBytes, 1);

        client.Client.Send(bytes);
    }
Пример #8
0
        SendToLeft
        (
            EMessageType aType
        )
        {
            if (aType == EMessageType.Unknown)
            {
                return;
            }

            MessagesToForward.Add(aType);
            MessagesToIgnore.Remove(aType);

            UpdateUser();
        }
Пример #9
0
        public void SendMessage(string[] args, EMessageType messageType)
        {
            DiscordWebhook webhook = configuration.Webhooks.FirstOrDefault(x => x.WebhookType == messageType.ToString());

            if (webhook == null || string.IsNullOrEmpty(webhook.WebhookUrl))
            {
                return;
            }

            List <Field> fields = new List <Field>();

            string[] array = webhook.MessageFormat.Split(new string[] { ": ", ", " }, StringSplitOptions.RemoveEmptyEntries);
            int      num   = 0;

            while (num < array.Length - 1)
            {
                string[] arr = array.Skip(num).Take(2).ToArray();

                string value = arr[1].Replace("{name}", args[0]).Replace("{steamid}", args[1]).Replace("{punisher}", args[2]);

                if (messageType != EMessageType.Unban)
                {
                    value = value.Replace("{reason}", args[3]);
                }
                if (messageType == EMessageType.Ban)
                {
                    value = value.Replace("{duration}", args[4]);
                }

                Field field = new Field(arr[0], value, true);

                fields.Add(field);
                num += 2;
            }

            DiscordWebhookMessage msg = new DiscordWebhookMessage();

            msg.embeds = new List <Embed>()
            {
                new Embed(fields)
            };

            using (WebClient wc = new WebClient())
            {
                wc.Headers.Add(HttpRequestHeader.ContentType, "application/json");
                wc.UploadString(webhook.WebhookUrl, JsonConvert.SerializeObject(msg));
            }
        }
Пример #10
0
    public static void Send(TcpClient client, EMessageType msgType, Type msgClass, Object message)
    {
        XmlSerializer serializer    = new XmlSerializer(msgClass);
        StringBuilder stringBuilder = new StringBuilder();
        StringWriter  writer        = new StringWriter(stringBuilder);

        serializer.Serialize(writer, message);

        //string msgStr = msgTyp
        byte[] bytes    = System.Text.Encoding.UTF8.GetBytes(writer.ToString());
        byte[] allBytes = new byte[bytes.Length + 1];
        allBytes[0] = (byte)msgType;
        bytes.CopyTo(allBytes, 1);

        client.Client.Send(bytes);
    }
Пример #11
0
        public static string MessageTypeToUIStr(EMessageType type)
        {
            string result = "";

            switch (type)
            {
            case EMessageType.Batch: { result = CS_EMessageType_Batch_UIStr; } break;

            case EMessageType.ETimed: { result = CS_EMessageType_EDTimed_UIStr; } break;

            case EMessageType.EAdditional: { result = CS_EMessageType_EAdditional_UIStr; } break;

            case EMessageType.Manual: { result = CS_EMessageType_Manual_UIStr; } break;
            }
            return(result);
        }
        /*
         *  SHomeSensorMsgHdr hdr;
         *  uint8_t sequence;
         *  uint32_t millilitres;
         *  int16_t temperature;
         *  uint16_t humidity;
         *  uint16_t vbat;
         *  uint16_t vsolar;
         *
         */
        public SRainGaugeStats(byte[] body)
        {
            type     = EMessageType.RainGaugeStats;
            Sequence = body[1];
            UInt32 imillimeters = BitConverter.ToUInt32(body, 2);       // 0.01 ml units
            Int16  itemperature = BitConverter.ToInt16(body, 6);        // 0.1 C units
            UInt16 ihumidity    = BitConverter.ToUInt16(body, 8);       // 0.1 %
            UInt16 ivbat        = BitConverter.ToUInt16(body, 10);      // mV
            UInt16 ivsolar      = BitConverter.ToUInt16(body, 12);      // mV

            millimeters = (double)imillimeters / 100.0;
            temperature = (double)itemperature / 10.0;
            humidity    = (double)ihumidity / 10.0;
            vbat        = (double)ivbat / 1000.0;
            vsolar      = (double)ivsolar / 1000.0;
        }
Пример #13
0
        /// <summary>
        /// 接收消息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnMessageRecv(object sender, CMQTT.CMessageArgs e)
        {
            try
            {
                if (!_recieveTopics.ContainsKey(e.topic))
                {
                    OnMessageArgs.OnEvented(new CCMessageArgs(e.idNo, e.name, e.topic, e.message, true, "主题不存在"));
                    return;
                }

                EMessageType msgType = _recieveTopics[e.topic];

                switch (msgType)
                {
                case EMessageType.广播指令:      //请求指示
                    CMessage <CData_Cmd> cmd_RPT = CJSon.Deserialize <CMessage <CData_Cmd> >(e.message);
                    OnRPTCmdArgs.OnEvented(new CCmdArgs(e.topic, e.message, cmd_RPT));
                    break;

                case EMessageType.应答指令:      //应答指令
                    CMessage <CData_Cmd> cmd_REQ = CJSon.Deserialize <CMessage <CData_Cmd> >(e.message);
                    OnREQCmdArgs.OnEvented(new CCmdArgs(e.topic, e.message, cmd_REQ));
                    break;

                case EMessageType.状态消息:
                    CMessage <CData_Status> status_data = CJSon.Deserialize <CMessage <CData_Status> >(e.message);
                    OnStatusArgs.OnEvented(new CStatusArgs(e.topic, e.message, status_data));
                    break;

                case EMessageType.报警消息:
                    break;

                case EMessageType.抽样消息:
                    break;

                default:
                    break;
                }

                OnMessageArgs.OnEvented(new CCMessageArgs(e.idNo, e.name, e.topic, e.message, false, msgType.ToString()));
            }
            catch (Exception ex)
            {
                OnMessageArgs.OnEvented(new CCMessageArgs(e.idNo, e.name, e.topic, e.message, true, ex.ToString()));
            }
        }
        [JsonProperty] public double Temperature;  // in 0.1C units

        public STankWatererStats(byte[] body)
        {
            type          = EMessageType.TankWatererStats;
            HighWaterMark = (body[1] & 0x01) != 0;
            ValveOpen     = (body[1] & 0x02) != 0;
            uTankFlow     = BitConverter.ToUInt32(body, 2);
            uTankOverflow = BitConverter.ToUInt32(body, 6);
            uWater24Hours = BitConverter.ToUInt16(body, 10);
            Moisture1     = BitConverter.ToUInt16(body, 14);
            Moisture2     = BitConverter.ToUInt16(body, 16);
            TankVolume    = BitConverter.ToUInt16(body, 18);
            uTemperature  = BitConverter.ToUInt16(body, 20);
            TankFlow      = (double)uTankFlow / 10.0;
            TankOverflow  = (double)uTankOverflow / 10.0;
            Temperature   = (double)uTemperature / 10.0;
            Water24Hours  = (double)uWater24Hours / 10.0;
        }
Пример #15
0
        public bool Parse_1(String msg, out CReportStruct report)
        {
            //
            //6013 $60131G21 11 0200 012345 04
            report = null;
            try
            {
                string data = string.Empty;
                if (!ProtocolHelpers.DeleteSpecialChar(msg, out data))
                {
                    return(false);
                }

                //  解析站点ID
                String stationID = data.Substring(0, 4);
                //  解析通信类别
                String type = data.Substring(6, 2);
                if (type != "21")
                {
                    return(false);
                }
                //  解析报文类别
                EMessageType reportType = ProtocolMaps.MessageTypeMap.FindKey(data.Substring(8, 2));
                //  解析接收时间
                DateTime recvTime       = DateTime.Now;
                string   hour           = data.Substring(10, 2);
                string   minute         = data.Substring(12, 2);
                DateTime collectTine    = new DateTime(recvTime.Year, recvTime.Month, recvTime.Day, int.Parse(hour), int.Parse(minute), 0);
                string   water          = data.Substring(14, 6);
                string   WaterPotential = data.Substring(20, 2);
                //  获取数据段,不包含站号、类别、报类、站类信息
                report = new CReportStruct()
                {
                    RecvTime  = recvTime,
                    Stationid = stationID
                };
                return(true);
            }
            catch (Exception exp)
            {
                System.Diagnostics.Debug.WriteLine("数据:" + msg);
                System.Diagnostics.Debug.WriteLine("上行指令解析数据不完整!" + exp.Message);
            }
            return(false);
        }
Пример #16
0
        private void btnServerCmd_Click(object sender, EventArgs e)
        {
            try
            {
                btnServerCmd.Enabled = false;

                string er = string.Empty;

                EMessageType messType = EMessageType.广播指令;

                string cmdInfo = txtCmdInfo.Text;

                if (cmbMesType.SelectedIndex == 1)
                {
                    messType = EMessageType.应答指令;

                    EDevRunStatus runStat = (EDevRunStatus)Enum.Parse(typeof(EDevRunStatus), cmbCmdInfo.Text);

                    cmdInfo = ((int)runStat).ToString();
                }

                ECmdType cmdType = (ECmdType)cmbCmdType.SelectedIndex;

                string cmdName = cmdType.ToString();

                if (!_service.Publish_ALL(messType, cmdType, cmdName, cmdInfo, out er))
                {
                    ShowServiceStatus(er, true);
                    return;
                }

                ShowServiceStatus("发布消息OK", false);
            }
            catch (Exception ex)
            {
                ShowServiceStatus(ex.ToString(), false);
            }
            finally
            {
                btnServerCmd.Enabled = true;
            }
        }
Пример #17
0
 public static string GetValue(EMessageType type)
 {
     if (type == EMessageType.Success)
     {
         return("Success");
     }
     if (type == EMessageType.Error)
     {
         return("Error");
     }
     if (type == EMessageType.Info)
     {
         return("Info");
     }
     if (type == EMessageType.None)
     {
         return("None");
     }
     throw new Exception();
 }
Пример #18
0
        protected MessageType ConvertMessageType(EMessageType eMessageType)
        {
            switch (eMessageType)
            {
            case EMessageType.None:
                return(MessageType.None);

            case EMessageType.Info:
                return(MessageType.Info);

            case EMessageType.Warning:
                return(MessageType.Warning);

            case EMessageType.Error:
                return(MessageType.Error);

            default:
                throw new System.ArgumentOutOfRangeException();
            }
        }
Пример #19
0
        public void ShowMessage(EMessageType st, string str, Callback <bool> callback)
        {
            if (mVisible)
            {
                return;
            }

            m_Callback = callback;
            mStatus    = st;

            Show();
            switch (mStatus)
            {
            case EMessageType.EMT_SureToWash:
                mMessage.text       = str;
                mSubmitBt.isEnabled = true;
                mTimeLabel.text     = "确认";
                mCaption.gameObject.SetActive(false);
                m_CloseBtn.gameObject.SetActive(true);
                break;
            }
        }
Пример #20
0
        public void SendMessage(string content, EMessageType messageType)
        {
            DiscordWebhook webhook = configuration.Webhooks.FirstOrDefault(x => x.WebhookType == messageType.ToString());

            if (webhook == null || string.IsNullOrEmpty(webhook.WebhookUrl))
            {
                return;
            }

            DiscordWebhookMessage msg = new DiscordWebhookMessage();

            msg.embeds = new List <Embed>()
            {
                new Embed(content, Convert.ToInt32(webhook.WebhookColor, 16))
            };

            using (WebClient wc = new WebClient())
            {
                wc.Headers.Add(HttpRequestHeader.ContentType, "application/json");
                wc.UploadString(webhook.WebhookUrl, JsonConvert.SerializeObject(msg));
            }
        }
Пример #21
0
    public void ShowMessage(EMessageType type)
    {
        string message = "";

        switch (type)
        {
        case EMessageType.OpenCamera:
            message = _openCamera;
            break;

        case EMessageType.TakeImportantPictures:
            message = _takeImportantPictures;
            break;

        case EMessageType.ClickToInteract:
            message = _clickToInteract;
            break;
        }

        _textfield.text = message;
        MessageShown    = type;
        _textfield.DOFade(1.0f, _animationDuration);
    }
Пример #22
0
        public Message(EMessageType MessageType, int count, DisplayInfo dInfo)
        {
            this.dInfo       = dInfo;
            this.MessageType = MessageType;
            this.count       = count;

            IsDead = false;

            switch (MessageType)
            {
            case EMessageType.FAILED:
                message = "BALL FAILED!!";
                break;

            case EMessageType.CLEAR:
                message = "CLEAR!!";
                break;

            case EMessageType.GAMEOVER:
                message = "GAME OVER!!";
                break;
            }
        }
Пример #23
0
 public void ClearMessages(EMessageType msgType)
 {
     _messages = msgType == EMessageType.All
         ? new List<IDomainMessage>()
         : _messages.Where(item => item.Type != msgType).ToList();
 }
Пример #24
0
 public void message(EMessageType prio, string file, int line, string fmt) {
   modshogunPINVOKE.SGIO_message(swigCPtr, (int)prio, file, line, fmt);
   if (modshogunPINVOKE.SWIGPendingException.Pending) throw modshogunPINVOKE.SWIGPendingException.Retrieve();
 }
Пример #25
0
 public AgentJobMessageBase(AgentGuid NewJobGuid,EMessageType NewType)
     : base(NewType)
 {
     JobGuid = NewJobGuid;
 }
Пример #26
0
 public void SendMessage(EMessageType pType, string pMessage, params object[] pArgs)
 {
     Packet packet = new Packet(EOpcode.SMSG_MESSAGE);
     packet.WriteByte((byte)pType);
     packet.WriteString(string.Format(pMessage, pArgs));
     if (pType == EMessageType.GMText) packet.WriteInt(0);
     mClient.SendPacket(packet);
 }
Пример #27
0
 /**
  * Constructor, initializes to specified values
  *
  * @param NewType The type of the message, one of EMessageType
  */
 public FMessage(EMessageType NewType)
 {
     Version = ESwarmVersionValue.VER_1_0;
     Type    = NewType;
 }
Пример #28
0
		public SimpleTextMessage(EMessageType _type, string _text)
		{
			Type = _type;
			Text = _text;
		}
Пример #29
0
 public static void ParseMsg(byte[] allBytes, out EMessageType msgType, out string message)
 {
     msgType = (EMessageType)allBytes[0];
     message = System.Text.Encoding.UTF8.GetString(allBytes, 1, allBytes.Length - 1);
 }
Пример #30
0
 public void set_loglevel(EMessageType level) {
   modshogunPINVOKE.SGIO_set_loglevel(swigCPtr, (int)level);
   if (modshogunPINVOKE.SWIGPendingException.Pending) throw modshogunPINVOKE.SWIGPendingException.Retrieve();
 }
Пример #31
0
 public void ShowMessage(string message, EMessageType type = EMessageType.Alert)
 {
     Console.WriteLine(string.Format("{0} {1}", message, type.ToString()));
 }
Пример #32
0
 /// <summary>
 /// <see cref="WifiP2pActivity.OnMessageReceivedProgressChanged(EMessageType, float)"/>
 /// </summary>
 override public void OnMessageReceivedProgressChanged(EMessageType message, float progress)
 {
     throw new System.NotImplementedException();
 }
Пример #33
0
        public bool Parse(String msg, out CReportStruct report)
        {
            //6013 $60131G2201161111040003046112271367
            report = null;
            try
            {
                string data = string.Empty;
                if (!ProtocolHelpers.DeleteSpecialChar(msg, out data))
                {
                    return(false);
                }

                //  解析站点ID
                String stationID = data.Substring(0, 4);
                //  解析通信类别
                String type = data.Substring(4, 2);
                //  解析报文类别
                EMessageType reportType = ProtocolMaps.MessageTypeMap.FindKey(data.Substring(6, 2));

                //  解析站点类别
                //EStationType stationType = EStationType.EHydrology;
                //String stationTypeStr = data.Substring(8, 2);
                //switch (stationTypeStr)
                //{
                //    case "01":  //  雨量
                //        stationType = EStationType.ERainFall;
                //        break;
                //    case "02":  //  水位
                //    case "12":
                //        stationType = EStationType.ERiverWater;
                //        break;
                //    case "03":  //  水文
                //    case "13":
                //        stationType = EStationType.EHydrology;
                //        break;
                //}
                EStationType stationType = ProtocolHelpers.ProtoStr2StationType(data.Substring(8, 2));

                //  解析接收时间
                DateTime recvTime = DateTime.Now;

                //  获取数据段,不包含站号、类别、报类、站类信息
                var lists = data.Substring(10).Split(CSpecialChars.BALNK_CHAR);
                var datas = GetData(lists, stationType);

                report = new CReportStruct()
                {
                    Stationid   = stationID,
                    Type        = type,
                    ReportType  = reportType,
                    StationType = stationType,
                    RecvTime    = recvTime,
                    Datas       = datas
                };
                return(true);
            }
            catch (Exception exp)
            {
                System.Diagnostics.Debug.WriteLine("数据:" + msg);
                System.Diagnostics.Debug.WriteLine("上行指令解析数据不完整!" + exp.Message);
            }
            return(false);
        }
Пример #34
0
 public static ClientNotificationMessageModel CreateNotificationMessage(string content, EMessageType type)
 {
     return new ClientNotificationMessageModel() { Content = content, MessageType = type.ToString() };
 }
Пример #35
0
        // 处理COUT类型数据
        private void DealCOUT(string msg)
        //  private String DealCOUT(string msg)
        {
            string result = null;

            InvokeMessage("通信输出  " + msg, "接收");
            SendBackTTCAString = msg;
            if (msg.Contains("COUT"))
            {
                if (msg.Contains("COUT"))
                {
                    num = num + 1;
                    FileStream   fs = new FileStream("numbd.txt", FileMode.Create);
                    StreamWriter sw = new StreamWriter(fs);
                    //开始写入
                    sw.Write(num);
                    //清空缓冲区
                    sw.Flush();
                    //关闭流
                    sw.Close();
                    fs.Close();
                }
            }
            // InvokeString(msg);
            var cout = BeidouHelper.GetCOUTInfo(msg);

            if (cout == null)
            {
                return;
            }

            //  return result;
            //  发送COSS指令
            //  必须在1秒内发送给卫星终端,否则会重新发送“通信输出”
            var coss = new CCOSSStruct();

            coss.SuccessStatus = true;          //  终端接收到外设通信申请,并校验成功
            SendCOSS(coss);
            //  发送CACA指令
            //  每隔一分钟发送回执$CACA
            //  65秒左右发一条
            var caca = new CCACAStruct();

            caca.SenderID              = "1";                 //  发信方ID为1,表示本机ID,默认
            caca.RecvType              = cout.SenderType;     //  回执的收信方类型  ==  通信输出中的发信方类型
            caca.RecvAddr              = cout.SenderAddr;     //  回执的收信方地址  ==  通信输出中的发信方地址
            caca.Requirements          = "1";                 //  不保密
            caca.ReceiptMsgSequenceNum = cout.MsgSequenceNum; // 回执的报文顺序号  ==  通信输出中的报文顺序号
            caca.ReceiptContent        = "1";
            SendCACA(caca);

            //  解析通信输出中的内容
            string content = cout.MsgContent;

            //通信输出gm8  $60131G2201161111040003046112271367
            try
            {
                string           rawMsg     = content;
                string           sid        = null;
                string           dealMsg    = ProtocolHelpers.dealBCD(rawMsg);
                WriteToFileClass writeClass = new WriteToFileClass("ReceivedLog");
                Thread           t          = new Thread(new ParameterizedThreadStart(writeClass.WriteInfoToFile));
                t.Start("COUT Message: " + " " + dealMsg + "\r\n");
                string bdid = cout.SenderAddr;
                //InvokeMessage("gm3  " + content, "接收");
                //sid需要根据北斗卫星号获取
                try
                {
                    sid = Manager.XmlStationDataSerializer.Instance.GetStationByBDID(bdid);
                }
                catch (Exception e)
                {
                    sid = "5712";
                    Debug.WriteLine("获取站号失败" + e.Message);
                }
                EMessageType type       = ProtocolMaps.MessageTypeMap.FindKey(dealMsg.Substring(0, 2));
                string       reportType = dealMsg.Substring(0, 2);
                if (reportType == "21" || reportType == "22")   //   定时报,加报
                {
                    //  YAC设备的墒情协议:
                    string stationType = dealMsg.Substring(2, 2);
                    switch (stationType)
                    {
                    //  站类为04时墒情站 05墒情雨量站 06,16墒情水位站 07,17墒情水文站
                    case "04":
                    case "05":
                    case "06":
                    case "07":
                    case "17":
                    {
                        //    var station = FindStationByBeidouID(cout.SenderAddr);
                        //    string currentMsg = rawMsg.Insert(0, "$" + station.StationID + "1G");
                        //    CEntitySoilData soil = new CEntitySoilData();
                        //    CReportStruct soilReport = new CReportStruct();
                        //    if (Soil.Parse(currentMsg, out soil, out soilReport))
                        //    {
                        //        soil.ChannelType = EChannelType.BeiDou;

                        //        if (null != this.SoilDataReceived)
                        //            this.SoilDataReceived(null, new CEventSingleArgs<CEntitySoilData>(soil));

                        //        if (null != soilReport && null != this.UpDataReceived)
                        //        {
                        //            soilReport.ChannelType = EChannelType.BeiDou;
                        //            soilReport.ListenPort = "COM" + this.Port.PortName;
                        //            this.UpDataReceived(null, new UpEventArgs() { RawData = rawMsg, Value = soilReport });
                        //        }
                        //    }

                        //}
                        //1111gm
                        string          newMsg     = dealMsg.Substring(1, dealMsg.Length - 1);
                        CEntitySoilData soil       = new CEntitySoilData();
                        CReportStruct   soilReport = new CReportStruct();
                        if (Soil.Parse(newMsg, out soil, out soilReport))
                        {
                            soilReport.ChannelType = EChannelType.BeiDou;
                            if (null != this.SoilDataReceived)
                            {
                                this.SoilDataReceived(null, new CEventSingleArgs <CEntitySoilData>(soil));
                            }

                            if (null != soilReport && null != this.UpDataReceived)
                            {
                                soilReport.ChannelType = EChannelType.GPRS;
                                soilReport.ListenPort  = "COM" + this.Port.PortName;
                                soilReport.flagId      = bdid;
                                this.UpDataReceived(null, new UpEventArgs()
                                    {
                                        RawData = newMsg, Value = soilReport
                                    });
                            }
                        }
                    }
                    break;

                    //  站类为01,02,03,12,13时,不是墒情站
                    case "01":
                    case "02":
                    case "03":
                    case "12":
                    case "13":
                    {
                        //1111gm
                        //string newMsg = dealMsg.Substring(1, dealMsg.Length - 1);
                        //CReportStruct report = new CReportStruct();
                        //if (Up.Parse(newMsg, out report))
                        //{
                        //    //6013 $60131G2201161111040003046112271367
                        //    report.ChannelType = EChannelType.BeiDou;
                        //    report.ListenPort = "COM" + this.Port.PortName;
                        //    if (this.UpDataReceived != null)
                        //    {
                        //        this.UpDataReceived.Invoke(null, new UpEventArgs() { Value = report, RawData = newMsg });
                        //    }
                        //}
                        CReportStruct report = new CReportStruct();
                        UpParser      Up1    = new UpParser();
                        if (Up1.Parse_beidou(sid, type, rawMsg, out report))
                        {
                            //InvokeMessage("gm6  " + rawMsg, "接收");
                            //$60131G2201161111040003046112271367
                            report.ChannelType = EChannelType.BeiDou;
                            report.ListenPort  = "COM" + this.Port.PortName;
                            report.flagId      = bdid;
                            if (this.UpDataReceived != null)
                            {
                                //InvokeMessage("gm7  " + rawMsg, "接收");
                                this.UpDataReceived.Invoke(null, new UpEventArgs()
                                    {
                                        Value = report, RawData = rawMsg
                                    });
                            }
                        }
                    }
                    break;

                    default:
                        break;
                    }
                }
                else if (reportType == "11")    //  人工水位
                {
                }
                else if (reportType == "23")    //  人工流量
                {
                }
                else if (reportType == "25")
                {
                    var    station    = FindStationByBeidouID(cout.SenderAddr);
                    string currentMsg = dealMsg.Insert(0, "$" + station.StationID + "1G");

                    CEntitySoilData soil       = new CEntitySoilData();
                    CReportStruct   soilReport = new CReportStruct();
                    if (Soil.Parse(currentMsg, out soil, out soilReport))
                    {
                        soil.ChannelType = EChannelType.BeiDou;

                        if (null != this.SoilDataReceived)
                        {
                            this.SoilDataReceived(null, new CEventSingleArgs <CEntitySoilData>(soil));
                        }

                        if (null != soilReport && null != this.UpDataReceived)
                        {
                            soilReport.ChannelType = EChannelType.BeiDou;
                            soilReport.ListenPort  = "COM" + this.Port.PortName;
                            soilReport.flagId      = bdid;
                            this.UpDataReceived(null, new UpEventArgs()
                            {
                                RawData = dealMsg, Value = soilReport
                            });
                        }
                    }
                }
            }
            catch (Exception exp)
            {
                System.Diagnostics.Debug.WriteLine("Beidou 数据解析出错 !" + content + "\r\n" + exp.Message);
            }
            //result = msg;
            //return result;
        }
Пример #36
0
 public GUIStyle this[EMessageType type]
 {
     get { return(GetTextStyle(type)); }
 }
Пример #37
0
 /**
  * Constructor, initializes to specified values
  *
  * @param NewVersion The version of the message format; one of ESwarmVersionValue
  * @param NewType The type of the message, one of EMessageType
  */
 public FMessage(ESwarmVersionValue NewVersion, EMessageType NewType)
 {
     Version = NewVersion;
     Type    = NewType;
 }
Пример #38
0
 private GUIStyle GetTextStyle(EMessageType type)
 {
     return(m_TextStyle[(int)type]);
 }
Пример #39
0
 public static void CheckMessage(Message message, EMessageType result, string value)
 {
     Assert.AreEqual(result, message.Type);
     Assert.AreEqual(value, message.Value);
 }
Пример #40
0
        public void ShowMessage(string message, EMessageType type = EMessageType.Alert)
        {
            var frm = new MessageBoxForm(message, type);

            frm.ShowDialog();
        }
Пример #41
0
 public Message(EMessageType type, byte[] arguments = null)
 {
     Type      = type;
     Arguments = arguments;
 }
Пример #42
0
 public IList<IDomainMessage> GetMessages(EMessageType msgType)
 {
     return msgType == EMessageType.All
         ? _messages
         : _messages.Where(item => item.Type == msgType).ToList();
 }
 public void ShowMessage(string message, EMessageType type = EMessageType.Alert)
 {
     var frm = new MessageBoxForm(message, type);
     frm.ShowDialog();
 }
Пример #44
0
 public void ShowMessage(string message, EMessageType type = EMessageType.Alert)
 {
     MessageBox.Show(message);
 }