Ejemplo n.º 1
0
 /// <summary>
 /// 設定Output數值
 /// </summary>
 /// <param name="bitNum">Bit Number</param>
 /// <param name="status">寫入成功回傳true,反之false(DI點一定false)</param>
 /// <returns></returns>
 public bool SetOutput(ushort bitNum, bool status)
 {
     if (dIOPara.IsActive)
     {
         if (ParameterDictionary.GetValue("DO7062BlockScan") == "true")
         {
             Status1[bitNum] = status;
             Status2[bitNum / 8, bitNum % 8] = status;
         }
         else
         {
             Stopwatch sw     = Stopwatch.StartNew();
             ushort    uValue = (ushort)(status ? 1 : 0);
             ushort    uRet   = CEtherCAT_DLL.CS_ECAT_Slave_DIO_Set_Single_Output_Value(dIOPara.CardNo, dIOPara.NodeNo, g_uESCSlotID, bitNum, uValue);
             if (uRet != CEtherCAT_DLL_Err.ERR_ECAT_NO_ERROR)
             {
                 throw new Exception("CS_ECAT_Slave_DIO_Set_Single_Output_Value, " + GetEtherCATErrorCode(uRet));
             }
             sw.Stop();
             //LogHelper.Debug("{0} SetOutput TACT {1}", this.DeviceName, sw.ElapsedMilliseconds);
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 2
0
        public CEtherCATDI6022(ModulesType modulesType, string parameterFolderPath, string deviceName)
            : base(modulesType, parameterFolderPath, deviceName)
        {
            dIOPara = Parameter as ParameterCEtherCATDI6022;

            slaveModuleInitialize();

            if (ParameterDictionary.GetValue("DI6022BlockScan") == "true")
            {
                //system scan
                FlowControl flowControl = ModulesFactory.FlowControlHelper.GetFlowControl("SYNTEKMotion");
                FlowBase    flowBase    = new FlowBase(this.DeviceName, systemScan);
                flowControl.AddFlowBase(flowBase);
                flowBase.Start();
            }
            keyOfIOScan = true;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 取得Intput數值
 /// </summary>
 /// <param name="bitNum">Bit Number</param>
 /// <returns></returns>
 public bool GetInput(ushort bitNum)
 {
     if (ParameterDictionary.GetValue("DI6022BlockScan") == "true")
     {
         return(Status1[bitNum]);
     }
     else
     {
         Stopwatch sw     = Stopwatch.StartNew();
         ushort    uValue = 0;
         ushort    uRet   = CEtherCAT_DLL.CS_ECAT_Slave_DIO_Get_Single_Input_Value(dIOPara.CardNo, dIOPara.NodeNo, g_uESCSlotID, bitNum, ref uValue);
         if (uRet != CEtherCAT_DLL_Err.ERR_ECAT_NO_ERROR)
         {
             throw new Exception("CS_ECAT_Slave_DIO_Get_Single_Input_Value, " + GetEtherCATErrorCode(uRet));
         }
         sw.Stop();
         //LogHelper.Debug("{0} GetInput TACT {1}", this.DeviceName, sw.ElapsedMilliseconds);
         return(uValue == 1);
     }
 }