Esempio n. 1
0
        //TODO: getMsgLenFromType: check test runs for this function
        /// <summary>
        /// Returns the expected byte message length for a specific message type.
        /// </summary>
        /// <param name="msgType">Message type to find length of.</param>
        /// <returns>The expected byte length of the passed in message type.</returns>
        public static int getMsgLenFromType(CNCRMSG_TYPE msgType)
        {
            switch (msgType)
            {
            case CNCRMSG_TYPE.CMD_ACKNOWLEDGE:
                return(CNCRConstants.MSG_LEN_CMD_ACK);

            case CNCRMSG_TYPE.E_STOP:
                return(CNCRConstants.MSG_LEN_ESTOP);

            case CNCRMSG_TYPE.MOVE:
                return(CNCRConstants.MSG_LEN_MOVE);

            case CNCRMSG_TYPE.PING:
                return(CNCRConstants.MSG_LEN_PING);

            case CNCRMSG_TYPE.REQUEST_COMMAND:
                return(CNCRConstants.MSG_LEN_RQST_COMM);

            case CNCRMSG_TYPE.SET_SPEED:
                return(CNCRConstants.MSG_LEN_SETSPD);

            case CNCRMSG_TYPE.START_QUEUE:
                return(CNCRConstants.MSG_LEN_STARTQ);

            case CNCRMSG_TYPE.TOOL_CMD:
                return(CNCRConstants.MSG_TOOL_CMD);

            default:
                throw new ArgumentException("msgType of "
                                            + msgType.ToString() + " has no defined length.",
                                            "msgType");
            }
        }
Esempio n. 2
0
 public override string ToString()
 {
     return("[ " + _msgType.ToString() +
            " - " + _priority.ToString() +
            " - ID: " + _msgID +
            " (" + CNCRTools.BytesToHex(this.toSerial()) + ") ]");
 }
Esempio n. 3
0
 //TODO: getMsgLenFromType: check test runs for this function
 /// <summary>
 /// Returns the expected byte message length for a specific message type.
 /// </summary>
 /// <param name="msgType">Message type to find length of.</param>
 /// <returns>The expected byte length of the passed in message type.</returns>
 public static int getMsgLenFromType(CNCRMSG_TYPE msgType)
 {
     switch (msgType)
     {
         case CNCRMSG_TYPE.CMD_ACKNOWLEDGE:
             return CNCRConstants.MSG_LEN_CMD_ACK;
         case CNCRMSG_TYPE.E_STOP:
             return CNCRConstants.MSG_LEN_ESTOP;
         case CNCRMSG_TYPE.MOVE:
             return CNCRConstants.MSG_LEN_MOVE;
         case CNCRMSG_TYPE.PING:
             return CNCRConstants.MSG_LEN_PING;
         case CNCRMSG_TYPE.REQUEST_COMMAND:
             return CNCRConstants.MSG_LEN_RQST_COMM;
         case CNCRMSG_TYPE.SET_SPEED:
             return CNCRConstants.MSG_LEN_SETSPD;
         case CNCRMSG_TYPE.START_QUEUE:
             return CNCRConstants.MSG_LEN_STARTQ;
         case CNCRMSG_TYPE.TOOL_CMD:
             return CNCRConstants.MSG_TOOL_CMD;
         default:
             throw new ArgumentException("msgType of "
                 + msgType.ToString() + " has no defined length.",
                 "msgType");
     }
 }