Ejemplo n.º 1
0
        void ¼ì²éµÆ״̬(IPEndPoint ipEndPoint)
        {
            DeviceCommandManager.setCommandCallback(enumDeviceCommand.²éѯÂ̵Æ״̬,
                                                    (data) =>
            {
                Debug.WriteLine("Â̵Æ״̬ => " + data);
                IDeviceCommand idc = DeviceCommandManager.getDeivceCommand(enumDeviceCommand.²éѯÂ̵Æ״̬);
                if (null != idc)
                {
                    LightState ls = idc.parseResponse(data);
                    if (null != ls && last_command != null)
                    {
                        bool temp = (last_command.Name == "open") ? true : false;
                        if (ls.State == temp)   //µÆÏÖÔÚµÄ״̬ºÍ²Ù×÷Ä¿±ê״̬Ïàͬ£¬Í¬Îª¹Ø»òÕß¿ª
                        {
                            switch (last_command.Name)
                            {
                            case "open":
                                Debug.WriteLine(string.Format("{0} ´ò¿ªÂ̵Æ", last_command.Commander));
                                command ncOpen         = new command("open", string.Format("{0}´ò¿ªÁ˵Æ", last_command.Commander));
                                last_effective_command = ncOpen;
                                recently_broadcast     = JsonConvert.SerializeObject(ncOpen);
                                this.Broadcast(recently_broadcast);
                                break;

                            case "close":
                                Debug.WriteLine(string.Format("{0} ¹Ø±ÕÂ̵Æ", last_command.Commander));
                                command ncClose        = new command("close", string.Format("{0}¹Ø±ÕÁ˵Æ", last_command.Commander));
                                last_effective_command = ncClose;
                                recently_broadcast     = JsonConvert.SerializeObject(ncClose);
                                this.Broadcast(recently_broadcast);
                                break;
                            }
                        }
                        else   //˵Ã÷É豸ûÓÐÏìÓ¦£¬Í¨Öª¿Í»§¶Ë
                        {
                            switch (ls.State)
                            {
                            case true:
                                command ncOpen     = new command("open", "²Ù×÷ʧ°Ü");
                                recently_broadcast = JsonConvert.SerializeObject(ncOpen);
                                this.Send(recently_broadcast);       //ֻ֪ͨ±¾ÈË
                                Debug.WriteLine("¹Ø±ÕÂ̵ƲÙ×÷ʧ°Ü");
                                break;

                            case false:
                                command ncClose    = new command("close", "²Ù×÷ʧ°Ü");
                                recently_broadcast = JsonConvert.SerializeObject(ncClose);
                                this.Send(recently_broadcast);
                                Debug.WriteLine("´ò¿ªÂ̵ƲÙ×÷ʧ°Ü");
                                break;
                            }
                        }
                    }
                }
            });
            DeviceCommandManager.executeCommand(enumDeviceCommand.²éѯÂ̵Æ״̬, ipEndPoint, 1000);
        }
Ejemplo n.º 2
0
        void 检查风扇状态(IPEndPoint ipEndPoint)
        {
            DeviceCommandManager.setCommandCallback(enumDeviceCommand.查询风扇状态,
                                                    (data) =>
            {
                Debug.WriteLine("风扇状态 => " + data);
                IDeviceCommand idc = DeviceCommandManager.getDeivceCommand(enumDeviceCommand.查询风扇状态);
                if (null != idc)
                {
                    LightState ls = idc.parseResponse(data);
                    if (null != ls && last_command != null)
                    {
                        bool temp = (last_command.Name == "open") ? true : false;
                        if (ls.State == temp)   //灯现在的状态和操作目标状态相同,同为关或者开
                        {
                            switch (last_command.Name)
                            {
                            case "open":
                                Debug.WriteLine(string.Format("{0} 打开风扇", last_command.Commander));
                                command ncOpen         = new command("open", string.Format("{0}打开了风扇", last_command.Commander));
                                last_effective_command = ncOpen;
                                recently_broadcast     = JsonConvert.SerializeObject(ncOpen);
                                this.Broadcast(recently_broadcast);
                                break;

                            case "close":
                                Debug.WriteLine(string.Format("{0} 关闭风扇", last_command.Commander));
                                command ncClose        = new command("close", string.Format("{0}关闭了风扇", last_command.Commander));
                                last_effective_command = ncClose;
                                recently_broadcast     = JsonConvert.SerializeObject(ncClose);
                                this.Broadcast(recently_broadcast);
                                break;
                            }
                        }
                        else   //说明设备没有响应,通知客户端
                        {
                            switch (ls.State)
                            {
                            case true:
                                command ncOpen     = new command("open", "操作失败");
                                recently_broadcast = JsonConvert.SerializeObject(ncOpen);
                                this.Send(recently_broadcast);       //只通知本人
                                Debug.WriteLine("关闭风扇操作失败");
                                break;

                            case false:
                                command ncClose    = new command("close", "操作失败");
                                recently_broadcast = JsonConvert.SerializeObject(ncClose);
                                this.Send(recently_broadcast);
                                Debug.WriteLine("打开风扇操作失败");
                                break;
                            }
                        }
                    }
                }
            });
            DeviceCommandManager.executeCommand(enumDeviceCommand.查询风扇状态, ipEndPoint, 1000);
        }
Ejemplo n.º 3
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            command temp = new command();

            temp.reportID = REPORT_ID_KEYBOARD;
            temp.length   = 8;
            commandList.Add(temp);
            refreshListBox();
        }
Ejemplo n.º 4
0
 public static void Close(string[] args)
 {
     Listener.Abort();
     Client.Send("<$>closecmd");
     ClientManager.ReadClients = true;
     Commands["directcmd"]     = new command(Run);
     Commands.Remove("closecmd");
     Console.WriteLine("Closed directcmd");
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Used to modify DB of commands. Either Update or Create.
 /// </summary>
 /// <param name="MS"></param>
 static void MasterCommandModify(MasterCommand MS)
 {
     //check if all values required for operation are set properly
     if (MS.commandId.Length > 0 && MS.argumentLengths.Length > 0 && MS.argumentTypes.Length > 0 && MS.commandName.Length > 0 && MS.description.Length > 0)
     {
         int cmdId;
         int.TryParse(MS.commandId, out cmdId);
         command cmd = new command()
         {
             argumentLengths = MS.argumentLengths,
             argumentTypes   = MS.getArgumentTypesAsByteArray(),
             commandName     = MS.commandName,
             arguments       = MS.getArgumentsAsBitArray(),
             description     = MS.description
         };
         Console.WriteLine("\n\nPRINTING PASSED ARGUMENTS OF COMMAND PASSED BY JOSH THROUGH LOCALHOST: \n");
         utilities.PrintCommandArguments(cmd);
         if (MS.createNewCommand)
         {
             if (db.commands.Where(c => c.Key == cmdId).Count() != 0)
             {
                 //fails, command with that ID already exists!!!
                 Console.WriteLine("\nFailed to insert command to DB. Command of id {0} already exists.\n\n", cmdId);
                 sendResponse(MS, false, "The command with id " + cmdId + " could not be added to DB since a command with same ID already exists. Why don't you try updating it instead fam?.");
             }
             else
             {
                 db.commands.Add(cmdId, cmd);
                 //Success
                 Console.WriteLine("SUCCESSFULLY ADDED CMD WITH {0}\n\n", cmdId);
                 sendResponse(MS, true, "Command of id " + cmdId + " has been added to the DB successfully.");
             }
         }
         else
         {
             if (db.commands.Where(c => c.Key == cmdId).Count() == 0)
             {
                 //fails, command with that ID does not exist, so cannot update
                 Console.WriteLine("Failed to update command of id {0} since no such command exists in DB.", cmdId);
                 sendResponse(MS, false, "The command you are trying to update does not exist. Check that the command with ID " + cmdId + " exists first.");
             }
             else
             {
                 db.commands[cmdId] = cmd;
                 //Success
                 Console.WriteLine("SUCCESSFULLY UPDATED CMD OF ID {0}\n\n", cmdId);
                 sendResponse(MS, true, "Command of id " + cmdId + " has been updated successfully.");
             }
         }
     }
     else
     {
         //fail instantly
         Console.WriteLine("Could not run MODIFY command since some of the mandatory fields in Master Command are not valid.\n\n");
         sendResponse(MS, false, "Issue adding command, some of the mandatory fields are empty! Check what values you are passing pls.");
     }
 }
Ejemplo n.º 6
0
 public Player(command _command, string name, int map, IPAddress ip, Point p, Color c)
 {
     Command = _command;
         Name = name;
         Map_num = map;
         IP = ip;
         Points = p;
         Color = c;
 }
Ejemplo n.º 7
0
        private void sendInitialInfo(WebSocket ws, command command)
        {
            ws.Send(JsonConvert.SerializeObject(command));

            //initialCommandList.ForEach(command =>
            //{
            //    ws.Send(JsonConvert.SerializeObject(command));
            //});
        }
Ejemplo n.º 8
0
 public internalcmds()
 {
     Commands["run"]       = new command(Run);
     Commands["print"]     = new command(Print);
     Commands["info"]      = new command(Info);
     Commands["close"]     = new command(Close);
     Commands["directcmd"] = new command(DirectCmd.Run);
     Commands["closecmd"]  = new command(DirectCmd.Close);
 }
Ejemplo n.º 9
0
        //////////////////////////////////////////////////////////////////////

        private void send_message(command type, ushort start, ushort registers, ref byte[] message)
        {
            if (address == 0)
            {
                throw new ApplicationException($"Device address has not been set");
            }
            init_message(type, start, registers, ref message);
            write(message, message.Length);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Sends a command to destination MAC. Either send a command in its default state as its in DB of commands or with custom arguments if they are passed
        /// </summary>
        /// <param name="MS"></param>
        static void MasterCommandSend(MasterCommand MS)
        {
            if ((MS.commandId.Length > 0 || MS.commandName.Length > 0) && MS.destinationMAC.Length > 0)
            {
                int commandId;
                if (MS.commandId == "")
                {
                    commandId = db.commands.Where(c => c.Value.commandName.ToLower() == MS.commandName).Select(c => c.Key).FirstOrDefault();
                }
                else
                {
                    int.TryParse(MS.commandId, out commandId);
                }
                if (db.commands.Where(c => c.Key == commandId).Count() > 0)// COMMAND EXISTS IN DB!!!
                {
                    command cmd = db.commands[(int)commandId];
                    //If custom arguments are passed, set them. REMEMBER TO KEEP SAME ORDER OF BITS AND LENGTH AS argumentLengths and argumentTypes on specific command in DB
                    //this updates db every time we send new arguments, a feature we wanted! This way next time default args are sent it will be the last ones sent
                    if (MS.arguments.Count > 0)
                    {
                        cmd.arguments = MS.getArgumentsAsBitArray();
                    }

                    Console.WriteLine("\n\nPRINTING ARGUMENTS OF COMMAND ABOUT TO BE SENT\n");

                    utilities.PrintCommandArguments(cmd);

                    Console.WriteLine("Command packet generated and about to be sent.\n COMMAND ID: {0} \n COMMAND NAME: {1}\n", commandId, cmd.commandName);

                    //Send packet to destination mac address via ethernet layer

                    Regex validMAC = new Regex("^([0-9A-F]{2}[:-]){5}([0-9A-F]{2})$");
                    if (validMAC.IsMatch(MS.destinationMAC))
                    {
                        PacketSender(cmd, MS.destinationMAC);
                        Console.WriteLine("Command packet WAS SENT SUCCESSFULLY.\n COMMAND ID: {0} \n COMMAND NAME: {1}\n\n", commandId, cmd.commandName);
                        sendResponse(MS, true, "Command of id " + commandId + " has been sent to destination MAC successfully.");
                    }
                    else
                    {
                        Console.WriteLine("Command of id " + commandId + " could not be sent to destination MAC since the MAC given is incorrect in format\n\n");
                        sendResponse(MS, false, "Command of id " + commandId + " could not be sent to destination MAC since the MAC given is incorrect in format:  " + MS.destinationMAC);
                    }
                }
                else
                {
                    //failed
                    Console.WriteLine("Could not find command in DB since the id/name are not present.\n\n");
                    sendResponse(MS, false, "Command could not be found in the DB, make sure the command ID or command Name exist first.");
                }
            }
            else
            {
                Console.WriteLine("Could not run SEND command since some of the mandatory fields in Master Command are not valid.\n\n");
                sendResponse(MS, false, "Command could not be sent since some of the required Master Command object properties are not set.");
            }
        }
        /// <summary>
        /// For an editor_command - perform an action associated with a hovered element.
        /// Ui specific action handled inside GUI. Other action should be forwarded back to calling class.
        /// </summary>
        /// <param name="c">command enum value</param>
        /// <returns>action that will be performed</returns>
        public actions?ui_command(command c)
        {
            actions?current = null;

            if (hovered_unit != null || hovered_container != null) // hover exists
            {
                switch (c)
                {
                case command.left_click:
                    current = get_current_action();
                    break;

                case command.left_hold:
                    current = get_current_action();
                    break;

                case command.left_release:
                    current = get_current_action();
                    break;

                default:
                    current = null;
                    break;
                }
            }
            else // no hover
            {
                switch (c)
                {
                case command.left_click:     // clicking outside GUI - if context menu is active send an action to Editor host class
                {
                    if (find_container("context menu", true) != null)
                    {
                        if (find_container("context menu", true).is_visible())
                        {
                            current = actions.hide_menu;
                        }
                        else
                        {
                            return(null);
                        }
                    }
                }
                break;

                case command.right_click:
                    current = actions.overall_context;     // this action does not depend on any hover, hover must not exist
                    break;

                default:
                    break;
                }
            }

            return(current);
        }
Ejemplo n.º 12
0
        private void button1_Click(object s, EventArgs oe)
        {
            if (wsGPS == null)
            {
                this.initial_web_sockets();
            }
            else
            {
                command c = new command("open", "gps");
                //c.Data = "data";
                wsGPS.Send(JsonConvert.SerializeObject(c));
            }
            //using (WebSocket ws = new WebSocket("ws://localhost:4649/GPS"))
            //{
            //    ws.OnOpen += (sender, e) =>
            //    {
            //        ws.Send("Hi, 张!");
            //    };

            //    ws.OnMessage += (sender, e) =>
            //    {
            //        Debug.WriteLine(string.Format("OnMessage => {0}", e.Data));
            //    };

            //    ws.OnError += (sender, e) =>
            //    {
            //        Debug.WriteLine(string.Format("OnError => {0}", e.Message));
            //    };

            //    ws.OnClose += (sender, e) =>
            //    {
            //        Debug.WriteLine(string.Format("OnClose => {0}", e.Data));
            //    };

            //    ws.Connect();

            //Thread.Sleep(500);
            //Debug.WriteLine("\nType \"exit\" to exit.\n");

            //string data;
            //while (true)
            //{
            //    Thread.Sleep(500);

            //    Debug.Write("> ");
            //    data = Console.ReadLine();
            //    if (data == "exit")
            //    //if (data == "exit" || !ws.IsAlive)
            //    {
            //        break;
            //    }

            //    ws.Send(data);
            //}
            //}
        }
Ejemplo n.º 13
0
 public void run(command cmd, TextBlock processbox)
 {
     processbox.Text = "Trying connect VPN...";
     cmd.go("powershell Add-VpnConnection -Name \"Evans_ChikaVPN\" -ServerAddress \"vpn1.chika.kr\" -TunnelType L2tp -L2tpPsk railgun\n\ny\n");
     Thread.Sleep(3000);
     processbox.Text += "\nTrying login VPN...";
     cmd.go("powershell rasdial Evans_ChikaVPN sunrin1 tsuki");
     processbox.Text += "\nConnecting VPN complete!";
     MessageBox.Show("Connecting VPN complete!");
 }
Ejemplo n.º 14
0
        public DataTable coba()
        {
            DataTable dt = new DataTable();

            cmd = new command();
            cmd.openCon();
            dt = cmd.executeQuery(@"SELECT *FROM [dbo].[coba]");
            cmd.closeCon();
            return(dt);
        }
Ejemplo n.º 15
0
        //////////////////////////////////////////////////////////////////////
        // assumes the message body is already set up

        private void init_message(command type, ushort start, ushort registers, ref byte[] message)
        {
            message[0] = address;
            message[1] = (byte)type;
            message[2] = (byte)(start >> 8);
            message[3] = (byte)start;
            message[4] = (byte)(registers >> 8);
            message[5] = (byte)registers;
            checksum.set(message, message.Length);
        }
Ejemplo n.º 16
0
        //DATA PRODUK
        public DataTable getProduk()
        {
            DataTable dt = new DataTable();

            cmd = new command();
            cmd.openCon();
            dt = cmd.executeQuery(@"SELECT *FROM [dbo].[tb_barang]");
            cmd.closeCon();
            return(dt);
        }
Ejemplo n.º 17
0
        //Data KATEGORI

        public DataTable getKategori()
        {
            DataTable dt = new DataTable();

            cmd = new command();
            cmd.openCon();
            dt = cmd.executeQuery(@"SELECT *FROM [dbo].[tb_kategori]");
            cmd.closeCon();
            return(dt);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Sends a command through selected network device on layer 1
        /// </summary>
        /// <param name="cmd">command object</param>
        /// <param name="destinationMAC">the Manufacturer Device's MAC address</param>
        static void PacketSender(command cmd, string destinationMAC)
        {
            Console.WriteLine("Select which device to send packet through");
            // Retrieve the device list from the local machine
            IList <LivePacketDevice> allDevices = LivePacketDevice.AllLocalMachine;

            if (allDevices.Count == 0)
            {
                Console.WriteLine("No interfaces found! Make sure WinPcap is installed.");
                return;
            }
            // Print the list
            for (int i = 0; i != allDevices.Count; ++i)
            {
                LivePacketDevice device = allDevices[i];

                Console.Write((i + 1) + ". " + device.Name);
                if (device.Description != null)
                {
                    Console.WriteLine(" (" + device.Description + ")");
                }
                else
                {
                    Console.WriteLine(" (No description available)");
                }
            }

            int deviceIndex = 0;

            do
            {
                Console.WriteLine("Enter the interface number (1-" + allDevices.Count + ") to send through:");
                string deviceIndexString = Console.ReadLine();
                if (!int.TryParse(deviceIndexString, out deviceIndex) ||
                    deviceIndex < 1 || deviceIndex > allDevices.Count)
                {
                    deviceIndex = 0;
                }
            } while (deviceIndex == 0);

            // Take the selected adapter
            PacketDevice selectedDevice = allDevices[deviceIndex - 1];

            // Open the device
            using (PacketCommunicator communicator =
                       selectedDevice.Open(65536,                                  // portion of the packet to capture
                                                                                   // 65536 guarantees that the whole packet will be captured on all the link layers
                                           PacketDeviceOpenAttributes.Promiscuous, // promiscuous mode
                                           1000))                                  // read timeout
            {
                int    commandId    = db.commands.Where(c => c.Value.commandName.ToLower() == cmd.commandName.ToLower()).Select(c => c.Key).FirstOrDefault();
                Packet packetToSend = BuildEthernetPacket(LivePacketDeviceExtensions.GetMacAddress(allDevices[deviceIndex - 1]).ToString(), destinationMAC, utilities.CreateCommandBytesForSending(commandId, cmd.arguments));
                communicator.SendPacket(packetToSend);
            }
        }
Ejemplo n.º 19
0
        public bool key(command command)
        {
            switch (command)
            {
            case command.Left:
                return(game.key("a"));

            case command.Right:
                return(game.key("d"));

            case command.Jump:
                return(game.key("space"));

            case command.ChangeMouseState:
                return(game.key("m"));

            case command.Pause:
                var state = game.key("p");
                if (state)
                {
                    if (PauseWasPressed == true)
                    {
                        return(false);
                    }
                    PauseWasPressed = true;
                    return(state);
                }
                else
                {
                    PauseWasPressed = false;
                    return(state);
                }

            case command.OpenInventory:
                var State = game.key("e");
                if (State)
                {
                    if (InventoryWasPressed == true)
                    {
                        return(false);
                    }
                    InventoryWasPressed = true;
                    return(State);
                }
                else
                {
                    InventoryWasPressed = false;
                    return(State);
                }

            case command.Action:
                return(Mouse.pressed);
            }
            return(false);
        }
Ejemplo n.º 20
0
        public void MCOpen()
        {
            command _cmd = new command(stateName.打开, "");

            _cmd.TargetDevice = TargetDeiveName.GPS;
            _cmd.id           = this._context.Id.ToString();
            string msg = JsonConvert.SerializeObject(_cmd);

            Debug.WriteLine(string.Format("GPSService OnMessage => {0}", msg));
            FuncModuleManager.OnMessage(msg);
        }
Ejemplo n.º 21
0
        public void Compiler(string commandline)
        {
            string[] buf = commandline.Split(' ');
            param = "";

            switch (buf[0])
            {
            case "init":
                current = command.init;
                break;

            case "add":
                current = command.add;
                break;

            default: throw new Exception("Неверная команда!");
            }
            buf.CopyTo(buf, 1);

            if (buf.Length > 1)
            {
                switch (buf[1])
                {
                case "add": subcommand = command.add; break;

                default: subcommand = command.no; break;
                }
                buf.CopyTo(buf, 1);
            }

            for (int i = 0; i < buf.Length; i++)
            {
                if (i % 2 == 1)
                {
                    Column bf = listOfCol.Find(
                        delegate(Column inp)
                    {
                        return(inp.Name == buf[i] || inp.Nick == buf[i]);
                    }
                        );
                    if (bf != null)
                    {
                        throw new Exception("Неверная имя/сокращение столбца!");
                    }
                    param += bf.colNumber.ToString() + " ";
                }
                else
                {
                    param += buf[i] + " ";
                }
            }

            Execute();
        }
Ejemplo n.º 22
0
 private void button4_Click(object sender, EventArgs e)
 {
     if (null == wsUHF)
     {
         this.initial_web_sockets();
     }
     else
     {
         command c = new command("close", "uhf");
         wsUHF.Send(JsonConvert.SerializeObject(c));
     }
 }
Ejemplo n.º 23
0
 public ActionResult EditB(command command)
 {
     try
     {
         var APIResponse = httpClient.PutAsJsonAsync <command>(baseAddress + "updatecommande/", command).ContinueWith(postTask => postTask.Result.EnsureSuccessStatusCode());
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Ejemplo n.º 24
0
 private void button3_Click(object sender, EventArgs e)
 {
     if (wsGPS == null)
     {
         this.initial_web_sockets();
     }
     else
     {
         command c = new command("close", "gps");
         wsGPS.Send(JsonConvert.SerializeObject(c));
     }
 }
Ejemplo n.º 25
0
 public ActionResult DeleteB(long reference, command command)
 {
     try
     {
         var tokenResponse = httpClient.DeleteAsync(baseAddress + "deleteByReference/" + reference).Result;
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
        public RemoteControlWithUndo()
        {
            onCommands = new command[7];
            offCommands = new command[7];

            command noCommand = new NoCommand();
            for (int i = 0; i < 7; i++)
            {
                onCommands[i] = noCommand;
                offCommands[i] = noCommand;
            }
            undoCommand = noCommand;
        }
Ejemplo n.º 27
0
        public DataTable getKategori(string kode_kategori)
        {
            DataTable dt = new DataTable();

            cmd = new command();
            List <SqlParameter> param = new List <SqlParameter>();

            param.Add(new SqlParameter("@kode_kategori", kode_kategori));
            cmd.openCon();
            dt = cmd.executeQuery(@"SELECT *FROM [dbo].[tb_kategori] WHERE [kode_kategori]=@kode_kategori", param);
            cmd.closeCon();
            return(dt);
        }
Ejemplo n.º 28
0
    void Start()
    {
        acivHeart1.gameObject.SetActive(false);
        acivHeart2.gameObject.SetActive(false);
        acivHeart3.gameObject.SetActive(false);
        animator = GetComponent <Animator>();
        restartDialog.SetActive(false);
        command cm = new command();

        // cm.wez=('a');
        klawisz = cm.wez;
        //cm.wez = 'a';
    }
Ejemplo n.º 29
0
        public DataTable getStok(string kode_produk)
        {
            DataTable dt = new DataTable();

            cmd = new command();
            List <SqlParameter> param = new List <SqlParameter>();

            param.Add(new SqlParameter("@kode_produk", kode_produk));
            cmd.openCon();
            dt = cmd.executeQuery(@"SELECT *FROM [dbo].[tb_stok] WHERE [kode_produk]=@kode_produk", param);
            cmd.closeCon();
            return(dt);
        }
Ejemplo n.º 30
0
        public void setDevice(ModuleCommand.command cmd, Action <ModuleCommand.command> callback)
        {
            myCallBack = callback;
            myCommand  = cmd;

            rfid_helper = new TDJ_RFIDHelper();

            //打开UDP端口,等待数据传入
            this.updServer         = UDPServer.getUDPServer(Program.UHF_UDP_Port);
            updServer.evtReceived += new OnReceiveString(updServer_evtReceived);
            updServer.startUDPListening();

            Debug.WriteLine(string.Format("*****  UHFDevice onListening... "));
        }
Ejemplo n.º 31
0
        /// <summary>
        /// app发送指令
        /// </summary>
        /// <param name="shipId"></param>
        /// <param name="comm"></param>
        /// <returns></returns>
        public bool AppSendCommand(int shipId, string comm)
        {
            waterdataEntities entity     = new waterdataEntities();
            command           newcommand = new command()
            {
                ship_id     = shipId,
                command1    = comm,
                create_time = DateTime.Now
            };

            entity.command.Add(newcommand);
            entity.SaveChanges();
            return(true);
        }
Ejemplo n.º 32
0
	// Use this for initialization
	public void Start () {
		commandQueue = new command[commandQueueSize];
		selected = null;
		destroyHighlighting = false;
		highlighting = false;
		colRadius = gameObject.GetComponent<CircleCollider2D>().radius;
		selectedAsset = transform.parent.gameObject.GetComponent<teamScript>().selectedAsset;
		highlightAsset = transform.parent.gameObject.GetComponent<teamScript>().highlightAsset;
		activatedAsset = transform.parent.gameObject.GetComponent<teamScript>().activatedAsset;
		unitsLayer = transform.parent.parent.gameObject.GetComponent<allTeamsScript>().unitsLayer;
		commandQueueSize = transform.parent.parent.gameObject.GetComponent<allTeamsScript>().commandQueueSize;
		_healthBar = transform.GetComponentInChildren<healthBarScript>();
		startFun();
	}
Ejemplo n.º 33
0
        public void setDevice(ModuleCommand.command cmd, Action <ModuleCommand.command> callback)
        {
            myCallBack = callback;
            myCommand  = cmd;
            switch (cmd.Name)
            {
            case stateName.打开:
                打开风扇(Program.getRemoteIPEndPoint());
                break;

            case stateName.关闭:
                关闭风扇(Program.getRemoteIPEndPoint());
                break;
            }
        }
Ejemplo n.º 34
0
 // function
 /// <summary>
 /// input comman
 /// </summary>
 /// <param name="cmd">Cmd.</param>
 public void input(command cmd)
 {
     cmd_que.Enqueue(cmd);
 }
Ejemplo n.º 35
0
 // Use this for initialization
 void Start()
 {
     this.cmd_que = new Queue();
     this.status = command.idle;
     this.time = 0f;
     this.enemy_hp_num = this.hp_max;
 }
Ejemplo n.º 36
0
	private void saveCommand(int index, int action, bool onUnit, Vector2 mousePosition, unitController unit){
		if(index < commandQueueSize)
			commandQueue[index] = new command(action, onUnit, mousePosition, unit);
	}
Ejemplo n.º 37
0
 public command(command rhs)
 {
     command_camera_num = rhs.command_camera_num;
 }
 public Node_Attack_Activate_Weapon(command weapon, IGameUnit caster)
 {
     m_weapon = weapon;
     m_caster = caster;
 }
Ejemplo n.º 39
0
 public static void AddCommand(int _number, Color _color)
 {
     command cmd = new command (_number, _color, 0,0);
 }
 public void setCommand(command command)
 {
     slot = command;
 }
Ejemplo n.º 41
0
        /// <summary>
        /// Sends a packet to the instrument and expects a reply
        /// </summary>
        /// <param name="cmd">Enumerated type of instrument command</param>
        /// <param name="data">Data packet to send to the device</param>
        /// <returns>Data packet returned by the device</returns>
        private byte[] msgSendGetReply(command cmd, byte[] data)
        {
            byte[] b = new byte[packetLength];

            //packet: startbyte, addr, command, data[..], checksum
            b[0] = STARTBYTE;
            b[1] = address;
            b[2] = (byte)cmd;
            Array.Copy(data, 0, b, 3, data.Length);
            b[25] = (byte)(computeChecksum(b));    //checksum is the sum, modulo 256

            return serialTransaction(b);  //just returns the datapacket
        }
Ejemplo n.º 42
0
 //overload for messages without data
 private void msgSend(command cmd)
 {
     byte[] b = new byte[0];
     msgSend(cmd, b);
 }
Ejemplo n.º 43
0
 /// <summary>
 /// Sends 24 byte packet to the instrument
 /// </summary>
 /// <param name="cmd"></param>
 /// <param name="data"></param>
 private void msgSend(command cmd, byte[] data)
 {
     msgSendGetReply(cmd, data);
 }
 public void setCommand(int slot, command onCommand, command offCommand)
 {
     onCommands[slot] = onCommand;
     offCommands[slot] = offCommand;
 }
 public void onButtonWasPushed(int slot)
 {
     onCommands[slot].execute();
     undoCommand = onCommands[slot];
 }
Ejemplo n.º 46
0
 public MacroCommand(command[] commands)
 {
     this.commands = commands;
 }
Ejemplo n.º 47
0
 // exec cmd
 private void _setStatus(command cmd)
 {
     this.status = cmd;
 }
Ejemplo n.º 48
0
 public static void AddCommand(int _number, int _labelNum)
 {
     command cmd = new command(_number,Color.black,1,_labelNum);
 }
 public Node_Activate_Ability(command ability, IGameUnit caster)
 {
     m_ability = ability;
     m_caster = caster;
 }
Ejemplo n.º 50
0
 public commandBase(string _text, command _command)
 {
     executec = _command;
     text = _text;
 }
Ejemplo n.º 51
0
 //overload for messages without data
 private byte[] msgSendGetReply(command cmd)
 {
     byte[] b = new byte[0];
     return msgSendGetReply(cmd, b);
 }
Ejemplo n.º 52
0
 public void deep_clone(command rhs)
 {
     command_camera_num = rhs.command_camera_num;
 }