예제 #1
0
 public DataMessage(string content) : this()
 {
     //    0    1    2    3    4    5    6     7      8      9    10   11     12      13  14      15
     // #D#date;time;lat1;lat2;lon1;lon2;speed;course;height;sats;hdop;inputs;outputs;adc;ibutton;params\r\n
     this.Success = false;
     if (this.InitFromString(content))
     {
         double[]          adcs          = null;
         CustomParameter[] custom_params = null;
         bool alarm     = false;
         var  adc_items = this._items[13].Split(',');
         if (adc_items.Length > 0)
         {
             adcs = new double[adc_items.Length];
             for (var i = 0; i < adc_items.Length; i++)
             {
                 double?val = ParseDouble(adc_items[i]);
                 if (val.HasValue)
                 {
                     adcs[i] = val.Value;
                 }
                 else
                 {
                     adcs[i] = 0;
                 }
             }
         }
         var cp_items = this._items[15].Split(',');
         if (cp_items.Length > 0)
         {
             custom_params = new CustomParameter[cp_items.Length];
             for (var i = 0; i < cp_items.Length; i++)
             {
                 var cp = CustomParameter.Parse(cp_items[i]);
                 custom_params[i] = cp;
                 if (cp.Name == "SOS" && cp.Type == CustomParamType.Int && cp.Value == "1")
                 {
                     alarm = true;
                 }
             }
         }
         this.InitFull(ParseDouble(this._items[10]),
                       this._items[14],
                       alarm,
                       ParseUInt32(this._items[11]),
                       ParseUInt32(this._items[12]),
                       adcs,
                       custom_params);
     }
 }
예제 #2
0
 public CustomParameter(CustomParameter source) : this(source.Name, source.Type, source.Value)
 {
 }