Beispiel #1
0
        public void Write(IoPoint ioPoint, bool value)
        {
            var device = _devices[ioPoint.BoardNo];
            var ret    = DASK.DO_WriteLine((ushort)device, 0, (ushort)ioPoint.PortNo, (ushort)(value ? 1 : 0));

            if (ret != DASK.NoError)
            {
                switch (ret)
                {
                case DASK.ErrorInvalidCardNumber:
                    throw new DaskException(string.Format("The CardNumber argument {0} is out of range (larger than 31).", device));

                case DASK.ErrorCardNotRegistered:
                    throw new DaskException(string.Format("No card registered as {0} CardNumber.", device));

                case DASK.ErrorFuncNotSupport:
                    throw new DaskException(string.Format("The {0} function called is not supported by this type of card.", "DO_WriteLine"));

                case DASK.ErrorInvalidIoChannel:
                    throw new DaskException(string.Format("The specified Channel or Port argument {0} is out of range.", ioPoint.PortNo));

                default:
                    throw new DaskException("Unknown error.");
                }
            }
        }
Beispiel #2
0
        //RW Single DOI
        public int WriteSingleDOutput(int boardId, int group, int idx, int iVal)
        {
            var ret = 0;

            ret = DASK.DO_WriteLine((ushort)_config.DevIndex, (ushort)group, (ushort)idx, (ushort)iVal);
            return(ret);
        }
Beispiel #3
0
        /* Write Node */
        public static void WritePin(ushort port, ushort pin, bool state, out short code, out string message)
        {
            if (Testing)
            {
                code = 0; message = "Testing"; return;
            }

            ushort logic = (state) ? (ushort)1 : (ushort)0;

            code = DASK.DO_WriteLine((ushort)m_device, port, pin, logic);
            if (code < 0)
            {
                message = "เขียนเอาท์พุทพิน DIO7432 ผิดพลาด";
                logText = "Write PIN [" + port.ToString() + "." + pin.ToString() + " = " + state.ToString() + "]: " + message;
                log.AppendText(logText);
                System.Diagnostics.Debug.WriteLine(logText);
            }
            else
            {
                message = "";
                logText = "Write PIN [" + port.ToString() + "." + pin.ToString() + " = " + state.ToString() + "]: OK";
                log.AppendText(logText);
                System.Diagnostics.Debug.WriteLine(logText);
            }
        }
Beispiel #4
0
        public int SetDO(int index, bool isON)
        {
            if (index < 0 || index >= DOCount)
            {
                throw new Exception(string.Format("SetDO(index = {0}, isON) index is out of range:0~{1}", index, DOCount - 1));
            }

            //lock (asynLocker)
            {
                if (DASK.DO_WriteLine(_devHandle, (ushort)(index / 32), (ushort)(index % 32), (ushort)(isON ? 1 : 0)) != 0)
                {
                    return((int)ErrorDef.InvokeFailed);
                }
            }
            return((int)ErrorDef.Success);
        }
Beispiel #5
0
        public bool SetOutBit(int iBit, bool bOn)
        {
            bool ret       = false;
            int  int_value = bOn == true ? 1 : 0;

            try
            {
                lock (lockObj)
                {
                    ret = DASK.DO_WriteLine(usCardNo, 0, (ushort)iBit, (ushort)int_value) == 0 ? true : false;
                }
            }
            catch (Exception)
            {
                return(false);
            }
            return(ret);
        }
Beispiel #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            short ret;
            int   out_value;

            if (Int32.TryParse(textBox1.Text, out out_value))
            {
                //ret = DASK.DO_WritePort((ushort)m_dev, 0, (uint)out_value); /* OUTPUT */
                ret = DASK.DO_WriteLine((ushort)m_dev, 0, 4, (ushort)out_value); /* OUTPUT */
                if (ret < 0)
                {
                    MessageBox.Show("DO_WritePort error!");
                }
            }
            else
            {
                MessageBox.Show("Input error!");
            }
        }
        private void DoPress_Click(object sender, EventArgs e)
        {
            var doValue = 0;

            _primADLink.ReadMultiDOutputFromAPI(_config.DevIndex, 0, ref doValue);

            var label  = (Label)sender;
            var index  = Convert.ToInt32(label.Tag);
            var status = (doValue >> index) & 1;

            if (status == 0)
            {
                status = 1;
            }
            else
            {
                status = 0;
            }
            DASK.DO_WriteLine((ushort)_config.DevIndex, 0, (ushort)index, (ushort)status);
        }
Beispiel #8
0
 public static void WriteIOCard7432OutputBit(ushort cardID, ushort cardDoBit, ushort status)
 {
     if (CAMiClsVariable.strIOCard == "7432")
     {
         DASK.DO_WriteLine((ushort)CAMiClsVariable.cardRegId, 0, cardDoBit, status);
     }
     else
     {
         uint doCurrentValue = 0;
         uint doValue        = 0;
         DAQ_I32.DAQ_Mul_GDO_Get(DAQ_I32.DAQ_TYPE.DAQ_D3232, (int)cardID, ref doCurrentValue);
         if (status == 1)//Set
         {
             doValue = (uint)(doCurrentValue | (uint)(1 << cardDoBit));
         }
         else if (status == 0)//Reset
         {
             doValue = (uint)(doCurrentValue & (4294967295 - (1 << cardDoBit)));
         }
         DAQ_I32.DAQ_Mul_GDO_Set(DAQ_I32.DAQ_TYPE.DAQ_D3232, (int)cardID, doValue);
     }
 }