コード例 #1
0
        /// <summary>
        /// Use this to check that the arguments you passed through localhost's Master Command are sent, received and parsed correctly to general Object ready to use!
        /// </summary>
        /// <param name="receivedCommandThroughLocalhost"></param>
        public static void PrintCommandArguments(command receivedCommandThroughLocalhost)
        {
            List <Object> argumentsInBitsToObjects = BitArrayToListObject(receivedCommandThroughLocalhost.arguments, receivedCommandThroughLocalhost.argumentLengths, receivedCommandThroughLocalhost.argumentTypes);;

            int count = 1;

            foreach (Object o in argumentsInBitsToObjects)
            {
                Console.WriteLine((count++) + ". " + o.ToString() + "\n");
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: kaloyanBozhkov/NetProject
        /// <summary>
        /// Used to output received command packet's info
        /// </summary>
        /// <param name="cmdId"></param>
        /// <param name="arguments"></param>
        private static void printReceivedCommandPacketDetails(int cmdId, BitArray arguments)
        {
            command cmd = db.commands.Where(c => c.Key == cmdId).Select(c => c.Value).FirstOrDefault();

            if (cmd == null)
            {//if no command with such ID found, then the HUB has a command with X id in its db that was
             //attempted to run on this device which does not have said command
                Console.WriteLine("\nA valid command was received but it is not registered with this device yet.\n");
            }
            else
            {
                List <Object> argumentsAsVar = utilities.BitArrayToListObject(arguments, cmd.argumentLengths, cmd.argumentTypes);

                Console.WriteLine("\nPrinting arguments of the received command packet of ID {0} and name {1}:\n", cmdId, cmd.commandName);
                int c = 0;
                foreach (var obj in argumentsAsVar)
                {
                    Console.WriteLine("Argument n. {0} is of type {1} and has a value of {2}.\n",
                                      (c += 1), obj.GetType().ToString(), obj.ToString());
                }
                //no point in printing expected argument Length and actual Length because there already are checks when
                //parsing from BitArray to list of objects, same for argument types!!
            }
        }