Exemplo n.º 1
0
        void dledev_OnReport(object sender, Comm.TextPackage txtObj)
        {
            // throw new Exception("The method or operation is not implemented.");

            try
            {
                if (txtObj.Text[0] == 0x10 || txtObj.Text[0]==0x11 || txtObj.Text[0]==0x13)
                {

                    System.Data.DataSet ds = protocol.GetSendDsByTextPackage(txtObj, Comm.CmdType.CmdReport);
                    string mesg = "";
                    for (int i = 1; i < ds.Tables[0].Columns.Count; i++)
                    {
                        mesg += ds.Tables[0].Columns[i].ColumnName + ":" + ds.Tables[0].Rows[0][ds.Tables[0].Columns[i].ColumnName].ToString() + "\t";
                    }
                    ConsoleServer.WriteLine(mesg);
                    SVWS_Status svws_status = new SVWS_Status(ds);
                    Program.mfcc_svws.stausmgr.AddSVWS_Status(svws_status);

                }

                //if (txtObj.Text[0] == 0x11)
                //{
                //    System.Data.DataSet ds = protocol.GetSendDsByTextPackage(txtObj, Comm.CmdType.CmdReport);
                //    string mesg = "";
                //    for (int i = 1; i < ds.Tables[0].Columns.Count; i++)
                //    {
                //        mesg += ds.Tables[0].Columns[i].ColumnName + ":" + ds.Tables[0].Rows[0][ds.Tables[0].Columns[i].ColumnName].ToString() + "\t";
                //    }
                //    ConsoleServer.WriteLine(mesg);
                //    SVWS_Status svws_status = new SVWS_Status(ds);
                //    Program.mfcc_svws.stausmgr.AddSVWS_Status(svws_status);
                //}

                //else if (txtObj.Text[0] == 0x13)
                //{

                //    System.Data.DataSet ds = protocol.GetSendDsByTextPackage(txtObj, Comm.CmdType.CmdReport);
                //    string mesg = "";
                //    for (int i = 1; i < ds.Tables[0].Columns.Count; i++)
                //    {
                //        mesg += ds.Tables[0].Columns[i].ColumnName + ":" + ds.Tables[0].Rows[0][ds.Tables[0].Columns[i].ColumnName].ToString() + "\t";
                //    }
                //    ConsoleServer.WriteLine(mesg);
                //    SVWS_Status svws_status = new SVWS_Status(ds);
                //    Program.mfcc_svws.stausmgr.AddSVWS_Status(svws_status);
                //}
                else if (txtObj.Text[0] == 0x12)
                {
                    lock (dledev.GetStream())
                    {
                        byte[] data = dledev.PackData(0xffff, new byte[]{0x12,(byte)(DateTime.Now.Year%100),(byte)DateTime.Now.Month,(byte) DateTime.Now.Day,
                           (byte) DateTime.Now.Hour, (byte) DateTime.Now.Minute, (byte) DateTime.Now.Second}, (byte)txtObj.Seq);
                        dledev.GetStream().Write(data, 0, data.Length);
                    }
                }
            }
            catch (Exception ex)
            {
                ConsoleServer.WriteLine(ex.Message + "," + ex.StackTrace);
            }
        }
Exemplo n.º 2
0
        public void AddSVWS_Status(SVWS_Status svws_status)
        {
            if (Program.mfcc_svws == null)
               return;

            #if DEBUG
               //if (svws_status.place != 22 || svws_status.group != 6 || svws_status.kind != 2 || svws_status.dir != 1 || svws_status.type != "A")

               //    return;
            #endif

               if (!hs_status.Contains(svws_status.Key))
               {
               hs_status.Add(svws_status.Key, svws_status);
               Program.mfcc_svws.dbServer.SendSqlCmd(svws_status.GetInsertStatement());
               Program.mfcc_svws.dbServer.SendSqlCmd(svws_status.GetInsertLogSql());
               }
               else
               {
               if (((SVWS_Status)hs_status[svws_status.Key]).Equals(svws_status))
                   return;

               hs_status.Remove(svws_status.Key);
               hs_status.Add(svws_status.Key, svws_status);
               Program.mfcc_svws.dbServer.SendSqlCmd(svws_status.GetUpdateStatement());

               }
        }
Exemplo n.º 3
0
        //public bool IsMatch(string key)
        //{
        //    return hs_status.Contains(key);
        //}
        public void loadStatus()
        {
            System.Data.Odbc.OdbcConnection cn = new System.Data.Odbc.OdbcConnection(DbCmdServer.getDbConnectStr());
               System.Data.Odbc.OdbcCommand cmd = new System.Data.Odbc.OdbcCommand();
               cmd.Connection = cn;
               cmd.CommandText= "select type,place,group,kind,dir,run_status,hw_status,density,level,no from tblsvwsconfig";
               try
               {
                   cn.Open();
                   System.Data.Odbc.OdbcDataReader rd = cmd.ExecuteReader();

                   while (rd.Read())
                   {
                       string type;
                       int place, group, kind, dir, run_status, hw_status, density, level, no;
                       type = rd[0].ToString();
                       place = System.Convert.ToInt32(rd[1]);
                       group = System.Convert.ToInt32(rd[2]);
                       kind = System.Convert.ToInt32(rd[3]);
                       dir = System.Convert.ToInt32(rd[4]);
                       run_status = System.Convert.ToInt32(rd[5]);
                       hw_status = System.Convert.ToInt32(rd[6]);
                       density = System.Convert.ToInt32(rd[7]);
                       level = System.Convert.ToInt32(rd[8]);
                       no = System.Convert.ToInt32(rd[9]);

            #if DEBUG
                       //if (place != 22 || group != 6 || kind != 2 || dir != 1 || type!="A")

                       //    continue;
            #endif
                       SVWS_Status svws_status=new SVWS_Status();
                       if (type == "A")
                           svws_status.SetAnalogStatus(place, group, kind, dir, density, level);
                       else if (type == "D")
                           svws_status.SetDigitalStatus(place, group, kind, dir, run_status, hw_status);
                       else if (type == "P")
                           svws_status.setPDStatus(place, group, kind, dir, run_status, hw_status,no);

                         this.hs_status.Add(svws_status.Key, svws_status);

                   }

                   rd.Close();
               }
               catch (Exception ex)
               {
                   ConsoleServer.WriteLine(ex.Message + "," + ex.StackTrace);
               }
               finally
               {
                   try { cn.Close(); }
                   catch { ;}
               }
        }
Exemplo n.º 4
0
        public void AddSVWS_Status(SVWS_Status svws_status)
        {
            if (!hs_status.Contains(svws_status.Key))
               {
               hs_status.Add(svws_status.Key, svws_status);
               Program.mfcc_svws.dbServer.SendSqlCmd(svws_status.GetInsertStatement());
               Program.mfcc_svws.dbServer.SendSqlCmd(svws_status.GetInsertLogSql());
               }
               else
               {
               if (((SVWS_Status)hs_status[svws_status.Key]).Equals(svws_status))
                   return;

               hs_status.Remove(svws_status.Key);
               hs_status.Add(svws_status.Key, svws_status);
               Program.mfcc_svws.dbServer.SendSqlCmd(svws_status.GetUpdateStatement());

               }
        }