Пример #1
0
        public bool setStatus(int status)
        {
            this.dt=DateTime.Now;
              if (this.status != status)
              {

              this.status = status;
              SecurityAlarmData data = new SecurityAlarmData(devName, dt, tunnel, place, cardid, status);
              data.status = status; ;
              if (status == 0 && this.OnEventStop != null)
              {

                  this.OnEventStop(data);
              }

              if (status != 0 && this.OnEvent != null)
                  this.OnEvent(data);

              return true;
              }
              else
              return false;
        }
Пример #2
0
        void TEMTest()
        {
            Console.ReadKey();
            RemoteInterface.TEM.SecurityAlarmData sd = new SecurityAlarmData(this.TEM_DEVNAME, DateTime.Now, "1", 1, 1, 1);
            (this.hsSecurityAlarmData[sd.Key] as RemoteInterface.TEM.SecurityAlarmData).setStatus(1);
              //  this.data_OnEvent(sd);

            Console.ReadKey();
            (this.hsSecurityAlarmData[sd.Key] as RemoteInterface.TEM.SecurityAlarmData).setStatus(0);
              //  this.data_OnEventStop(sd);
        }
Пример #3
0
        void MFCC_TEM_OnTCReport(object tcobj, Comm.TextPackage txt)
        {
            //throw new Exception("The method or operation is not implemented.");

            if (txt.Text[0] == 0x0b || txt.Text[0] == 0x01)
                return;

            TCBase tc = tcobj as TCBase;

            System.Data.DataSet ds = null;
            try
            {

                ds=protocol.GetSendDsByTextPackage(txt, CmdType.CmdReport);

                System.Data.DataRow r = ds.Tables[0].Rows[0];
              //  string key;
                switch (txt.Text[0])
                {

                    case 0x10:  //filealarm

                     //   key = r["tunnel"].ToString() + "-" + r["place"] + "-" + r["div"];
                        RemoteInterface.TEM.FireAlarmData fdata = new RemoteInterface.TEM.FireAlarmData(tc.DeviceName, System.DateTime.Now,
                             r["tunnel"].ToString(), Convert.ToInt32(r["place"]), Convert.ToInt32(r["div"]), Convert.ToInt32(r["status"]));
                        if (!hsFireAlarmData.Contains(fdata.Key))
                        {

                            fdata.OnEvent += new RemoteInterface.TEM.OnEventHandler(data_OnEvent);
                            fdata.OnEventStop += new RemoteInterface.TEM.OnEventHandler(data_OnEventStop);
                            hsFireAlarmData.Add(fdata.Key, fdata);
                            ConsoleServer.WriteLine("新增火警分區:" + fdata);
                            //  this.r_host_comm.setTemEvent(tc.DeviceName, data);

                        }
                        else
                        {
                            (hsFireAlarmData[fdata.Key] as FireAlarmData).setStatus(Convert.ToInt32(r["status"]));
                            ConsoleServer.WriteLine("火警分區:" + fdata);
                        }

                        break;

                    case 0x13:   //power
                       // key = r["tunnel"].ToString() + "-" + r["place"];
                        RemoteInterface.TEM.PowerAlarmData pdata = new RemoteInterface.TEM.PowerAlarmData(tc.DeviceName, System.DateTime.Now,
                              r["tunnel"].ToString(), Convert.ToInt32(r["place"]), Convert.ToInt32(r["status"]));
                        if (!hsPowerAlarmData.Contains(pdata.Key))
                        {

                            pdata.OnEvent += new RemoteInterface.TEM.OnEventHandler(data_OnEvent);
                            pdata.OnEventStop += new RemoteInterface.TEM.OnEventHandler(data_OnEventStop);
                            hsPowerAlarmData.Add(pdata.Key, pdata);
                            ConsoleServer.WriteLine("新增配電分區:" + pdata);
                            //   this.r_host_comm.setTemEvent(tc.DeviceName, data);

                        }
                        else
                        {
                            (hsPowerAlarmData[pdata.Key] as PowerAlarmData).setStatus(Convert.ToInt32(r["status"]));
                            ConsoleServer.WriteLine("配電:" + pdata);
                        }

                        break;
                    case 0x14:  //security
                       // key = r["tunnel"].ToString() + "-" + r["place"]+"-"+r["card_reader"];\
                        RemoteInterface.TEM.SecurityAlarmData sdata = new RemoteInterface.TEM.SecurityAlarmData(tc.DeviceName, System.DateTime.Now,
                              r["tunnel"].ToString(), Convert.ToInt32(r["place"]), Convert.ToInt32(r["card_reader"]), Convert.ToInt32(r["status"]));
                        if (!hsSecurityAlarmData.Contains(sdata.Key))
                        {

                            sdata.OnEvent += new RemoteInterface.TEM.OnEventHandler(data_OnEvent);
                            sdata.OnEventStop += new RemoteInterface.TEM.OnEventHandler(data_OnEventStop);
                            hsSecurityAlarmData.Add(sdata.Key, sdata);
                            ConsoleServer.WriteLine("新增門禁分區:" + sdata);
                            // this.r_host_comm.setTemEvent(tc.DeviceName, data);

                        }
                        else
                        {
                            (hsSecurityAlarmData[sdata.Key] as SecurityAlarmData).setStatus(Convert.ToInt32(r["status"]));
                            ConsoleServer.WriteLine("門禁:" + sdata);
                        }

                        break;

                    case 0x15:

                        RemoteInterface.TEM.MonitorAlarmData mdata = new RemoteInterface.TEM.MonitorAlarmData(tc.DeviceName, System.DateTime.Now,
                                                    r["tunnel"].ToString(), Convert.ToInt32(r["place"]), Convert.ToInt32(r["location"]), Convert.ToInt32(r["status"]));
                        if (!hsMonitorAlarmData.Contains(mdata.Key))
                        {

                            mdata.OnEvent += new RemoteInterface.TEM.OnEventHandler(data_OnEvent);
                            mdata.OnEventStop += new RemoteInterface.TEM.OnEventHandler(data_OnEventStop);
                            hsMonitorAlarmData.Add(mdata.Key, mdata);
                            ConsoleServer.WriteLine("新增監控分區:" + mdata);
                            // this.r_host_comm.setTemEvent(tc.DeviceName, data);

                        }
                        else
                        {
                            (hsMonitorAlarmData[mdata.Key] as MonitorAlarmData).setStatus(Convert.ToInt32(r["status"]));
                            ConsoleServer.WriteLine("監控:" + mdata);
                        }

                        break;

                    case 0x12:  //light
                       // key = r["tunnel"].ToString() + "-" + r["place"] + "-" + r["div"];
                        RemoteInterface.TEM.LightAlarmData ldata = new RemoteInterface.TEM.LightAlarmData(tc.DeviceName, System.DateTime.Now,
                              r["tunnel"].ToString(), Convert.ToInt32(r["place"]), Convert.ToInt32(r["div"]), Convert.ToInt32(r["required"]), Convert.ToInt32(r["damaged"]));
                        if (!hsLightAlarmData.Contains(ldata.Key))
                        {

                            ldata.OnEvent += new RemoteInterface.TEM.OnEventHandler(data_OnEvent);
                            ldata.OnEventStop += new RemoteInterface.TEM.OnEventHandler(data_OnEventStop);
                            hsLightAlarmData.Add(ldata.Key, ldata);
                            ConsoleServer.WriteLine("新增照明分區:" + ldata);
                            //  this.r_host_comm.setTemEvent(tc.DeviceName, data);
                        }
                        else
                        {
                            (hsLightAlarmData[ldata.Key] as LightAlarmData).setStatus(Convert.ToInt32(r["required"]), Convert.ToInt32(r["damaged"]));
                            ConsoleServer.WriteLine("照明:" + ldata);
                        }

                        break;

                    case 0x11:  //air

                        AirAlarmData vidata, codata, nodata, no2data, noxdata ;

                        int tunnel = System.Convert.ToInt32(r["tunnel"]);
                        int place = System.Convert.ToInt32(r["place"]);
                        int mile_k = System.Convert.ToInt32(r["mile_k"]);
                        int mile_m = System.Convert.ToInt32(r["mile_m"]);
                        vidata = new AirAlarmData(tc.DeviceName, tunnel, place, mile_k, mile_m, "VI"
                            , System.Convert.ToInt32(r["vi_density_2"]), System.Convert.ToInt32(r["vi_odd_2"]), System.Convert.ToInt32(r["vi_level_2"]));
                        codata = new AirAlarmData(tc.DeviceName, tunnel, place, mile_k, mile_m, "CO"
                           , System.Convert.ToInt32(r["co_density_1"]), System.Convert.ToInt32(r["co_odd_1"]), System.Convert.ToInt32(r["co_level_1"]));
                        nodata = new AirAlarmData(tc.DeviceName, tunnel, place, mile_k, mile_m, "NO"
                          , System.Convert.ToInt32(r["no_density_3"]), System.Convert.ToInt32(r["no_odd_3"]), System.Convert.ToInt32(r["no_level_3"]));
                        no2data = new AirAlarmData(tc.DeviceName, tunnel, place, mile_k, mile_m, "NO2"
                         , System.Convert.ToInt32(r["no2_density_4"]), System.Convert.ToInt32(r["no2_odd_4"]), System.Convert.ToInt32(r["no2_level_4"]));

                        noxdata = new AirAlarmData(tc.DeviceName, tunnel, place, mile_k, mile_m, "NOX"
                        , System.Convert.ToInt32(r["nox_density_5"]), System.Convert.ToInt32(r["nox_odd_5"]), System.Convert.ToInt32(r["nox_level_5"]));

                        AirAlarmData[] airDatas = new AirAlarmData[] { vidata, codata, nodata, no2data, noxdata };
                        foreach (AirAlarmData a in airDatas)
                        {
                            if (!hsAirAlarmData.Contains(a.Key))
                            {
                                hsAirAlarmData.Add(a.Key, a);
                                a.OnEvent += new OnEventHandler(data_OnEvent);
                                a.OnEventStop += new OnEventHandler(data_OnEventStop);
                                ConsoleServer.WriteLine("新增空氣品質分區:" + a);
                            }
                            else
                            {
                                (hsAirAlarmData[a.Key] as AirAlarmData).setData(a.density, a.level);
                                ConsoleServer.WriteLine("空氣品質:" + a);
                            }

                        }
                         //for(int i=0;i < ds.Tables[0].Columns.Count;i++)
                         //{
                         //    ConsoleServer.Write(ds.Tables[0].Columns[i].ColumnName + ":" + r[i].ToString()+" ");

                         //}
                         //ConsoleServer.WriteLine("");

                        break;

                }

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

              //  ConsoleServer.WriteLine(txt.ToString());

            //try
            //{
            //    string result="";
            //    string sql = "insert into tblTEMStateLog (devicename,timestamp,lane_id,cam_id,event_id,action_type) values('{0}','{1}',{2},{3},{4},{5})";
            //    System.Data.DataSet ds = this.protocol.GetSendDsByTextPackage(txt,Comm.CmdType.CmdReport);
            //    int year,mon,day,hr,min,sec;
            //    System.Data.DataRow r=ds.Tables[0].Rows[0];
            //    year=System.Convert.ToInt32(r["year"]);
            //    mon=System.Convert.ToInt32(r["month"]);
            //    day=System.Convert.ToInt32(r["day"]);
            //    hr=System.Convert.ToInt32(r["hour"]);
            //    min=System.Convert.ToInt32(r["minute"]);
            //    sec=System.Convert.ToInt32(r["second"]);

            //    DateTime dt=new DateTime(year,mon,day,hr,min,sec);

            //    for(int i =0;i<ds.Tables["tblevent_lane_count"].Rows.Count;i++)
            //    {
            //        string dbcmd=string.Format(sql, (tc as Comm.TCBase).DeviceName,Comm.DB2.Db2.getTimeStampString(dt),System.Convert.ToInt32(ds.Tables["tblevent_lane_count"].Rows[i]["lane_id"]),
            //            System.Convert.ToUInt32(r["cam_id"]),System.Convert.ToInt32(r["event_id"]),System.Convert.ToInt32(r["action_type"]));
            //        dbServer.SendSqlCmd(dbcmd);
            //    }
            //    for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
            //    {
            //       result+=ds.Tables[0].Columns[i].ColumnName+":"+ds.Tables[0].Rows[0][i]+",";
            //    }
            //    ConsoleServer.WriteLine(result.TrimEnd(new char[]{','}));
            //}
            //catch (Exception ex)
            //{
            //    ConsoleServer.WriteLine(txt.ToString());
            //    ConsoleServer.WriteLine(ex.Message + "," + ex.StackTrace);
            //}
        }