示例#1
0
        /// <summary>
        /// 設定Channel輸出電壓 -10.0v ~ +10.0v
        /// </summary>
        /// <param name="channel">The Channel No</param>
        /// <param name="voltage">The Voltage</param>
        /// <returns>設定結果</returns>
        public bool SetVoltage(DACChannel channel, double voltage)
        {
            SetVoltageProperty(channel, voltage);
            double lastValue = GetVoltageProperty(channel);

            I16 rc = CDAC_A104.CS_mnet_ao4_set_voltage((U16)dacPara.RingNoOfCard, (U16)dacPara.SlaveIP, (byte)channel, lastValue);

            return(rc == 0);
        }
示例#2
0
        public void SetOutputValue(DACChannel channelNo, ushort value)
        {
            ushort g_uRet = CEtherCAT_DLL.CS_ECAT_Slave_AIO_Set_Output_Value(dacPara.CardNo, dacPara.NodeNo, (ushort)channelNo, value);

            if (g_uRet != CEtherCAT_DLL_Err.ERR_ECAT_NO_ERROR)
            {
                throw new Exception("CS_ECAT_Slave_AIO_Set_Output_Value, " + GetEtherCATErrorCode(g_uRet));
            }
        }
示例#3
0
        public void SetOutputEnable(DACChannel channelNo, bool enable)
        {
            ushort g_uRet = CEtherCAT_DLL.CS_ECAT_Slave_R1_EC9144_Set_Output_Enable(dacPara.CardNo, dacPara.NodeNo, (ushort)channelNo, (ushort)(enable ? 1 : 0));

            if (g_uRet != CEtherCAT_DLL_Err.ERR_ECAT_NO_ERROR)
            {
                throw new Exception("CS_ECAT_Slave_R1_EC9144_Set_Output_Enable, " + GetEtherCATErrorCode(g_uRet));
            }
        }
示例#4
0
        public void SetOutputRangeMode(DACChannel channelNo, RangeMode rangeMode)
        {
            ushort g_uRet = CEtherCAT_DLL.CS_ECAT_Slave_R1_EC9144_Set_Output_RangeMode(dacPara.CardNo, dacPara.NodeNo, (ushort)channelNo, (ushort)rangeMode);

            if (g_uRet != CEtherCAT_DLL_Err.ERR_ECAT_NO_ERROR)
            {
                throw new Exception("CS_ECAT_Slave_R1_EC9144_Set_Output_RangeMode, " + GetEtherCATErrorCode(g_uRet));
            }
        }
示例#5
0
        public ushort GetOutputReturnCode(DACChannel channelNo)
        {
            ushort returnCode = 0;
            ushort g_uRet     = CEtherCAT_DLL.CS_ECAT_Slave_R1_EC9144_Get_Output_ReturnCode(dacPara.CardNo, dacPara.NodeNo, (ushort)channelNo, ref returnCode);

            if (g_uRet != CEtherCAT_DLL_Err.ERR_ECAT_NO_ERROR)
            {
                throw new Exception("CS_ECAT_Slave_R1_EC9144_Get_Output_ReturnCode, " + GetEtherCATErrorCode(g_uRet));
            }
            return(returnCode);
        }
示例#6
0
        private void SetVoltageProperty(DACChannel channel, double voltage)
        {
            switch (channel)
            {
            case DACChannel.CN0:
                this.VoltageCN0 = voltage;
                break;

            case DACChannel.CN1:
                this.VoltageCN1 = voltage;
                break;

            case DACChannel.CN2:
                this.VoltageCN2 = voltage;
                break;

            case DACChannel.CN3:
                this.VoltageCN3 = voltage;
                break;
            }
        }
示例#7
0
        private double GetVoltageProperty(DACChannel channel)
        {
            double voltage = 0;

            switch (channel)
            {
            case DACChannel.CN0:
                voltage = this.VoltageCN0;
                break;

            case DACChannel.CN1:
                voltage = this.VoltageCN1;
                break;

            case DACChannel.CN2:
                voltage = this.VoltageCN2;
                break;

            case DACChannel.CN3:
                voltage = this.VoltageCN3;
                break;
            }
            return(voltage);
        }
示例#8
0
        /// <summary>
        /// 設定Channel輸出電壓 -10.0v ~ +10.0v
        /// </summary>
        /// <param name="channel">The Channel No</param>
        /// <param name="voltage">The Voltage</param>
        /// <returns>設定結果</returns>
        public bool SetVoltage(DACChannel channelNo, double setVoltage)
        {
            double lastValue = 0;

            if (setVoltage <= dacPara.MaxVoltage[(int)channelNo] && setVoltage >= dacPara.MinVoltage[(int)channelNo])
            {
                lastValue = setVoltage;
            }
            else
            {
                if (setVoltage > dacPara.MaxVoltage[(int)channelNo])
                {
                    lastValue = dacPara.MaxVoltage[(int)channelNo];
                }
                if (setVoltage < dacPara.MinVoltage[(int)channelNo])
                {
                    lastValue = dacPara.MinVoltage[(int)channelNo];
                }
            }

            I16 rc = CA104_L132.CS_mnet_ao4_set_voltage((U16)dacPara.CardSwitchNo, (U16)dacPara.RingNoOfCard, (U16)dacPara.SlaveIP, (byte)channelNo, lastValue);

            if (rc != 0)
            {
                return(false);
            }
            else
            {
                voltage[(int)channelNo] = lastValue;

                switch (channelNo)
                {
                case DACChannel.CN0:
                    if (VoltageChangedCN0 != null)
                    {
                        VoltageChangedCN0(lastValue);
                    }
                    break;

                case DACChannel.CN1:
                    if (VoltageChangedCN1 != null)
                    {
                        VoltageChangedCN1(lastValue);
                    }
                    break;

                case DACChannel.CN2:
                    if (VoltageChangedCN2 != null)
                    {
                        VoltageChangedCN2(lastValue);
                    }
                    break;

                case DACChannel.CN3:
                    if (VoltageChangedCN3 != null)
                    {
                        VoltageChangedCN3(lastValue);
                    }
                    break;
                }
                return(true);
            }
        }