public static async Task SendAdminMenu() { if (!await AsyncCamCom.TryConnect().ConfigureAwait(false)) { return; } AsyncCamCom.SendNonAsync(new byte[] { 0xFF, 0x01, 0x00, 0x07, 0x00, 0xFB, 0x03 }); AsyncCamCom.SendNonAsync(new byte[] { 0xFF, 0x01, 0x00, 0x07, 0x00, 0xFD, 0x05 }); AsyncCamCom.SendNonAsync(new byte[] { 0xFF, 0x01, 0x00, 0x07, 0x00, 0xFC, 0x04 }); AsyncCamCom.SendNonAsync(new byte[] { 0xFF, 0x01, 0x00, 0x07, 0x00, 0xFE, 0x06 }); }
public static async Task QuickCommand(string command, bool sendAsync = true, int manualAdr = -5) { try { if (!await AsyncCamCom.TryConnect().ConfigureAwait(false)) { MessageBox.Show("Not connected to camera!\nTried sending: " + command); return; } uint adr = Tools.MakeAdr(); if (manualAdr != -5) //if sending preset { adr = Convert.ToUInt32(manualAdr); } ScriptCommand send = CheckForCommands(command, adr, false).Result; if (send.codeContent == PelcoD.noCommand) { if (command.Length == 0) { MessageBox.Show("Command length is 0!\nMake sure to check the command in the settings!"); return; } else { byte[] code = Tools.ConvertMsgToByte(command); if (code == null) { MessageBox.Show("Command invalid!\nMake sure to enter command in the correct format!\n(FF 0x xx xx xx xx yy OR [command] [value])"); return; } send = new ScriptCommand(new string[] { "custom" }, code, "", 0); } } if (!sendAsync) { AsyncCamCom.SendNonAsync(send.codeContent); } else { var t = Task.Factory.StartNew(() => { AsyncCamCom.SendScriptCommand(send); }); Task.WaitAll(); } } catch (Exception e) { Tools.ShowPopup("Failed to send quick command!\nShow more?", "Error Occurred!", e.ToString()); } }