示例#1
0
        public static void RGS_Test_Task()
        {
            Protocol protocol=new Protocol();
            protocol.Parse(System.IO.File.ReadAllText(System.AppDomain.CurrentDomain.BaseDirectory+"protocol.txt"));
            Comm.TC.RGSTC tc = new Comm.TC.RGSTC(protocol, "RGSTest", "59.120.20.153", 4660,0xffff, new byte[] { 0, 0, 0, 0 },0,0,0);
            // Comm.TC.RGSTC tc = (Comm.TC.RGSTC)this.manager["RGS232"];

            while (!tc.IsConnected) ;
            tc.m_device.OnAck += new OnAckEventHandler(m_device_OnAck);
            tc.m_device.OnSendingPackage += new OnSendPackgaeHandler(m_device_OnSendingPackage);
            tc.m_device.OnReceiveText += new OnTextPackageEventHandler(m_device_OnReceiveText);
            while (true)
            {

                System.Drawing.Color[][] color;
                color = new System.Drawing.Color[1][];
                color[0] = new System.Drawing.Color[4] { System.Drawing.Color.Red, System.Drawing.Color.Red, System.Drawing.Color.Red, System.Drawing.Color.Red };
                try
                {
                    if (tc.IsConnected)
                        tc.SetTravelDisplay(new byte[0], new string[] { "系統測試" }, color);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
示例#2
0
        void establish_RGS_TC()
        {
            rgs_protocol.Parse(System.IO.File.ReadAllText(Util.CPath(AppDomain.CurrentDomain.BaseDirectory+"RGS.txt")), false);
              lock (QYTask.Program.RGSConfDs.tblRGSMain)
              {

              foreach (QYTask.Ds.tblRGSMainRow r in Program.RGSConfDs.tblRGSMain.Rows)
              {
                  Comm.TC.RGSTC tc = new Comm.TC.RGSTC(rgs_protocol, r.rgs_name, r.ip, (int)r.port, r.deviec_id);
                  //AD HWSTATUS EVENT HERE!
                  tc.OnConnectStatusChanged += new Comm.ConnectStatusChangeHandler(tc_OnConnectStatusChanged);
                  tc.OnHwStatusChanged += new Comm.HWStatusChangeHandler(tc_OnHwStatusChanged);
                  RGS_tcs.Add(r.ip, tc);

              }
              }
        }
示例#3
0
        public void AddDevice(string devName)
        {
            if (this.manager.IsContains(devName))
              throw new Exception(devName + " alreay in MFCC name list!");

              System.Data.Odbc.OdbcDataReader rd=null;
              System.Data.Odbc.OdbcConnection cn = new System.Data.Odbc.OdbcConnection(Comm.DB2.Db2.db2ConnectionStr);
              //rd = Comm.DB2.Db2.getDeviceConfigReader(cn, this.mfccid);
              System.Data.Odbc.OdbcCommand cmd = new System.Data.Odbc.OdbcCommand("select devicename,ip,port ,hw_status_1,hw_status_2,hw_status_3,hw_status_4,op_mode,op_status,comm_state,IsF311z,comparison_cycle,enable from tbldeviceconfig where mfccid='" + mfccid + "'" + " and  devicename='" + devName + "'" , cn);
              Comm.TCBase tc = null;
             // this.dbServer.SendSqlCmd("update tblDeviceConfig set comm_state=3 where devicename='" + devName + "'");
              try
              {

              cmd.Connection = cn;
              cn.Open();
              rd = cmd.ExecuteReader();

              if (!rd.Read())
                  throw new Exception("can't find " + devName + "in tblDeviceConfig");

               //   ConsoleServer.WriteLine(string.Format("load tc:{0} ip:{1} port:{2}", rd[0], rd[1], rd[2]));

              byte[] hw_status = new byte[4];
              byte opmode, opstatus;
              byte comm_state;
              bool enable;
              for (int i = 0; i < 4; i++)
              hw_status[i] = System.Convert.ToByte(rd[3 + i]);
              opmode = System.Convert.ToByte(rd[7]);
              opstatus = System.Convert.ToByte(rd[8]);
              comm_state = System.Convert.ToByte(rd[9]);
              enable = (rd[12].ToString() == "Y");

              if (this.devType == "VD")
              {
              tc = new Comm.TC.VDTC(protocol, rd[0].ToString().Trim(), rd[1].ToString(), (int)rd[2], 0xffff, hw_status, opmode, opstatus,comm_state);
              }

              else if (this.devType == "RGS")
              {
              tc = new Comm.TC.RGSTC(protocol, rd[0].ToString().Trim(), rd[1].ToString(), (int)rd[2], 0xffff, hw_status, opmode, opstatus,comm_state);
              }
              else if (this.devType == "RMS")
              {
              tc = new Comm.TC.RMSTC(protocol, rd[0].ToString().Trim(), rd[1].ToString(), (int)rd[2], 0xffff, hw_status, opmode, opstatus,comm_state);

              }
              else if (this.devType == "CMS")
              {
              tc = new Comm.TC.CMSTC(protocol, rd[0].ToString().Trim(), rd[1].ToString(), (int)rd[2], 0xffff, hw_status, opmode, opstatus,comm_state);

              }
              else if (this.devType == "WIS")
              {
              tc = new Comm.TC.WISTC(protocol, rd[0].ToString().Trim(), rd[1].ToString(), (int)rd[2], 0xffff, hw_status, opmode, opstatus,comm_state);

              }
              else if (this.devType == "LCS")
              {
              tc = new Comm.TC.LCSTC(protocol, rd[0].ToString().Trim(), rd[1].ToString(), (int)rd[2], 0xffff, hw_status, opmode, opstatus,comm_state);
              }
              else if (this.devType == "CSLS")
              {
              tc = new Comm.TC.CSLSTC(protocol, rd[0].ToString().Trim(), rd[1].ToString(), (int)rd[2], 0xffff, hw_status, opmode, opstatus,comm_state);
              }
              else if (this.devType == "AVI")
              {
              tc = new Comm.TC.AVITC(protocol, rd[0].ToString().Trim(), rd[1].ToString(), (int)rd[2], 0xffff, hw_status, opmode, opstatus,comm_state);
              }
              else if (this.devType == "ETAG")
              {
              tc = new Comm.TC.ETAGTC(protocol, rd[0].ToString().Trim(), rd[1].ToString(), (int)rd[2], 0xffff, hw_status, opmode, opstatus, comm_state);
              }

              else if (this.devType == "RD")
              {
              tc = new Comm.TC.RDTC(protocol, rd[0].ToString().Trim(), rd[1].ToString(), (int)rd[2], 0xffff, hw_status, opmode, opstatus, comm_state);
              }
              else if (this.devType == "VI")
              {
              tc = new Comm.TC.VITC(protocol, rd[0].ToString().Trim(), rd[1].ToString(), (int)rd[2], 0xffff, hw_status, opmode, opstatus, comm_state);
              }
              else if (this.devType == "WD")
              {
              tc = new Comm.TC.WDTC(protocol, rd[0].ToString().Trim(), rd[1].ToString(), (int)rd[2], 0xffff, hw_status, opmode, opstatus, comm_state);
              }
              else if (this.devType == "TTS")
              {
              tc = new Comm.TC.TTSTC(protocol, rd[0].ToString().Trim(), rd[1].ToString(), (int)rd[2], 0xffff, hw_status, opmode, opstatus, comm_state);
              }
              else if (this.devType == "FS")
              {
              tc = new Comm.TC.FSTC(protocol, rd[0].ToString().Trim(), rd[1].ToString(), (int)rd[2], 0xffff, hw_status, opmode, opstatus, comm_state);
              }
              else if (this.devType == "MAS")
              {
              tc = new Comm.TC.MASTC(protocol, rd[0].ToString().Trim(), rd[1].ToString(), (int)rd[2], 0xffff, hw_status, opmode, opstatus, comm_state);
              }
              else if (this.devType == "IID")
              {
              tc = new Comm.TC.IIDTC(protocol, rd[0].ToString().Trim(), rd[1].ToString(), (int)rd[2], 0xffff, hw_status, opmode, opstatus, comm_state);
              }
              else if (this.devType == "ETTU")
              {
              tc = new Comm.TC.ETTUTC(protocol, rd[0].ToString().Trim(), rd[1].ToString(), (int)rd[2], 0xffff, hw_status, opmode, opstatus, comm_state);
              }
              else if (this.devType == "LS")
              {
              tc = new Comm.TC.LSTC(protocol, rd[0].ToString().Trim(), rd[1].ToString(), (int)rd[2], 0xffff, hw_status, opmode, opstatus, comm_state);
              }
              else if (this.devType == "TEM")
              {
              tc = new Comm.TC.TEMTC(protocol, rd[0].ToString().Trim(), rd[1].ToString(), (int)rd[2], 0xffff, hw_status, opmode, opstatus, comm_state);
              }
              else if (this.devType == "SCM")
              {
              tc = new Comm.TC.SCMTC(protocol, rd[0].ToString().Trim(), rd[1].ToString(), (int)rd[2], 0xffff, hw_status, opmode, opstatus, comm_state);
              }
              else if (this.devType == "CMSRST")
              {
              tc = new Comm.TC.CMSRSTTC(protocol, rd[0].ToString().Trim(), rd[1].ToString(), (int)rd[2], 0xffff, hw_status, opmode, opstatus, comm_state);
              }
              else if (this.devType == "BS")
              {
              tc = new Comm.TC.BSTC(protocol, rd[0].ToString().Trim(), rd[1].ToString(), (int)rd[2], 0xffff, hw_status, opmode, opstatus, comm_state);
              }

              ConsoleServer.WriteLine(string.Format("load tc:{0} ip:{1} port:{2}", rd[0], rd[1], rd[2]));
              if(tc is OutputTCBase)
             ((OutputTCBase)tc).setDisplayCompareCycle( System.Convert.ToInt32(rd[11]));

              tcAry.Add(tc);
              tc.OnHwStatusChanged += new HWStatusChangeHandler(tc_OnHwStatusChanged);
              tc.OnConnectStatusChanged += new ConnectStatusChangeHandler(tc_OnConnectStatusChanged);
              tc.OnOpModeChanged += new OnOPModeChangeHandler(tc_OnOpModeChanged);
              tc.OnOpStatusChanged += new OnOPStatusChangeHandler(tc_OnOpStatusChanged);
              tc.OnTCReport += new OnTCReportHandler(tc_OnTCReport);
              tc.OnDbDemand += new OnDbDemandHandler(tc_OnDbDemand);
              tc.IsF311z = (System.Convert.ToString(rd[10]).ToUpper() == "Y") ? true : false;
              tc.IsEnable = enable;
              if (tc is OutputTCBase)
              {
              ((OutputTCBase)tc).OnOutputChanged += new Comm.OnOutputChangedHandler(MFCC_Base_OnOutputChanged);
              ((OutputTCBase)tc).OnOutputDataCompareWrongEvent += new OnOutputDataCompareWrongEventHandler(MFCC_Base_OnOutputDataCompareWrongEvent);
              }
              this.BindEvent(tc);

              manager.AddTC(tc);

              }
              catch (Exception ex)
              {
              ConsoleServer.WriteLine("InAddDevice:" + ex.Message);
              throw new Exception("InAddDevice:" + ex.Message);
              }
              finally
              {
              rd.Close();
              cn.Close();
              }
        }