Пример #1
0
        //取得最近五分鐘資料
        private void getLast5VD_Data()
        {
            System.DateTime dt = System.DateTime.Now.AddMinutes(-4);
               System.Data.DataSet ds;
               for (int i = 0; i < 5; i++)
               {

               byte[] sendData = new byte[] { 0x15, (byte)dt.Day, (byte)dt.Hour,(byte) dt.Minute };
               try
               {
                  SendPackage pkg;

                   this.m_device.Send(pkg=new SendPackage(CmdType.CmdQuery, CmdClass.A, 0xffff, sendData));
                   if (pkg.result == CmdResult.ACK)
                   {
                       ds = m_protocol.GetReturnDsByTextPackage(pkg.ReturnTextPackage);
                       OneMinDataStore.inData(getOneMinAvgData(ds));

                   }
                   else
                   {
                       ConsoleServer.WriteLine(pkg.result.ToString() + pkg.ToString());
                   }

               }
               catch (Exception ex)
               {
                   ConsoleServer.WriteLine(ex.Message + ex.StackTrace);
               }

               dt = dt.AddMinutes(1);

               }

               VD_MinAvgData fiveMinData = this.OneMinDataStore.getFiveMinMovingAvgData();
               ConsoleServer.WriteLine("five min avg:" + fiveMinData.ToString());
               if (this.OnFiveMinAvgData != null)
               this.OnFiveMinAvgData(this, fiveMinData);
        }