Example #1
0
 private static void start()
 {
     try
     {
         if (Start == false)
         {
             string ip   = mainForm.txtIp.Text;
             int    port = CommFunc.ConvertDBNullToInt32(mainForm.txtPort.Text);
             int    cnt  = 0;
             while (cnt < 3)
             {
                 ++cnt;
                 bool rst = RdcMethod.Close();
                 if (rst == true)
                 {
                     break;
                 }
                 Thread.Sleep(500);
             }
             RdcMethod.RdcVar = new RdcFunc.RDC_VarOk(resultVar); //放到业务层上去
             RdcMethod.Instance(ip);                              /*初始化*/
             Start = true;
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #2
0
 private static void start()
 {
     try
     {
         if (Start == false)
         {
             string lpFileName = Config.lpFileName;
             string ip         = YDS6000.Models.IniHepler.GetConfig(lpFileName, "rdc", "Ip");
             int    port       = YDS6000.Models.CommFunc.ConvertDBNullToInt32(YDS6000.Models.IniHepler.GetConfig(lpFileName, "rdc", "DataPort"));
             int    cnt        = 0;
             while (cnt < 3)
             {
                 ++cnt;
                 bool rst = RdcMethod.Close();
                 if (rst == true)
                 {
                     break;
                 }
                 Thread.Sleep(500);
             }
             RdcMethod.RdcVar = new RdcFunc.RDC_VarOk(resultVar); //放到业务层上去
             RdcMethod.Instance(ip);                              /*初始化*/
             Start = true;
         }
     }
     catch (Exception ex)
     {
         FileLog.WriteLog("初始化Rdc错误:" + ex.Message + ex.StackTrace);
     }
 }
Example #3
0
 private void start()
 {
     try
     {
         if (Start == false)
         {
             //string lpFileName = Config.lpFileName;
             int cnt = 0;
             rdc = new RdcMethod(this.ip, this.dataPort);
             while (cnt < 3)
             {
                 ++cnt;
                 bool rst = rdc.Close();
                 if (rst == true)
                 {
                     break;
                 }
                 Thread.Sleep(500);
             }
             rdc.RdcVar = new RdcFunc.RDC_VarOk(resultVar); //放到业务层上去
             //rdc.Instance(ip);/*初始化*/
             /*开启事件监听*/
             var ed = new Thread((ThreadStart) delegate { ReadEventDo(); });
             ed.IsBackground = true;
             ed.Start();
             //
             Start = true;
         }
     }
     catch (Exception ex)
     {
         FileLog.WriteLog("初始化Rdc错误:" + ex.Message + ex.StackTrace);
     }
 }
Example #4
0
 //初始化数据
 internal static void Instance(List <string> tag)
 {
     try
     {
         start();
         if (tag != null && tag.Count > 0)
         {
             RdcMethod.AddVar(tag);/*增加变量*/
         }
     }
     catch (Exception ex)
     {
         FileLog.WriteLog("命令新增错误:" + ex.Message + ex.StackTrace);
         mainForm.textBox2.Text = ex.Message;
     }
 }
Example #5
0
        internal static void Close()
        {
            int cnt = 0;

            while (cnt < 3)
            {
                ++cnt;
                bool rst = RdcMethod.Close();
                if (rst == true)
                {
                    break;
                }
                Thread.Sleep(500);
            }
            Start = false;
        }
Example #6
0
        internal static void WriteVar(string lpszDbVarName, string dataVal)
        {
            bool      rst     = false;
            AlarmType errCode = AlarmType.Err_Qt;
            string    errTxt  = "";

            try
            {
                int result = RdcMethod.WriteVar(lpszDbVarName, dataVal);
                rst     = result == 0 ? true : false;
                errCode = rst == true ? AlarmType.Sue : AlarmType.Err_Qt;
                errTxt  = rst == true ? "成功" : "写数据错误";
            }
            catch (Exception ex)
            {
                errTxt = ex.Message;
                FileLog.WriteLog("IOService变量" + lpszDbVarName + "下发命令错误:" + ex.Message + ex.StackTrace);
            }
            //DataProcess.YdProcess.Helper.IOServiceSaveCollectCache(lpszDbVarName, dataVal, DateTime.Now, 0, rst, errCode, errTxt);
        }