示例#1
0
 private void ParseCmd(Pack pack)
 {
     
 }
示例#2
0
        private void ParseData(Pack pack)
        {
            var arr = new int[4];
          
            var barr = pack.Data.ToArray();
          //  arr = pack.Data.ToArray();
            for (int i = 0, j = 0; i < 4; i++, j += 2)
            {
                arr[i] = BitConverter.ToInt16(barr, j);
                arr[i] >>= 1;

            /*  if (ExchangeConfig.CorrectRxMistakes)
               {
                   if (arr[i] < 0x0F)
                       arr[i] = arr_prev[i];
                   else 
                       arr_prev[i] = arr[i];
                  
               }*/

              var vl = (arr[i] * 5.09 / 1024);
               
              if(ExchangeConfig.FilterType==InputFilterType.AlphaBeta)
                 vl = ExchangeConfig.AlphaBetaKoefs[i] * vl + (1 - ExchangeConfig.AlphaBetaKoefs[i]) * vl_prev[i];

              
                vl_prev[i] = vl;

                if (_zeroCorrection)
                {
                    if (Math.Abs(vl - zeroAdcVals[i]) < 0.06)
                        vl = 0.0;
                    else if (vl > zeroAdcVals[i])
                        vl -= zeroAdcVals[i];
                }

                if(ExchangeConfig.CorrectRxMistakes)
                    vl = Math.Round(vl, 2);

                CurrAdcVals[i] = vl;
      
                WeightDoubles[i] = CurrAdcVals[i]*WeightKoefs[i]; 

            }
         }
示例#3
0
 protected override void Parse(Pack pack)
 {
     switch (_mode)
     {
      case StabilityParseMode.ParseData:
         ParseData(pack);
      break;
      case StabilityParseMode.ParseCmd:
         ParseCmd(pack);
       break;
     }
     if(ParseDone != null)
         ParseDone.Invoke(this,null);//BeginInvoke(this, null, null, null);
 }
示例#4
0
 /// <summary>
 /// Выполняет отправку данных по интрефейсу RS232
 /// </summary>
 public void SendData(Pack p)
 {
     SendData(p.Data.ToArray());
 }
示例#5
0
        private void RxThreadHandler(object ev)
        {
           var stopEvent = (ManualResetEvent)ev;
           while (stopEvent.WaitOne())
            {              
             if (_rxBuf.Count > 0)       //Если в буфере есть данные
             {
                 Pack pack;
                 if (UseSLIP)
                     pack = SlipParser(); // то прогоняем их через SLIP протокол
                 else
                 {
                     pack = new Pack(_rxBuf.GetRange(0,_threshold));
                     _rxBuf.RemoveRange(0,_threshold);
                 }

                  if (pack != null)
                   {
                    RxData.Enqueue(new Pack(pack.Data));   //Суем пакет в выходную очередь
                       if (RxEvent != null)
                          RxEvent.Invoke(this, null); //Дергаем Event   
                           
                           
                   }
                }
                
               Thread.Sleep(20);
            }
        }
示例#6
0
 protected virtual void Parse(Pack p)
 {
     throw new NotImplementedException();
 }