示例#1
0
        //Turn a set of tokens into an operand
        private void parseOperandString(string[] tokens, ref ModifierOperand operand)
        {
            //example string -> bus:0:id:200:d3

            operand.bus      = -1;
            operand.ID       = -2;
            operand.databyte = 0;

            for (int i = 0; i < tokens.Length; i++)
            {
                if (tokens[i] == "BUS")
                {
                    operand.bus = Utility.ParseStringToNum(tokens[++i]);
                }
                else if (tokens[i] == "ID")
                {
                    operand.ID = Utility.ParseStringToNum(tokens[++i]);
                }
                else if (tokens[i].Length == 2 && tokens[i].StartsWith("D"))
                {
                    operand.databyte = Utility.ParseStringToNum(tokens[i].Substring(1));
                }
                else
                {
                    operand.databyte = Utility.ParseStringToNum(tokens[i]);
                    operand.ID       = 0; //special ID to show this is a number not a look up.
                }
            }
        }
示例#2
0
        private int fetchOperand(int idx, ModifierOperand op)
        {
            CANFrame tempFrame;

            if (op.ID == 0) //numeric constant
            {
                return(op.databyte);
            }
            else if (op.ID == -2)
            {
                return(sendingData[idx].data[op.databyte]);
            }
            else //look up external data byte
            {
                tempFrame = lookupFrame(op.ID, op.bus);
                if (tempFrame != null)
                {
                    return(tempFrame.data[op.databyte]);
                }
                else
                {
                    return(0);
                }
            }
        }
示例#3
0
        //Turn a set of tokens into an operand
        private void parseOperandString(string[] tokens, ref ModifierOperand operand)
        {
            //example string -> bus:0:id:200:d3

            operand.bus = -1;
            operand.ID = -2;
            operand.databyte = 0;

            for (int i = 0; i < tokens.Length; i++)
            {
                if (tokens[i] == "BUS")
                {
                    operand.bus = Utility.ParseStringToNum(tokens[++i]);
                }
                else if (tokens[i] == "ID")
                {
                    operand.ID = Utility.ParseStringToNum(tokens[++i]);
                }
                else if (tokens[i].Length == 2 && tokens[i].StartsWith("D"))
                {
                    operand.databyte = Utility.ParseStringToNum(tokens[i].Substring(1));
                }
                else
                {
                    operand.databyte = Utility.ParseStringToNum(tokens[i]);
                    operand.ID = 0; //special ID to show this is a number not a look up.
                }
            }
        }
示例#4
0
 private int fetchOperand(int idx, ModifierOperand op)
 {
     CANFrame tempFrame;
     if (op.ID == 0) //numeric constant
     {
         return op.databyte;
     }
     else if (op.ID == -2)
     {
         return sendingData[idx].data[op.databyte];
     }
     else //look up external data byte
     {
         tempFrame = lookupFrame(op.ID, op.bus);
         if (tempFrame != null)
         {
             return tempFrame.data[op.databyte];
         }
         else return 0;
     }
 }