Esempio n. 1
0
 static void _mc_OnSent(MessagesCommunicator comm, WialonIPS.Message msg)
 {
     //this.Log.PostHead("<<<", msg.ToString());
     //if (msg.MsgType == MessageType.Message)
     //    this.Messages.Sent((msg as WialonIPS.MessageMessage).Text);
     if (Settings.SendPingPackets)
     {
         tmrPing.Change(_ping_interval, _ping_interval);
     }
 }
Esempio n. 2
0
 void _mc_OnReceive(MessagesCommunicator comm, WialonIPS.Message msg)
 {
     this.Log.PostHead(">>>", msg.ToString());
     if (msg.MsgType == MessageType.Message)
     {
         this.Messages.Received((msg as WialonIPS.MessageMessage).Text);
     }
     if (msg.MsgType == MessageType.LoginAns && !(msg as LoginAnsMessage).Success)
     {
         Disconnect();
     }
 }
Esempio n. 3
0
 static void _mc_OnReceive(MessagesCommunicator comm, WialonIPS.Message msg)
 {
     Console.WriteLine(">>>" + msg.ToString());
     if (msg.MsgType == MessageType.Message)
     {
         Console.WriteLine((msg as WialonIPS.MessageMessage).Text);
     }
     //this.Messages.Received((msg as WialonIPS.MessageMessage).Text);
     if (msg.MsgType == MessageType.LoginAns && !(msg as LoginAnsMessage).Success)
     {
         Disconnect();
     }
 }
Esempio n. 4
0
        private void UpdateDataPacketText(DateTime time)
        {
            this.send_data_message = null;
            double?lat = null, lon = null;
            int?   alt     = null;
            UInt16?speed   = null;
            UInt16?heading = null;
            byte?  sats    = null;
            double dvalue  = 0;
            int    ivalue  = 0;
            UInt16 uivalue = 0;
            byte   bvalue  = 0;

            if (double.TryParse(this.tbLat.Text, out dvalue))
            {
                lat = dvalue;
            }
            if (double.TryParse(this.tbLon.Text, out dvalue))
            {
                lon = dvalue;
            }
            if (int.TryParse(this.tbAlt.Text, out ivalue))
            {
                alt = ivalue;
            }
            if (UInt16.TryParse(this.tbSpeed.Text, out uivalue))
            {
                speed = uivalue;
            }
            if (UInt16.TryParse(this.tbHeading.Text, out uivalue))
            {
                heading = uivalue;
            }
            if (byte.TryParse(this.tbSats.Text, out bvalue))
            {
                sats = bvalue;
            }

            var dev = (this.cbDevice.SelectedItem as DeviceInfo);

            dev.Latitude  = lat;
            dev.Longitude = lon;
            dev.Altitude  = alt;
            dev.Speed     = speed;
            dev.Heading   = heading;
            dev.Sats      = sats;

            if (this.rbFullData.Checked)
            {
                // full data packet
                dev.HDOP = WialonIPS.Message.ParseDouble(this.tbHdop.Text);
                if (this.cbiButtonEnabled.Checked)
                {
                    dev.IButton = this.tbIButton.Text;
                }
                else
                {
                    dev.IButton = "NA";
                }
                dev.Alarm   = this.cbAlarm.Checked;
                dev.Inputs  = this.ioInputs.Value;
                dev.Outputs = this.ioOutputs.Value;
                if (this._adc_params.Length > 0)
                {
                    dev.Adcs = new double[this._adc_params.Length];
                    for (var i = 0; i < dev.Adcs.Length; i++)
                    {
                        if (this._adc_params[i] != null)
                        {
                            double val = 0;
                            if (double.TryParse(this._adc_params[i].Text.Text, out val))
                            {
                                dev.Adcs[i] = val;
                            }
                        }
                        else
                        {
                            dev.Adcs[i] = 0;
                        }
                    }
                }
                else
                {
                    dev.Adcs = null;
                }
                if (dev.CustomParameters != null)
                {
                    for (var i = 0; i < dev.CustomParameters.Length; i++)
                    {
                        var text = this._custom_params[i].Value.Text;
                        if (((CustomParamType)this._custom_params[i].Type.SelectedItem) == CustomParamType.Double)
                        {
                            text = text.Replace(',', '.');
                        }
                        dev.CustomParameters[i] = new CustomParameter(
                            this._custom_params[i].Name.Text,
                            (CustomParamType)this._custom_params[i].Type.SelectedItem,
                            text);
                        if (dev.CustomParameters[i].Name == "SOS" && dev.CustomParameters[i].Type == CustomParamType.Int)
                        {
                            dev.Alarm = (dev.CustomParameters[i].Value == "1");
                            this.cbAlarm.CheckedChanged -= this.UpdateCurrentPacketDataHandler;
                            this.cbAlarm.Checked         = dev.Alarm;
                            this.cbAlarm.CheckedChanged += new EventHandler(this.UpdateCurrentPacketDataHandler);
                        }
                    }
                }
                this.send_data_message = new WialonIPS.DataMessage(time, lat, lon, alt, speed, heading, sats,
                                                                   dev.HDOP, dev.IButton, dev.Alarm, dev.Inputs, dev.Outputs, dev.Adcs, dev.CustomParameters);
            }
            else
            {
                // short data packet
                this.send_data_message = new WialonIPS.ShortDataMessage(time, lat, lon, alt, speed, heading, sats);
            }
            if (this.send_data_message != null)
            {
                this.tbResultPacket.Text = this.send_data_message.GetTextData();
            }
        }
Esempio n. 5
0
        private void UpdateDataPacketText(DateTime time)
        {
            this.send_data_message = null;
            double? lat = null, lon = null;
            int? alt = null;
            UInt16? speed = null;
            UInt16? heading = null;
            byte? sats = null;
            double dvalue = 0;
            int ivalue = 0;
            UInt16 uivalue = 0;
            byte bvalue = 0;
            if (double.TryParse(this.tbLat.Text, out dvalue)) lat = dvalue;
            if (double.TryParse(this.tbLon.Text, out dvalue)) lon = dvalue;
            if (int.TryParse(this.tbAlt.Text, out ivalue)) alt = ivalue;
            if (UInt16.TryParse(this.tbSpeed.Text, out uivalue)) speed = uivalue;
            if (UInt16.TryParse(this.tbHeading.Text, out uivalue)) heading = uivalue;
            if (byte.TryParse(this.tbSats.Text, out bvalue)) sats = bvalue;

            var dev = (this.cbDevice.SelectedItem as DeviceInfo);
            dev.Latitude = lat;
            dev.Longitude = lon;
            dev.Altitude = alt;
            dev.Speed = speed;
            dev.Heading = heading;
            dev.Sats = sats;

            if (this.rbFullData.Checked)
            {
                // full data packet
                dev.HDOP = WialonIPS.Message.ParseDouble(this.tbHdop.Text);
                if (this.cbiButtonEnabled.Checked)
                    dev.IButton = this.tbIButton.Text;
                else
                    dev.IButton = "NA";
                dev.Alarm = this.cbAlarm.Checked;
                dev.Inputs = this.ioInputs.Value;
                dev.Outputs = this.ioOutputs.Value;
                if (this._adc_params.Length > 0)
                {
                    dev.Adcs = new double[this._adc_params.Length];
                    for (var i = 0; i < dev.Adcs.Length; i++)
                    {
                        if (this._adc_params[i] != null)
                        {
                            double val = 0;
                            if (double.TryParse(this._adc_params[i].Text.Text, out val))
                                dev.Adcs[i] = val;
                        } else
                            dev.Adcs[i] = 0;
                    }
                } else
                    dev.Adcs = null;
                if (dev.CustomParameters != null) {
                    for (var i = 0; i < dev.CustomParameters.Length; i++)
                    {
                        var text = this._custom_params[i].Value.Text;
                        if (((CustomParamType)this._custom_params[i].Type.SelectedItem) == CustomParamType.Double)
                            text = text.Replace(',', '.');
                        dev.CustomParameters[i] = new CustomParameter(
                            this._custom_params[i].Name.Text,
                            (CustomParamType)this._custom_params[i].Type.SelectedItem,
                            text);
                        if (dev.CustomParameters[i].Name == "SOS" && dev.CustomParameters[i].Type == CustomParamType.Int)
                        {
                            dev.Alarm = (dev.CustomParameters[i].Value == "1");
                            this.cbAlarm.CheckedChanged -= this.UpdateCurrentPacketDataHandler;
                            this.cbAlarm.Checked = dev.Alarm;
                            this.cbAlarm.CheckedChanged += new EventHandler(this.UpdateCurrentPacketDataHandler);
                        }
                    }
                }
                this.send_data_message = new WialonIPS.DataMessage(time, lat, lon, alt, speed, heading, sats,
                    dev.HDOP, dev.IButton, dev.Alarm, dev.Inputs, dev.Outputs, dev.Adcs, dev.CustomParameters);
            } else
            {
                // short data packet
                this.send_data_message = new WialonIPS.ShortDataMessage(time, lat, lon, alt, speed, heading, sats);
            }
            if (this.send_data_message != null)
                this.tbResultPacket.Text = this.send_data_message.GetTextData();
        }