示例#1
0
 /// <summary>
 /// 设置模拟输出电压
 /// </summary>
 /// <param name="ch">通道号0-1</param>
 /// <param name="data">电压值0-5V</param>
 /// <returns>是否设置成功</returns>
 public bool SetAoMode(int ch, double data)
 {
     if (ch < instantAoCtrlUsb4704.ChannelCount && data >= 0 && data <= 5)
     {
         ErrorCode err = instantAoCtrlUsb4704.Write(ch, data);
         if (err != ErrorCode.Success)
         {
             ActiveEventError("设置模拟输出失败:" + err.ToString());
             return(false);
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#2
0
        /// <summary>
        /// sets "value" voltage on channel no "channel"
        /// </summary>
        /// <param name="channel">channel no</param>
        /// <param name="value">0-5V (will be checked anyway - throws if bad)</param>
        private void setPortAO(int channel, double value)
        {
            if (effectorsActive)
            {
                if (value > 5 || value < 0)
                {
                    throw new ArgumentException("value is not in range", "value");
                }

                try
                {
                    instantAoCtrl.Write(channel, value);
                }
                catch (InvalidCastException)
                {
                    Logger.Log(this, "msg couldn't been send via extentionCardCommunicator - probably because of no connection", 2);
                }
            }
            else
            {
                Logger.Log(this, "analog port was not set, because effectors are no active");
            }
        }