예제 #1
0
        public override sealed void OnReceiveText(TextPackage text)
        {
            if (text.Cmd == 0x28)
               DoGetPeriodData(text);
               else // pass to children
               OnSSHDDataController_ReceiveText(text);

               //throw new NotImplementedException();
        }
예제 #2
0
		/// <summary>Loads external CSS if a href is available and it's known to be css.</summary>
		public void LoadContent(){
			if(!IsCSS || string.IsNullOrEmpty(Href) || StyleIndex!=-1){
				return;
			}
			
			// Let's go get it!
			// The style index makes sure that this style is loaded into this position relative to other style on the page:
			StyleIndex=Element.Document.GetStyleIndex();
			TextPackage package=new TextPackage(Href,Element.Document.basepath);
			package.Get(OnTextReady);
		}
예제 #3
0
        /// <summary>Loads external CSS if a href is available and it's known to be css.</summary>
        public void LoadContent()
        {
            if (!IsCSS || string.IsNullOrEmpty(Href) || StyleIndex != -1)
            {
                return;
            }

            // Let's go get it!
            // The style index makes sure that this style is loaded into this position relative to other style on the page:
            StyleIndex = Element.Document.GetStyleIndex();
            TextPackage package = new TextPackage(Href, Element.Document.basepath);

            package.Get(OnTextReady);
        }
예제 #4
0
        /// <summary>The callback for the request to get the external style.</summary>
        /// <param name="package">The text package containing the style if the request was ok.</param>
        private void OnTextReady(TextPackage package)
        {
            if (Element.Document == null || StyleIndex < 0)
            {
                return;
            }
            // The element is still somewhere on the UI.
            string style = "";

            if (package.Ok)
            {
                // Grabbed it okay.
                style = package.Text;
            }
            Element.Document.AddStyle(style, StyleIndex);
            StyleIndex = -1;
        }
예제 #5
0
        /// <summary>
        /// 发送信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSend_Click(object sender, EventArgs e)
        {
            //组织发送文本报文
            var textPackage = new TextPackage()
            {
                Message = txbSend.Text
            };
            //定义格式化器
            var formater = new BinaryFormatter();

            //序列化到网络流,即发送信息
            formater.Serialize(_stream, textPackage);
            //历史信息显示
            txbHis.Text += "自己说:" + txbSend.Text + "\r\n";
            //清空发送文本框
            txbSend.Clear();
        }
예제 #6
0
파일: WISTC.cs 프로젝트: ufjl0683/Center
        void WISTC_OnTCReport(object tc, TextPackage txt)
        {
            #if DEBUG
              ////WIS-T78-E-26.9
              //if ((tc as TCBase).DeviceName != "WIS-T78-E-26.9")
              //    return;
            #endif
              if (txt.Text[0] == 0xdf && txt.Text[1] == 0xda)
              {

              System.Data.DataSet ds = this.m_protocol.GetSendDsByTextPackage(txt,CmdType.CmdReport);
              this.InvokeOutPutWrongEvent(GetDisplayDesc(currentDispalyDataset),GetDisplayDesc(ds));

              }

              //throw new Exception("The method or operation is not implemented.");
        }
예제 #7
0
파일: VDTC.cs 프로젝트: ufjl0683/Center
        // 主動回報事件
        void VDTC_OnTCReport(object tc, TextPackage txt)
        {
            //throw new Exception("The method or operation is not implemented.");
               System.Data.DataSet ds=null;

               if (txt.Text[0] == 0x10) //cycle data
               {
                   try
                   {
                       ds=m_protocol.GetReturnDsByTextPackage(txt);
                        VD_MinAvgData data= getOneMinAvgData(ds);
                       OneMinDataStore.inData(data);

                       VD_MinAvgData fiveMinData = this.OneMinDataStore.getFiveMinMovingAvgData();

                       if (this.OnFiveMinAvgData != null)
                           this.OnFiveMinAvgData(this, fiveMinData);

                       ConsoleServer.WriteLine("Five min AVG:" + fiveMinData.ToString());

                   }
                   catch (Exception ex)
                   {
                       ConsoleServer.WriteLine(ex.Message);
                   }
               }
               else  if(txt.Cmd==0x17) // 20 sec 事件資料
               {
                  ConsoleServer.WriteLine(txt.ToString());
                  try
                  {
                      ds = m_protocol.GetReturnDsByTextPackage(txt);
                      //if (this.OnRealTimeData != null)
                      //    this.OnRealTimeData(this, ds);
                  }
                  catch (Exception ex)
                  {
                      ConsoleServer.WriteLine(ex.Message + "\r\n" + ex.StackTrace);
                  }
              }

              else if (txt.Cmd == 0x18)  //現點速率
              {
                  ConsoleServer.WriteLine(txt.ToString());
                  try
                  {
                      ds = m_protocol.GetReturnDsByTextPackage(txt);
                      if (this.OnRealTimeData != null)
                          this.OnRealTimeData(this, ds);
                  }
                  catch (Exception ex)
                  {
                      ConsoleServer.WriteLine("現點速率:"+ex.Message + "\r\n" + ex.StackTrace);
                  }
              }
        }
예제 #8
0
파일: MFCC_Base.cs 프로젝트: ufjl0683/sshmc
 //public void RemoveCommMoniterRegist(TCBase tc)
 //{
 //    try
 //    {
 //        tc.m_device.OnAck -= new OnAckEventHandler(m_device_OnAck);
 //        tc.m_device.OnBeforeAck -= new OnSendingAckNakHandler(m_device_OnBeforeAck);
 //        tc.m_device.OnSendingPackage -= new OnSendPackgaeHandler(m_device_OnSendingPackage);
 //        tc.m_device.OnReceiveText -= new OnTextPackageEventHandler(m_device_OnReceiveText);
 //        tc.m_device.OnNak -= new OnNakEventHandler(m_device_OnNak);
 //    }
 //    catch { ;}
 //}
 void m_device_OnReceiveText(object sender, TextPackage txtObj)
 {
     try
       {
       this.notifier.NotifyAll(new NotifyEventObject(EventEnumType.MFCC_Comm_Moniter_Event, ((Comm.I_DLE)sender).getDeviceName(),
            "\t" + DateTime.Now.ToLongTimeString() + "," + txtObj.ToString() + "<=="));
       }
       catch (Exception ex){
       ConsoleServer.WriteLine(ex.Message+","+ex.StackTrace);
       ;}
       //throw new Exception("The method or operation is not implemented.");
 }
예제 #9
0
파일: RDTC.cs 프로젝트: ufjl0683/Center
        void RDTC_OnTCReport(object tc, TextPackage txt)
        {
            // throw new Exception("The method or operation is not implemented.");
            try{
                if (txt.Text[0] == 0x48   )   // cycle data  主動回報
                {

                    if (txt.Text.Length != 13)
                    {
                        ConsoleServer.WriteLine(this.DeviceName + "," + txt.ToString() + ",長度不符");
                        return;
                    }

                    System.DateTime dt = new DateTime(System.DateTime.Now.Year, System.DateTime.Now.Month, txt.Text[6], txt.Text[7], txt.Text[8], 0);

                    curr_amount = (txt.Text[9] == 255) ? -1 : txt.Text[9];
                    curr_acc_amount = (txt.Text[10] * 256 + txt.Text[11] == 65535) ? -1 : txt.Text[10] * 256 + txt.Text[11];
                    curr_degree = (txt.Text[12] == 255) ? -1 : txt.Text[12];
                    last_receive_time = dt;

                    if (On_RD_FivceMinData != null)
                        this.On_RD_FivceMinData(this, dt, curr_amount, curr_acc_amount, curr_degree,(txt.Text[1]==0)?1:0);
                }
                else  if(txt.Text[0]==0x4a)
                {
                    System.DateTime dt = new DateTime(System.DateTime.Now.Year, System.DateTime.Now.Month, txt.Text[6], txt.Text[7], txt.Text[8], 0);
                    if(this.On_DegreeChange!=null)
                        On_DegreeChange(this, txt.Text[1],dt, txt.Text[9], txt.Text[10]);

                }

               }

             catch(Exception ex)
                 {
                    ConsoleServer.WriteLine(this.DeviceName+","+ex.Message);
                 }
               //  this.dbServer.SendSqlCmd(string.Format(sql,  txt.Text[9], txt.Text[10] * 256 + txt.Text[11], txt.Text[12], tc.DeviceName, Comm.DB2.Db2.getTimeStampString(dt)));
        }
예제 #10
0
 CmdResult GetCmdResult(TextPackage pkg)
 {
     if (pkg.GetErrBit(V2DLE.DLE_ERR_LCR))
         return CmdResult.LRC_ERR;
     else if (pkg.GetErrBit(V2DLE.DLE_ERR_FRAME))
         return CmdResult.Frame_ERR;
     else if (pkg.GetErrBit(V2DLE.DLE_ERR_CMD_ERR))
         return CmdResult.Cmd_Invalid;
     else if (pkg.GetErrBit(V2DLE.DLE_ERR_CMD_PARAM_OVERRANGE))
         return CmdResult.Param_OverRange;
     else if (pkg.GetErrBit(V2DLE.DLE_ERR_CMD_FAIL))
         return CmdResult.Cmd_Fail;
     else
         return CmdResult.Unknown;
 }
예제 #11
0
파일: WDTC.cs 프로젝트: ufjl0683/Center
        void WDTC_OnTCReport(object tc, TextPackage txt)
        {
            //throw new Exception("The method or operation is not implemented.");

              // throw new Exception("The method or operation is not implemented.");
              try
              {
                  if (txt.Text[0] == 0x28  )   // cycle data  and 主動回報
                  {

                      System.DateTime dt = new DateTime(System.DateTime.Now.Year, System.DateTime.Now.Month, txt.Text[6], txt.Text[7], txt.Text[8], 0);

                     //urr_amount = (txt.Text[9] == 255) ? -1 : txt.Text[9];
                      this.curr_average_wind_speed=(txt.Text[9] == 255) ? -1 : txt.Text[9];
                      this.curr_average_wind_direction = (txt.Text[10] == 255) ? -1 : txt.Text[10];
                      this.curr_max_wind_speed = (txt.Text[11] == 255) ? -1 : txt.Text[11];
                      this.curr_max_wind_direction = (txt.Text[12] == 255) ? -1 : txt.Text[12];
                      this.curr_degree = (txt.Text[13] == 255) ? -1 : txt.Text[13];
                      last_receive_time = dt;

                      if (On_WD_CycleData != null)
                          this.On_WD_CycleData(this, dt, curr_average_wind_speed,curr_average_wind_direction,curr_max_wind_speed,curr_max_wind_direction,  curr_degree,txt.Text[1]==0?1:0);
                  }
                  else if(txt.Text[0]==0x2a)
                  {
                      int avgwindspd, avgwinddir, maxwindspd, maxwindir, amdegree;

                      avgwindspd = txt.Text[9];
                      avgwinddir = txt.Text[10];
                      maxwindspd = txt.Text[11];
                      maxwindir = txt.Text[12];
                      amdegree = txt.Text[13];
                      if (this.On_DegreeChange != null)
                          this.On_DegreeChange(this,txt.Text[1] , System.DateTime.Now, avgwindspd, avgwinddir, maxwindspd, maxwindir, amdegree);
                  }
              }
              catch (Exception ex)
              {
                  ConsoleServer.WriteLine(this.DeviceName + "," + ex.Message);
              }
              //  this.dbServer.SendSqlCmd(string.Format(sql,  txt.Text[9], txt.Text[10] * 256 + txt.Text[11], txt.Text[12], tc.DeviceName, Comm.DB2.Db2.getTimeStampString(dt)));
        }
예제 #12
0
파일: LCSTC.cs 프로젝트: ufjl0683/Center
        void LCSTC_OnTCReport(object tc, TextPackage txt)
        {
            #if DEBUG

              //if ((tc as TCBase).DeviceName != "LCS-T72-E-29.94")
              //    return;
            #endif

              if (txt.Text[0] == 0xc3)
              {
              System.Data.DataSet ds = m_protocol.GetSendDsByTextPackage(txt, CmdType.CmdReport);

              this.InvokeOutPutWrongEvent(GetDisplayDecs(currDisplayds),GetDisplayDecs(ds));
              }
              //throw new Exception("The method or operation is not implemented.");
        }
예제 #13
0
파일: VDTC.cs 프로젝트: ufjl0683/Center
        // 主動回報事件
        void VDTC_OnTCReport(object tc, TextPackage txt)
        {
            System.Data.DataSet ds=null;

               if (txt.Text[0] == 0x10  ) //cycle data 1 min cycle
               {
                   try
                   {
                       ds=m_protocol.GetSendDsByTextPackage(txt,CmdType.CmdReport);
                       ds.AcceptChanges();
                       if (true/*System.Convert.ToInt32(ds.Tables[0].Rows[0]["response_type"]) == 0 || System.Convert.ToInt32(ds.Tables[0].Rows[0]["response_type"]) == 4*/)
                       {

                           VD_MinAvgData data = getOneMinAvgData(ds,System.DateTime.Now.Year,System.DateTime.Now.Month);
                           curr_1_min_data = data;
                           if (dtlast0x10 != data.dateTime)
                                OneMinDataStore.inData(data);

                         // if(dtlast0x10!=data.dateTime)
                           VD_MinAvgData fiveMinData = this.OneMinDataStore.getFiveMinMovingAvgData();

                           if (this.OnFiveMinAvgData != null)
                               try
                               {
                                   this.OnFiveMinAvgData(this, fiveMinData);
                               }
                               catch (Exception ex)
                               {
                                   ConsoleServer.WriteLine(this.DeviceName+ex.Message+ex.StackTrace);
                               }
                           if (this.On1MinTrafficData != null)
                               try
                               {
                                   if (dtlast0x10 != data.dateTime)
                                       this.On1MinTrafficData(this, data);
                                   else
                                       ConsoleServer.WriteLine(this.DeviceName+"1min data repeat!");

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

                           dtlast0x10 = data.dateTime;
                           // 顯示取得最近1分鐘資料
                        //   ConsoleServer.WriteLine(this.DeviceName + " " + "Five min AVG:" + fiveMinData.ToString());
                       }

                   }
                   catch (Exception ex)
                   {
                       ConsoleServer.WriteLine(this.DeviceName+" "+"Five min AVG"+ex.Message);
                   }
               }
               else  if(txt.Cmd==0x17) // 20 sec 事件資料
               {
                //  ConsoleServer.WriteLine(txt.ToString());
                  try
                  {
                      ds = m_protocol.GetSendDsByTextPackage(txt, CmdType.CmdReport);
                      ds.AcceptChanges();
                      if (this.On20SecEvent != null)
                          this.On20SecEvent(this, getOneMinAvgData(ds, System.DateTime.Now.Year, System.DateTime.Now.Month));
                      //if (this.OnRealTimeData != null)
                      //    this.OnRealTimeData(this, ds);
                  }
                  catch (Exception ex)
                  {
                      ConsoleServer.WriteLine(this.DeviceName+" "+" 20 sec 事件資料"+ex.Message + "\r\n" + ex.StackTrace);
                  }
              }

              else if (txt.Cmd == 0x18)  //現點速率
              {

                  try
                  {
                      ConsoleServer.WriteLine(txt.ToString());
                      if (System.DateTime.Now >= m_realEventEndTime)
                      {
                          ConsoleServer.WriteLine(this.DeviceName + "關閉現點速率");
                          //this.Tc_SetRealData(0);
                          AsyncSend(new SendPackage(CmdType.CmdSet,CmdClass.B,0xffff,new byte[]{0x11,00}));
                          return;
                      }
                      ds = m_protocol.GetSendDsByTextPackage(txt, CmdType.CmdReport);
                      ds.AcceptChanges();
                      if (this.OnRealTimeData != null)
                          this.OnRealTimeData(this, ds);
                  }
                  catch (Exception ex)
                  {
                      ConsoleServer.WriteLine(this.DeviceName+" "+"現點速率:"+ex.Message + "\r\n" + ex.StackTrace);
                  }
              }
              else if (txt.Cmd == 0x1a)  //觸動事件
              {
                  try
                  {
                      ds = m_protocol.GetSendDsByTextPackage(txt, CmdType.CmdReport);
                      ds.AcceptChanges();
                      if (this.OnTriggerEvent != null)
                          this.OnTriggerEvent(this, ds);
                  }
                  catch (Exception ex)
                  {
                      ConsoleServer.WriteLine(this.DeviceName+" "+"觸動事件:" + ex.Message + "\r\n" + ex.StackTrace);
                  }
              }
        }
예제 #14
0
파일: CSLSTC.cs 프로젝트: ufjl0683/Center
        void CSLSTC_OnTCReport(object tc, TextPackage txt)
        {
            #if DEBUG
              //if ((tc as TCBase).DeviceName != "CSLS-N6-E-17.5")
              //    return;
            #endif
              if (txt.Text[0] == 0xb5)
              {
              if (currDisplayds == null && txt.Text[1] == 0xff)
              {
                  this.InvokeOutPutWrongEvent("255", txt.Text[1].ToString());
                  return;
              }

              this.InvokeOutPutWrongEvent(currDisplayds.Tables[0].Rows[0]["speed"].ToString(), txt.Text[1].ToString());

              }

              //throw new Exception("The method or operation is not implemented.");
        }
예제 #15
0
파일: CSLSTC.cs 프로젝트: ufjl0683/Center
 void CSLSTC_OnTCReceiveText(object tc, TextPackage txt)
 {
     //throw new Exception("The method or operation is not implemented.");
       if (txt.Text[0] == 0xb1)
       CSLS_LedTest_Report(txt.Text, this.DeviceName);
 }
예제 #16
0
 public abstract void OnReceiveText(TextPackage text);
예제 #17
0
파일: VITC.cs 프로젝트: ufjl0683/Center
        void VITC_OnTCReport(object tc, TextPackage txt)
        {
            try
              {
                  if (txt.Text[0] == 0x20 )   // cycle data  and 主動回報
                  {

                      System.DateTime dt = new DateTime(System.DateTime.Now.Year, System.DateTime.Now.Month, txt.Text[6], txt.Text[7], txt.Text[8], 0);

                     //urr_amount = (txt.Text[9] == 255) ? -1 : txt.Text[9];
                      curr_distance=(txt.Text[9] * 256 + txt.Text[10] == 65535) ? -1 : txt.Text[9] * 256 + txt.Text[10];
                      curr_degree = (txt.Text[11] == 255) ? -1 : txt.Text[11];
                      last_receive_time = dt;

                      if (On_VI_FivceMinData != null)
                          this.On_VI_FivceMinData(this, dt, curr_distance,  curr_degree,txt.Text[1]==0?1:0);
                  }
                  else if (txt.Text[0] == 0x22 )
                  {
                      System.DateTime dt = new DateTime(System.DateTime.Now.Year, System.DateTime.Now.Month, txt.Text[6], txt.Text[7], txt.Text[8], 0);
                      int distance = (txt.Text[9] * 256 + txt.Text[10] == 65535) ? -1 : txt.Text[9] * 256 + txt.Text[10];
                      int degree = (txt.Text[11] == 255) ? -1 : txt.Text[11];
                      if (this.On_DegreeChange != null)
                          this.On_DegreeChange(this,txt.Text[1], dt, distance, degree);
                  }
              }
              catch (Exception ex)
              {
                  ConsoleServer.WriteLine(this.DeviceName + "," + ex.Message);
              }
              //  this.dbServer.SendSqlCmd(string.Format(sql,  txt.Text[9], txt.Text[10] * 256 + txt.Text[11], txt.Text[12], tc.DeviceName, Comm.DB2.Db2.getTimeStampString(dt)));
        }
예제 #18
0
        private TextPackage ReadText()
        {
            int Seq=0,Address=0,Len=0,LRC=0,HeadLRC=0;
            byte[] text=null;
            TextPackage textPackage = new TextPackage();
            Seq = ReadByte(stream);
            Address = ReadByte(stream) * 256;
            Address+= ReadByte(stream);
            Len = ReadByte(stream) * 256;
            Len += ReadByte(stream);
            HeadLRC = ReadByte(stream);
            textPackage.Seq = Seq;
            textPackage.Address = Address;
              //  textPackage.LRC = HeadLRC;

            if (HeadLRC != (((Address >> 8) & 0x00ff) ^ (Address & 0x00ff) ^ ((Len >> 8) & 0x00ff) ^ (Len & 0x00ff)))
            {
              // textPackage.HasErrors = true;
                textPackage.SetErrBit(V2DLE.DLE_ERR_FRAME, true);
                textPackage.eErrorDescription += "Hearder LRC Error!\r\n";
                //Console.WriteLine("Hearder LRC Error!");
                return textPackage;
            }
            else
            {

                text = new byte[Len];
                int rlen = 0;

                do
                {
                    rlen+=stream.Read(text,rlen, Len-rlen);

                } while (rlen != Len);
                //for (int i = 0; i < Len; i++)
                //    text[i] = (byte)stream.ReadByte();

                //if (rlen != Len)
                //   Console.WriteLine("rLen={0}!=len={1}",rlen,Len);

                LRC=DLE ^ SOH ^ Seq ;
                for (int i = 0; i < text.Length; i++)
                    LRC ^= text[i];

                int tmp = ReadByte(stream);
                if (LRC !=tmp)// stream.ReadByte())
                {
                    textPackage.SetErrBit(V2DLE.DLE_ERR_LCR, true);
                    textPackage.eErrorDescription += "LRC Error!\r\n";
                    textPackage.Text = text;
                    Console.WriteLine("LRC Error!"+"==>"+ textPackage.ToString());
                    return textPackage;
                }
                else
                {
                   textPackage.Text=text;
                   textPackage.LRC = LRC;
                   return textPackage;

                }

            }
        }
예제 #19
0
 public abstract void OnSSHDDataController_ReceiveText(TextPackage text);
예제 #20
0
        void tcbase_OnTCReport(object tc, TextPackage txt)
        {
            if (txt.Text[0] == 0x29) //cycle report
              {
            DataSet ds  = this.protocol.GetSendDsByTextPackage(txt, CmdType.CmdReport);
            int day, hour, min;
            day =System.Convert.ToInt32( ds.Tables[0].Rows[0]["day"]);
            hour = System.Convert.ToInt32(ds.Tables[0].Rows[0]["hour"]);
            min = System.Convert.ToInt32(ds.Tables[0].Rows[0]["minute"]);
            int sensor_cnt = System.Convert.ToInt32(ds.Tables[0].Rows[0]["sensor_cnt"]);
            int value_cnt= System.Convert.ToInt32(ds.Tables[0].Rows[0]["value_cnt"]);
            DateTime timestamp=new DateTime(DateTime.Now.Year,DateTime.Now.Month,day,hour,min,0);
              //  int maxdegree = 0;
            for (int i = 0; i < sensor_cnt; i++)
            {
                double value0, value1, value2;
                value0 =Comm.V2DLE.uLongToDouble( System.Convert.ToUInt64( ds.Tables[1].Rows[i]["value0"]));
                value1 = Comm.V2DLE.uLongToDouble(System.Convert.ToUInt64(ds.Tables[1].Rows[i]["value1"]));
                value2 = Comm.V2DLE.uLongToDouble(System.Convert.ToUInt64(ds.Tables[1].Rows[i]["value2"]));
                int degree = System.Convert.ToInt32(ds.Tables[1].Rows[i]["degree"]);

                string isvalid=(System.Convert.ToInt32(ds.Tables[1].Rows[i]["is_valid"])==1)?"Y":"N";
                int execution_mode = 0;
                string sql = "insert into tbltc10mindatalog values({0},'{1}',{2},{3},{4},{5},'{6}',{7},{8},{9},'{10}')";
                dbServer.SendSqlCmd(
                    string.Format(sql, (tc as TCBase).sensor_ids[i], DbCmdServer.getTimeStampString(timestamp), value0, value1, value2, degree, isvalid, execution_mode, (tc as TCBase).DeviceName, value_cnt,'N'));

                sql=string.Format("update tblsensor set current_degree={0},value0={1},value1={2},value2={3}  ,ISVALID='{5}' where sensor_id={4}",degree,value0,value1,value2,(tc as TCBase).sensor_ids[i],isvalid);

                dbServer.SendSqlCmd(sql);

                sql = string.Format("update tblTC_Restore set trycnt=trycnt+1,isfinsh='Y' where controller_id={0} and timestamp='{1}'", (tc as TCBase).DeviceName, DbCmdServer.getTimeStampString(timestamp));
                dbServer.SendSqlCmd(sql);
                if (r_host_comm != null   &&  isvalid=="Y")
                {
                    try
                    {
                        r_host_comm.SetSensorValueDegree(System.Convert.ToInt32((tc as TCBase).sensor_ids[i]), value0, value1, value2, degree);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message + "," + ex.StackTrace);
                    }
                }
            }

              Console.WriteLine("cyclic report!");
              }
        }
예제 #21
0
파일: LSTC.cs 프로젝트: ufjl0683/Center
        void LSTC_OnTCReport(object tc, TextPackage txt)
        {
            try
              {
                  if (txt.Text[0] == 0x30  )   // cycle data  and 主動回報
                  {

                      System.DateTime dt = new DateTime(System.DateTime.Now.Year, System.DateTime.Now.Month, txt.Text[6], txt.Text[7], txt.Text[8], 0);

                      last_receive_time = dt;

                      DataSet ds0x30=m_protocol.GetSendDsByTextPackage(txt,CmdType.CmdReport);
                     // this.currData = ds0x30;
                      curr_day_var = System.Convert.ToInt32( ds0x30.Tables[0].Rows[0]["day_var"]);
                      curr_day_var = System.Convert.ToInt32( ds0x30.Tables[0].Rows[0]["mon_var"]);

                      if (On_LS_CycleData != null)
                          this.On_LS_CycleData((LSTC)tc,dt, ds0x30);
                  }

                  else if (txt.Text[0] == 0x32)  //event
                  {
                      System.DateTime dt = new DateTime(System.DateTime.Now.Year, txt.Text[6], txt.Text[7], txt.Text[8], txt.Text[9], 0);
                      DataSet ds0x32 = m_protocol.GetSendDsByTextPackage(txt, CmdType.CmdReport);
                      // this.currData = ds0x30;
                     // curr_day_var = System.Convert.ToInt32(ds0x32.Tables[0].Rows[0]["day_var"]);
                      //curr_day_var = System.Convert.ToInt32(ds0x32.Tables[0].Rows[0]["mon_var"]);
                      if (this.On_DegreeChange != null)
                          this.On_DegreeChange(this, dt, ds0x32);

                  }
              }
              catch (Exception ex)
              {
                  ConsoleServer.WriteLine(this.DeviceName + "," + ex.Message);
              }
              //  this.dbServer.SendSqlCmd(string.Format(sql,  txt.Text[9], txt.Text[10] * 256 + txt.Text[11], txt.Text[12], tc.DeviceName, Comm.DB2.Db2.getTimeStampString(dt)));
        }
예제 #22
0
파일: TTSTC.cs 프로젝트: ufjl0683/Center
        void TTSTC_OnTCReport(object tc, TextPackage txt)
        {
            // TTS-N1-S-248.2

            #if DEBUG

              if ((tc as TCBase).DeviceName != "TTS-N1-N-216.7")
                  return;

            #endif
              if (txt.Text[0] == 0x5f && txt.Text[1] == 0x1a)
              {

                  try
                  {
                      lock (this.currDispLockObj)
                      {
                          byte[][] data = new byte[3][];

                          for (int i = 0; i < 3; i++)
                          {
                              data[i] = new byte[4];
                              System.Array.Copy(currDisplayBytes[i], data[i], 4);

                          }

                          int position = txt.Text[2];
                          data[position - 1][0] = txt.Text[10];
                          data[position - 1][1] = txt.Text[11];
                          data[position - 1][2] = txt.Text[12];

                          this.InvokeOutPutWrongEvent(GetCurrentDisplayDecs(), GetDisplayDesc(data));
                      }
                  }
                  catch
                  {
                      ;
                  }

              }

              //throw new Exception("The method or operation is not implemented.");
        }
예제 #23
0
		/// <summary>The callback for the request to get the external style.</summary>
		/// <param name="package">The text package containing the style if the request was ok.</param>
		private void OnTextReady(TextPackage package){
			if(Element.Document==null || StyleIndex<0){
				return;
			}
			// The element is still somewhere on the UI.
			string style="";
			if(package.Ok){	
				// Grabbed it okay.
				style=package.Text;
			}
			Element.Document.AddStyle(style,StyleIndex);
			StyleIndex=-1;
		}
예제 #24
0
 /// <summary>
 /// 处理文本报文
 /// </summary>
 /// <param name="textPackage"></param>
 private void HandleText(TextPackage textPackage)
 {
     txbHis.Text += "对方说:" + textPackage.Message + "\r\n";
 }
예제 #25
0
파일: MFCC_Base.cs 프로젝트: ufjl0683/sshmc
        void tc_OnTCReport(object tc, TextPackage txt)
        {
            //throw new Exception("The method or operation is not implemented.");
              if (txt.Text[0] == 0x07)
              {

              try
              {
                //  if (r_host_comm == null) return;
                 this.notifier.NotifyAll(new NotifyEventObject( EventEnumType.TC_Manual_Ask_Event,((TCBase)tc).DeviceName,txt.Text[1]));
              }
              catch (Exception ex)
              {
                  ConsoleServer.WriteLine(ex.Message + "," + ex.StackTrace);
              }

              }
              else if (txt.Text[0] == 0x0b)
              {
              //for(int i=0;i< (tc as TCBase).sensor_ids.Length;i++)
              //{
              //string sensor_id = (tc  as TCBase).getHwStaus().sensor_ids[inx - 16];
              //string sql = string.Format("update tblSensor set Isconnected='{0}' where sensor_id={1}",
              //    desc.getStatus(inx) ? "N" : "Y", sensor_id);
              //dbServer.SendSqlCmd(sql);
              //}
              }

              //else if (txt.Text[0] == 0x29) //cycle report
              //{
              //    Console.WriteLine("cyclic report!");
              //}
        }
예제 #26
0
        void tc_OnTCReport(object tc, TextPackage txt)
        {
            //throw new Exception("The method or operation is not implemented.");
              if (txt.Text[0] == 0x07)
              {

              try
              {
                //  if (r_host_comm == null) return;
                 this.notifier.NotifyAll(new NotifyEventObject( EventEnumType.TC_Manual_Ask_Event,((TCBase)tc).DeviceName,txt.Text[1]));
              }
              catch (Exception ex)
              {
                  ConsoleServer.WriteLine(ex.Message + "," + ex.StackTrace);
              }
              }
        }
예제 #27
0
파일: WISTC.cs 프로젝트: ufjl0683/Center
        void WISTC_OnTCReceiveText(object tc, TextPackage txt)
        {
            if (txt.Text[0] == 0xdf && txt.Text[1]==0xd6)
              WIS_LedTest_Report(txt.Text, this.DeviceName);

              //throw new Exception("The method or operation is not implemented.");
        }
예제 #28
0
        void v2dle_OnReceiveText(object sender, TextPackage txt)
        {
            //throw new NotImplementedException();
            System.Data.DataSet ds;
            if (v2dle == null)
                return;
            try
            {
                switch (txt.Text[0])
                {
                    case 0x04:  //query
                        txt.IsQueryCmd = true;

                        switch (txt.Text[1])
                        {
                            case 0x02: //get date time

                                SendDirect(ControllerID, new byte[] { 04,this.PropertyBag.HWtatus[0],this.PropertyBag.HWtatus[1]
                                    ,this.PropertyBag.HWtatus[2],this.PropertyBag.HWtatus[3],0,7,2 , (byte)(DateTime.Now.Year/256),(byte)(DateTime.Now.Year %256),
                            (byte)DateTime.Now.Month,(byte)DateTime.Now.Day,(byte)DateTime.Now.Hour,(byte)DateTime.Now.Minute,(byte)DateTime.Now.Second}, (byte)txt.Seq);
                                break;
                            case 0x03:  //trandmission cycle
                                int _devtype=1;

                               SendDirect(this.ControllerID,
                                   new byte[]{0x04,PropertyBag.HWtatus[0],PropertyBag.HWtatus[1],PropertyBag.HWtatus[2],PropertyBag.HWtatus[3],
                                       0x00,0x05,0x03,1,PropertyBag.TransmitCycle,PropertyBag.TransmitMode,PropertyBag.HWCycle},(byte)txt.Seq);
                               break;
                            case 0x07:
                               SendDirect(this.ControllerID,
                                new byte[]{0x04,PropertyBag.HWtatus[0],PropertyBag.HWtatus[1],PropertyBag.HWtatus[2],PropertyBag.HWtatus[3],
                                       0x00,0x02,0x07,PropertyBag.IsAllowManualMode?(byte)0:(byte)1}, (byte)txt.Seq);
            //cmd=0x04

            //description="Get Trasmiission cycle"
            //class=A
            //func_name="get_transmission_cycle"
            //type=Query
            //send= protocol_code(1:3-3) device_type(1:4 "4_AM Cycle")
            //return= hw_status_1(1:0-255) hw_status_2(1:0-255) hw_status_3(1:0-255) hw_status_4(1:0-255)
            //protocol_length(2:0-65530) protocol_code(1:3-3)  device_type(1:4 "4_AM Cycle")  transmission_cycle(1:1-255) transmit_mode(1:0 "Polling",1 "Active" ) hwcyc(1: 0 "State change" ,1 "5sec",2 "10Sec",3 "20sec",4 "1min",5 "5min")
            //test=@cmd protocol_code(3) device_type(4)
                                break;

                            case 0x08:
                                SendDirect(this.ControllerID,
                             new byte[]{0x04,PropertyBag.HWtatus[0],PropertyBag.HWtatus[1],PropertyBag.HWtatus[2],PropertyBag.HWtatus[3],
                                       0x00,0x03,0x08,txt.Text[2],this.config.sensors[txt.Text[2]].execution_mode }, (byte)txt.Seq);
                                break;

                            case 0x20:
                                byte[] configbytes = GetConfigBytes();
                                byte[] data = new byte[configbytes.Length + 3];

                                data[0] = 0x20;
                                data[1] = (byte)(configbytes.Length / 256);
                                data[2] = (byte)(configbytes.Length % 256);
                                System.Array.Copy(configbytes, 0, data, 3, configbytes.Length);

                                SendPackage pkg = new SendPackage(CmdType.CmdQuery, CmdClass.A, this.ControllerID, To04DataBytes(data));
                                pkg.Seq = txt.Seq;
                                SendDirect(pkg);
                                break;
                            default:
                                OnReceiveText(txt);
                                break;
                        }
                        break;
                    case 0x02:  //set date time get diff
                        int year = txt.Text[1] * 256 + txt.Text[2];
                        int month = txt.Text[3];
                        int day = txt.Text[4];
                        int hour = txt.Text[5];
                        int min = txt.Text[6];
                        int sec = txt.Text[7];

                        DateTime d = new DateTime(year, month, day, hour, min, sec);
                        uint diff = (uint)Math.Abs(d.Subtract(DateTime.Now).TotalSeconds);
                        if (diff > 255)
                            diff = 255;
                        if(diff<3)
                            Comm.Util.SetSysTime(d);
                        txt.IsQueryCmd = true;
                        SendDirect(this.ControllerID, new byte[] { 2, (byte)diff }, (byte)txt.Seq);
                        break;

                    case 0x01: //get hw status

                        // ds = protocol.GetSendDsByTextPackage(txt, CmdType.CmdQuery);
                        txt.IsQueryCmd = true;
                    //    ds= protocol.GetReturnDataSet("get_HW_Status");

                        SendDirect(this.ControllerID, new byte[] { 01, this.PropertyBag.HWtatus[0], this.PropertyBag.HWtatus[1], this.PropertyBag.HWtatus[2], this.PropertyBag.HWtatus[3] }, (byte)txt.Seq);

                        break;
                    case 0x00:  //reset
                        Console.WriteLine("reset!");
                        Environment.Exit(0);

                        break;
                    case 0x03: //Set transmit cycle
            //[Command]
            //cmd=0x03
            //description= "Set Trasmiission cycle"
            //class=A
            //func_name="set_transmission_cycle"
            //type=Set
            //send=device_type(1:4 "4_AM",18 "18_Other")  transmission_cycle(1:0-255) transmit_mode(1:0 "Polling",1 "Active" ) hwcyc(1: 0 "State change" ,1 "5sec",2 "10Sec",3 "20sec",4 "1min",5 "5min")
            //return=
            //test=@cmd device_type(4) transmission_cycle(5) transmit_mode(1) hwcyc(1)
                        ds = protocol.GetSendDsByTextPackage(txt, CmdType.CmdSet);
                        byte device_type= (byte)ds.Tables[0].Rows[0]["device_type"];
                        byte transmission_cycle = (byte)ds.Tables[0].Rows[0]["transmission_cycle"];
                        byte transmit_mode = (byte)ds.Tables[0].Rows[0]["transmit_mode"];
                        byte hwcyc = (byte)ds.Tables[0].Rows[0]["hwcyc"];

                        PropertyBag.HWCycle = hwcyc;
                        PropertyBag.TransmitCycle = transmission_cycle;
                        PropertyBag.TransmitMode = transmit_mode;
                        SetHWStatusTmr();
                        SetTransmitCycleTmr();

                        Console.WriteLine("transmission_cycle:" + transmission_cycle);
                        break;

                    case 0x07: // set Manul Mode
                        if (this.PropertyBag.IsAllowManualMode != ((txt.Text[1] == 0) ? true : false))
                        {
                            this.PropertyBag.IsAllowManualMode = (txt.Text[1] == 0) ? true : false;
                            SendPackage pkg = new SendPackage(CmdType.CmdSet, CmdClass.A, this.ControllerID, new byte[]{0x07,
                            (byte)(PropertyBag.IsAllowManualMode?0:1)});
                            PostSend(pkg);
                        }
                        break;

                    case 0x08:// set Execution mode
                      //  this.config.execution_mode = txt.Text[1]; execution mode will remove
                        this.config.sensors[txt.Text[1]].execution_mode = txt.Text[2];
                        this.config.Serialize();
                        break;
                    case 0x0b: //get hw status
                        txt.IsQueryCmd = true;
                        SendDirect(this.ControllerID, new byte[] { 0x0b, this.PropertyBag.HWtatus[0], this.PropertyBag.HWtatus[1], this.PropertyBag.HWtatus[2], this.PropertyBag.HWtatus[3],PropertyBag.ComState ,PropertyBag.OPStatus,PropertyBag.OPMode}, (byte)txt.Seq);
                        break;

                    case 0x0E:
                        txt.IsQueryCmd = true;

                        SendDirect(this.ControllerID,
                            new byte[] {0x0e,this.PropertyBag.HWtatus[0],this.PropertyBag.HWtatus[1],this.PropertyBag.HWtatus[2],this.PropertyBag.HWtatus[3],
                           (byte)(BuildDate.Year/256),(byte)(BuildDate.Year%256),(byte)BuildDate.Month,(byte)BuildDate.Day,
                            0x30,0x30,0x30,0x30,0x30,1,this.VersionNo,
                            (byte)(this.ControllerID/256),(byte)(this.ControllerID%256)}, (byte)txt.Seq);
                        break;
                    case 0x20:  //set Communication param
                        SetConfig(txt);
                        break;

                     default:
                         OnReceiveText(txt);
                        break;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "," + ex.StackTrace);
            }
        }
예제 #29
0
파일: ETAGITC.cs 프로젝트: ufjl0683/Center
 void AVITC_OnTCReport(object tc, TextPackage txt)
 {
     //throw new Exception("The method or operation is not implemented.");
 }
예제 #30
0
        private async Task HandleReceivedPackage(IPackage package)
        {
            this.online = true;

            if (package.IdReceiver != "")
            {
                await this.server.SendPackage(package);

                if (package.Type == PackageType.Text || package.Type == PackageType.Voice ||
                    package.Type == PackageType.File)
                {
                    IMessage message = package switch
                    {
                        TextPackage textPackage => new TextMessage(this.Id, textPackage.IdAuthor, textPackage.Time,
                                                                   textPackage.Content),
                        VoicePackage voicePackage => new VoiceMessage(this.Id, voicePackage.IdAuthor, voicePackage.Time,
                                                                      voicePackage.Content),
                        FilePackage filePackage => new FileMessage(this.Id, filePackage.IdAuthor, filePackage.Time,
                                                                   filePackage.Content)
                    };
                    // Тут нужен текст сообщения еще
                    // Лучше в Imessage еще хранить chatId, и текст
                    var chatId = string.Compare(this.Id, message.IdAuthor) == -1 ?
                                 $"{Id} {message.IdAuthor}" :
                                 $"{message.IdAuthor} {Id}";
                    server.dataBase.SetMessage(message, chatId);

                    //this.server.ServerDataBase.AddMessage(message);
                }

                this.OnGetPackage?.Invoke(package);
            }
            else
            {
                switch (package)
                {
                case DisconnectPackage:
                    await this.server.Disconnect(this.Id);

                    await this.Disconnect();

                    break;

                    /*case HistoryRequestPackage historyRequestPackage:
                     *  List<IMessage> messages = this.server.ServerDataBase.GetMessages(
                     *      this.Id, historyRequestPackage.IdRequest, historyRequestPackage.TimeUntil);
                     *  HistoryAnswerPackage packageAnswer1 = new HistoryAnswerPackage(this.Id,"",
                     *      messages.Select(message =>
                     *      {
                     *          Tuple<MessageType, string> result = message switch
                     *          {
                     *              TextMessage textMessage => new Tuple<MessageType, string>(message.Type,
                     *                  textMessage.Content),
                     *              VoiceMessage => new Tuple<MessageType, string>(message.Type, "voice message"),
                     *              FileMessage => new Tuple<MessageType, string>(message.Type, "file")
                     *          };
                     *          return result;
                     *      }).ToList());
                     *  await this.server.SendPackage(packageAnswer1);
                     *  break;*/

                    /*case UsersListRequestPackage usersListRequestPackage:
                     *  List<string> users = this.server.ServerDataBase
                     *      .GetUsersWithSimilarId(usersListRequestPackage.IdRequest);
                     *  UsersListAnswerPackage packageAnswer2 = new UsersListAnswerPackage(this.Id, "", users);
                     *  await this.server.SendPackage(packageAnswer2);
                     *  break;*/
                }
            }
        }