public void SetOutputPoint(IO_OUT_Type Io, IOValue Value)
 {
     if (m_ControlerBoard != null)
     {
         m_ControlerBoard.SendCommandToSetControlBoardOutput(Io, Value);
     }
 }
Example #2
0
        //设置单片机控制板控制的按键灯
        public void SetKeyLedByKey(Board board, ARM_InputPoint Key, LED_State LedState)
        {
            IOValue         Value  = LedState == (LED_State.LED_ON) ? IOValue.IOValueHigh : IOValue.IOValueLow;
            ARM_OutputPoint KeyLed = ARM_OutputPoint.IO_OUT_LedKeyRun;

            switch (Key)
            {
            case ARM_InputPoint.IO_IN_KeyRun:
                KeyLed = ARM_OutputPoint.IO_OUT_LedKeyRun;
                break;

            case ARM_InputPoint.IO_IN_KeyPause:
                KeyLed = ARM_OutputPoint.IO_OUT_LedKeyPause;
                break;

            case ARM_InputPoint.IO_IN_KeyStop:
                KeyLed = ARM_OutputPoint.IO_OUT_LedKeyStop;
                break;

            case ARM_InputPoint.IO_IN_KeyReset:
                KeyLed = ARM_OutputPoint.IO_OUT_LedKeyReset;
                break;

            default:
                break;
            }

            SetArmControlBoardIo(board, KeyLed, Value);
        }
Example #3
0
        /// <summary>
        /// Gets the <see cref="IOValue"/> associated with the given <paramref name="valueID"/>.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="valueID">The ID corresponding to the <see cref="IOValue"/> to retrieve.</param>
        /// <returns>The <see cref="IOValue"/> associated with the given <paramref name="valueID"/>.</returns>
        public static IOValue GetIOValue(this IOValue source, int valueID)
        {
            if (Enum.GetValues(typeof(IOValue)).OfType <int>().Contains(valueID))
            {
                return((IOValue)valueID);
            }

            return(IOValue.UNKNOWN);
        }
Example #4
0
 public void SetRobotIo(Robot_Out Io, IOValue Value)
 {
     if (m_IsConnected)
     {
         AxisNum axis    = 0;
         ushort  channel = 0;
         GetAxisAndChannelByRobotOut(Io, ref axis, ref channel);
         m_MotionControler.SetMotionIo(axis, channel, (byte)Value);
     }
 }
Example #5
0
        //设置单片机控制板的IO
        public bool SetArmControlBoardIo(Board board, ARM_OutputPoint Io, IOValue Value)
        {
            if (!IsBoardConnected(board))
            {
                return(false);
            }

            int data1 = 8;  //1~8输出口使能控制字节, 最大是0x80
            int data2 = 16;
            int data3 = 24;
            int data4 = 32;

            const int CommandIndex = Message.MessageCommandIndex;

            Message.MakeSendArrayByCode((byte)ArmCommandCode.SetOutput, ref m_SendMeas);

            //根据Type, Value 设置使能位和数据
            int  TempIo       = (int)Io;
            int  ControlIndex = CommandIndex + 1;
            byte ControlValue = 0;
            byte IoData       = 0;

            if (TempIo <= data1)
            {
                ControlIndex = CommandIndex + 1;
                ControlValue = (byte)(0x01 << (TempIo - 1));
                IoData       = (byte)(((byte)Value) << (TempIo - 1));
            }
            else if (TempIo > data1 && TempIo <= data2)
            {
                ControlIndex = CommandIndex + 2;
                ControlValue = (byte)(0x01 << (TempIo - data1 - 1));
                IoData       = (byte)(((byte)Value) << (TempIo - data1 - 1));
            }
            else if (TempIo > data2 && TempIo <= data3)
            {
                ControlIndex = CommandIndex + 3;
                ControlValue = (byte)(0x01 << (TempIo - data2 - 1));
                IoData       = (byte)(((byte)Value) << (TempIo - data2 - 1));
            }
            else if (TempIo > data3 && TempIo <= data4)
            {
                ControlIndex = CommandIndex + 4;
                ControlValue = (byte)(0x01 << (TempIo - data3 - 1));
                IoData       = (byte)(((byte)Value) << (TempIo - data3 - 1));
            }

            m_SendMeas[ControlIndex]            = ControlValue;
            m_SendMeas[ControlIndex + 4]        = IoData;
            m_SendMeas[Message.MessageSumCheck] = MyMath.CalculateSum(m_SendMeas, Message.MessageLength);

            m_MyTcpClientArm[(int)board].ClientWrite(m_SendMeas);

            return(true);
        }
Example #6
0
        public IOValue GetRobotIo(Robot_In Io)
        {
            IOValue Value = IOValue.IOValueLow;

            if (m_IsConnected)
            {
                AxisNum axis    = 0;
                ushort  channel = 0;
                GetAxisAndChannelByRobotIn(Io, ref axis, ref channel);
                Value = (IOValue)m_MotionControler.GetMotionIo(axis, channel);
            }

            return(Value);
        }
Example #7
0
        public void SendCommandToSetControlBoardOutput(IO_OUT_Type Io, IOValue Value)
        {
            int BoardIndex = 0;
            int IoOutIndex = 0;

            GetIoOutBoardAndAxisIndexByIO_OUT_Type(Io, ref BoardIndex, ref IoOutIndex);

            if (!IsControlerConnected((Board)BoardIndex))
            {
                return;
            }

            uint outputBuffer = 0;  //输出口数据
            uint outputEnable = 0;  //输出口使能

            if (Value == IOValue.High)
            {
                outputBuffer |= ((uint)1 << IoOutIndex);
            }

            outputEnable |= ((uint)1 << IoOutIndex);

            byte[] temp = new byte[CommunicationProtocol.MessageLength];
            CommunicationProtocol.MakeSendArrayByCode((byte)ControlerCommandCode.SetOutput, ref temp);

            const int DataIndex = CommunicationProtocol.MessageCommandIndex + 1;

            temp[DataIndex + 0] = (byte)(outputEnable & 0xffU);
            temp[DataIndex + 1] = (byte)((outputEnable >> 8) & 0xffU);
            temp[DataIndex + 2] = (byte)((outputEnable >> 16) & 0xffU);
            temp[DataIndex + 3] = (byte)((outputEnable >> 24) & 0xffU);
            temp[DataIndex + 4] = (byte)(outputBuffer & 0xffU);
            temp[DataIndex + 5] = (byte)((outputBuffer >> 8) & 0xffU);
            temp[DataIndex + 6] = (byte)((outputBuffer >> 16) & 0xffU);
            temp[DataIndex + 7] = (byte)((outputBuffer >> 24) & 0xffU);

            temp[CommunicationProtocol.MessageSumCheck] = 0x00;
            temp[CommunicationProtocol.MessageSumCheck] = MyMath.CalculateSum(temp, CommunicationProtocol.MessageLength);

            AddCommandMessageToQueue((Board)BoardIndex, ControlerCommandCode.SetOutput, ref temp);
        }
Example #8
0
        public bool CheckGraspAndPutIo(GraspAndPutType type, IOValue value)
        {
            bool Re = false;

            if (m_IsConnected)
            {
                if (type == GraspAndPutType.Device)
                {
                    Re = (GetRobotIo(Robot_In.IO_IN_GraspDeviceNozzleCheck) == value);
                }
                else
                {
                    Re = ((GetRobotIo(Robot_In.IO_IN_GraspSalverNozzleCheck1) == value) &&
                          (GetRobotIo(Robot_In.IO_IN_GraspSalverNozzleCheck2) == value) &&
                          (GetRobotIo(Robot_In.IO_IN_GraspSalverNozzleCheck3) == value) &&
                          (GetRobotIo(Robot_In.IO_IN_GraspSalverNozzleCheck4) == value));
                }
            }

            return(Re);
        }
Example #9
0
        public void SetRobotIo(Robot_IO_OUT Io, IOValue Value)
        {
            bool State = (Value == IOValue.IOValueLow ? true : false);

            m_Robot.SetOutputState((int)Io, State);
        }
Example #10
0
 /// <summary>
 /// Gets the name of the IO value.
 /// </summary>
 /// <param name="source"></param>
 /// <returns>The name of the IO value.</returns>
 public static string GetName(this IOValue source)
 {
     return(source.ToString());
 }
Example #11
0
 /// <summary>
 /// Gets the ID of the IO value.
 /// </summary>
 /// <param name="source"></param>
 /// <returns>The ID of the IO value</returns>
 public static int GetID(this IOValue source)
 {
     return((int)source);
 }
 /// <summary>
 /// Gets the name of the IO value.
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public static string GetName(this IOValue value)
 {
     return(value.ToString());
 }
 /// <summary>
 /// Gets the ID of the IO value.
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public static int GetID(this IOValue value)
 {
     return((int)value);
 }
		/**
		 * Sets the digital value (high or low) to the provided IO line of this 
		 * XBee device.
		 * 
		 * @param ioLine The IO line to set its value.
		 * @param ioValue The IOValue to set to the IO line ({@code HIGH} or 
		 *              {@code LOW}).
		 * 
		 * @throws InterfaceNotOpenException if this device connection is not open.
		 * @throws ArgumentNullException if {@code ioLine == null} or 
		 *                              if {@code ioValue == null}.
		 * @throws TimeoutException if there is a timeout sending the set DIO 
		 *                          command.
		 * @throws XBeeException if there is any other XBee related exception.
		 * 
		 * @see #getIOConfiguration(IOLine)
		 * @see #setIOConfiguration(IOLine, IOMode)
		 * @see com.digi.xbee.api.io.IOLine
		 * @see com.digi.xbee.api.io.IOValue
		 * @see com.digi.xbee.api.io.IOMode#DIGITAL_OUT_HIGH
		 * @see com.digi.xbee.api.io.IOMode#DIGITAL_OUT_LOW
		 */
		public void setDIOValue(IOLine ioLine, IOValue ioValue)/*throws TimeoutException, XBeeException */{
			// Check IO line.
			if (ioLine == null)
				throw new ArgumentNullException("IO line cannot be null.");
			// Check IO value.
			if (ioValue == null)
				throw new ArgumentNullException("IO value cannot be null.");
			// Check connection.
			if (!connectionInterface.SerialPort.IsOpen)
				throw new InterfaceNotOpenException();

			SetParameter(ioLine.GetConfigurationATCommand(), new byte[] { (byte)ioValue.GetID() });
		}
 public void SetInputPointStateBackups(IO_IN_Type Point, IOValue Value)
 {
     m_InputPointStateBackups[(int)Point] = Value;
 }