Example #1
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     for (int i = 0; i < yAddressName.Length; i++)
     {
         plc.GetDevice(yAddressName[i], out yResultData[i]);
         plcData_y.SetValue(yAddressName[i], yResultData[i]);
     }
 }
Example #2
0
        public override int GetDevice(string sDevice, out int iData)
        {
            iData = 0;
#if (NoCom)
            int[] iDatas = new int[] { iData };
            ErrorCode = NoComWriteDeviceBuffer(sDevice, 1, ref iDatas);
#else
            lock (mvarActEasyIF)
            {
                int retry = 0;
                do
                {
                    ErrorCode = mvarActEasyIF.GetDevice(sDevice, out iData);
                    if (ErrorCode != 0)
                    {
                        System.Threading.Thread.Sleep(100);
                    }
                    retry++;
                } while (ErrorCode != 0 && retry < 3);
            }
#endif
            return(ErrorCode);
        }