protected internal virtual TStatusSocket ProcessingData() { const int lengthHead = 8; while (_msReceive.Length > 0) { _msReceive.Position = 0; // read command and length if (_msReceive.Length < lengthHead) { return(TStatusSocket.receiveStream); } commands commandReceive = (commands)_readerReceive.ReadInt32(); int lengthDataReceive = _readerReceive.ReadInt32(); // not complyte receive if (_msReceive.Length < lengthDataReceive + lengthHead) { return(TStatusSocket.receiveStream); } // all received if (_msReceive.Length >= lengthDataReceive + lengthHead) { _msReceive.Position = lengthHead; switch (commandReceive) { case commands.sendString: byte[] buf = new byte[lengthDataReceive]; _msReceive.ms.Read(buf, 0, lengthDataReceive); string str = Encoding.Unicode.GetString(buf); _Log("str " + str); _OnReceive(str); _msReceive.TruncateFromTop(lengthDataReceive + lengthHead); break; case commands.sendFile: _OnError(new Exception("File receive not complit")); _msReceive.Clear(); break; default: _msReceive.Clear(); break; } } } return(TStatusSocket.none); }
public static void OnChatMessage(string m, GameObject sender, int team, commands from = null) { Player p = null; if (sender != null) { p = Players.GetBySteamId(sender.GetComponent <lobbyPlayerManager>().steamID); } Vector3?fromPos = null; if (from != null) { fromPos = from.pc.transform.position; } foreach (var f in _onChatMessage) { try { f(m, p, team, fromPos); } catch (Exception ex) { Console.WriteLine($"OnChatMessage Function Error: {f.Method}"); Console.WriteLine(ex.Message); Console.WriteLine(ex.Source); Console.WriteLine(ex.StackTrace); } } }
void Update() { if (Input.GetKeyUp(KeyCode.Mouse0) && !Input.GetKey(KeyCode.Mouse1)) { if (rectManage.rectOn == false) { Collider2D[] detectedThings = Physics2D.OverlapPointAll(Camera.main.ScreenToWorldPoint(Input.mousePosition)); thingLeftClicked(detectedThings[0].gameObject); } Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto); commandMode = commands.neutral; } if (Input.GetKeyUp(KeyCode.Mouse1) && !Input.GetKey(KeyCode.Mouse0) && targetingCircle.enabled == false) { if (rectManage.rectOn == false) { Collider2D[] detectedThings = Physics2D.OverlapPointAll(Camera.main.ScreenToWorldPoint(Input.mousePosition)); thingRightClicked(detectedThings[0].gameObject); } } if (activeUnits.Count > 0) { if (Input.GetButtonUp("take") && !Input.GetButtonUp("give")) { Cursor.SetCursor(cursorForTaking, Vector2.zero, CursorMode.Auto); commandMode = commands.take; } if (Input.GetButtonUp("give") && !Input.GetButtonUp("take")) { Cursor.SetCursor(cursorForGiving, Vector2.zero, CursorMode.Auto); commandMode = commands.give; } } }
public void processCommand(int CMD, int dist) { commands cmd = intToEnum(CMD); switch (cmd) { case commands.PENUP: // Process pen up command penUp(); break; case commands.PENDWN: // Process pen down command penDown(); break; case commands.RIGHT: turnRight(); break; case commands.LEFT: turnLeft(); break; case commands.FORWARD: move(dist); break; default: break; } }
public ActActConnection(string id, Actuator source, Actuator target, commands sourceCommand, commands targetCommand) : base(id, source, target) { this.id = id; this.source = source; this.target = target; this.targetCommand = targetCommand; this.sourceCommand = sourceCommand; }
public pathNode(float X, float Y, float Radius, float Wait, commands Command) { x = X; y = Y; radius = Radius; wait = Wait; command = Command; }
public SensActConnection(string id, Sensor source, Actuator target, float rightSide, LogicSenActInput.Operatoren condOperator, commands targetCommand) : base(id, source, target) { this.id = id; this.source = source; this.target = target; this.rightSide = rightSide; this.condOperator = condOperator; this.targetCommand = targetCommand; }
public void sendCmd(commands command, int red, int green, int blue) { command_struct_t command_struct; command_struct.command = command; command_struct.redLightValue = red; command_struct.greenLightValue = green; command_struct.blueLightValue = blue; sendCmd(command_struct); }
internal void addCommand(string id, commands.Command newCommand) { if (_commands.ContainsKey(id)) { _commands[id] = newCommand; } else { _commands.Add(id, newCommand); } }
public override async Task DoAsync() { TranslationList rocket = await LoadTranslationsAsync(); if (rocket == null) { await LogInfo("Could not load Rocket translations!"); return; } await LogInfo("Preparing OpenMod translations"); Dictionary <string, string> errors = new Dictionary <string, string>(); foreach (string key in ErrorConversions.Keys) { string value = rocket.Translate(key); string newKey = ErrorConversions[key]; errors.Add(newKey, value); } Dictionary <string, string> others = new Dictionary <string, string>(); foreach (string key in OtherConversions.Keys) { string value = rocket.Translate(key); string newKey = OtherConversions[key]; others.Add(newKey, value); } commands openMod = new commands(others, errors); await LogInfo("Saving OpenMod translations"); await SaveAsync(openMod); }
public string commandString(commands commandNumber) { // 1. Return the command string. return(commandsAsStrings[(int)commandNumber]); }
DenormalizeCommands(commands, prefix + pair.command + " ", pair.reference, result);
public commands create_goTo_msg_from_selectedComboBoxItem(string transitionName, string stepNum) { int step = Convert.ToInt16(stepNum); int msg_num = 0; commands command = 0; switch (transitionName) { case "lineáris": switch (step) { case 2: command = commands.cmd_goTo_Linear_WithStep_2; break; case 5: command = commands.cmd_goTo_Linear_WithStep_5; break; case 10: command = commands.cmd_goTo_Linear_WithStep_10; break; case 15: command = commands.cmd_goTo_Linear_WithStep_15; break; case 30: command = commands.cmd_goTo_Linear_WithStep_30; break; case 50: command = commands.cmd_goTo_Linear_WithStep_50; break; case 65: command = commands.cmd_goTo_Linear_WithStep_65; break; case 80: command = commands.cmd_goTo_Linear_WithStep_80; break; case 100: command = commands.cmd_goTo_Linear_WithStep_100; break; default: msg_num = commands.cmd_goTo_Linear_WithStep_10.GetHashCode(); break; } break; case "szinuszos": switch (step) { case 2: command = commands.cmd_goTo_Sine_WithStep_2; break; case 5: command = commands.cmd_goTo_Sine_WithStep_5; break; case 10: command = commands.cmd_goTo_Sine_WithStep_10; break; case 15: command = commands.cmd_goTo_Sine_WithStep_15; break; case 30: command = commands.cmd_goTo_Sine_WithStep_30; break; case 50: command = commands.cmd_goTo_Sine_WithStep_50; break; case 65: command = commands.cmd_goTo_Sine_WithStep_65; break; case 80: command = commands.cmd_goTo_Sine_WithStep_80; break; case 100: command = commands.cmd_goTo_Sine_WithStep_100; break; default: command = commands.cmd_goTo_Sine_WithStep_30; break; } break; case "exponenciális": switch (step) { case 2: command = commands.cmd_goTo_Exp_WithStep_2; break; case 5: command = commands.cmd_goTo_Exp_WithStep_5; break; case 10: command = commands.cmd_goTo_Exp_WithStep_10; break; case 15: command = commands.cmd_goTo_Exp_WithStep_15; break; case 30: command = commands.cmd_goTo_Exp_WithStep_30; break; case 50: command = commands.cmd_goTo_Exp_WithStep_50; break; case 65: command = commands.cmd_goTo_Exp_WithStep_65; break; case 80: command = commands.cmd_goTo_Exp_WithStep_80; break; case 100: command = commands.cmd_goTo_Exp_WithStep_100; break; default: command = commands.cmd_goTo_Exp_WithStep_30; break; } break; default: command = commands.cmd_setBlack; break; } return(command); }
private bool readAnswer(commands command) { NetduinoHardwareController.GetTristatePort().Active = false; for (int n = RXBUFFERLENGTH; n > 0; n--) { this.m_tempBuffer[n - 1] = this.readByte(); } NetduinoHardwareController.GetTristatePort().Active = true; return this.m_tempBuffer[RXCOMMANDPOS] == (Byte)command; }
/* Send a command request to the WeatherShield1 */ private void sendCommand(commands command, byte parameter) { /* We start sending the first high level bit */ if (!NetduinoHardwareController.GetTristatePort().Active) { NetduinoHardwareController.GetTristatePort().Active = true; } NetduinoHardwareController.GetTristatePort().Write(true); this.pulseClockPin(); /* The first byte is always 0xAA... */ this.sendByte(0xAA); /* ... then is the address... */ this.sendByte(this.m_deviceAddress); /* ... then is the command ... */ this.sendByte((Byte)command); /* ... and the parameter ... */ this.sendByte(parameter); /* And this is the last low level bit required by the protocol */ NetduinoHardwareController.GetTristatePort().Write(false); this.pulseClockPin(); }
/* Read the answer back from the Weather Shield 1 and fill the provided buffer with the result. Depending on the type of command associated to this answer the buffer contents should be properly decoded. The function returns true if the read answer contain the expected command */ private bool readAnswer(commands command) { m_dataPort.Active = false; for (int n = RXBUFFERLENGTH; n > 0; n--) m_tempBuffer[n-1] = readByte(); m_dataPort.Active = true; return (m_tempBuffer[RXCOMMANDPOS] == (Byte)command); }
/* Send a command request to the WeatherShield1 */ private void sendCommand(commands command, Byte parameter) { /* We start sending the first high level bit */ if (!m_dataPort.Active) m_dataPort.Active = true; m_dataPort.Write(true); pulseClockPin(); /* The first byte is always 0xAA... */ sendByte(0xAA); /* ... then is the address... */ sendByte(m_deviceAddress); /* ... then is the command ... */ sendByte((Byte)command); /* ... and the parameter ... */ sendByte(parameter); /* And this is the last low level bit required by the protocol */ m_dataPort.Write(false); pulseClockPin(); }
=> new FormResetCurrentBranch(commands, revision ?? throw new NotSupportedException(Strings.NoRevision), resetType);
public void helloProcessing() { // 1. Try handshake ("@@@") three times; or continue if successful. // 2. Check if reply seems valid(ish). // 3. Chop up the reply into useful device data. // 4. Save the device data for later. // 5. If not reply, let the user know it was a fail. int[] firmwareDatePieces = { 0x00, 0x00 }; int firmwareStatus = 0x00; int[] signatureBytes = { 0x00, 0x00, 0x00 }; int pagesizeInWords = 0x00; int[] freeFlash = { 0x00, 0x00 }; int[] eepromSize = { 0x00, 0x00 }; serialPorts.WriteData("AT+PIOB0"); Thread.Sleep(120); serialPorts.WriteData("AT+PIOB1"); Thread.Sleep(120); for (int i = 0; i < 3; i++) { serialPorts.WriteData("@@@"); Thread.Sleep(50); rxBuffer = serialPorts.ReadExistingAsString(); if (rxBuffer.Length > 0) { break; } } // ATtiny have all lower case, ATMega have upper case. Not sure if it's expected. if (rxBuffer.Contains("tsb") || rxBuffer.Contains("TSB") && rxBuffer.Length == 17) { if (rxBuffer.Length > 16) { firmwareDatePieces[0] = rxBuffer[3]; firmwareDatePieces[1] = rxBuffer[4]; firmwareStatus = rxBuffer[5]; signatureBytes[0] = rxBuffer[6]; signatureBytes[1] = rxBuffer[7]; signatureBytes[2] = rxBuffer[8]; pagesizeInWords = rxBuffer[9]; freeFlash[0] = rxBuffer[10]; freeFlash[1] = rxBuffer[11]; eepromSize[0] = rxBuffer[12]; eepromSize[1] = rxBuffer[13]; } // Date of firmware. int day = firmwareDatePieces[0]; int month = ((firmwareDatePieces[1] & 0xF0) >> 1); int year = (firmwareDatePieces[1] & 0x0F); firmwareDateString = (month + " " + day + " " + "20" + year); // Atmel device signature. deviceSignature = signatureBytes[0].ToString("X2") + " " + signatureBytes[1].ToString("X2") + " " + signatureBytes[2].ToString("X2"); Int32 combinedDeviceSignature = (Int32)(((signatureBytes[0] << 16) | signatureBytes[1] << 8) | signatureBytes[2]); deviceSignatureValue = (DEVICE_SIGNATURE)combinedDeviceSignature; // The size is in words, make it bytes. pageSize = (pagesizeInWords * 2); string pageSizeString = (pagesizeInWords * 2).ToString(); // Get flash size. flashSize = ((freeFlash[1] << 8) | freeFlash[0]) * 2; string flashLeft = flashSize.ToString(); // REPLACE WITH DEVICE INFO numberOfPages = flashSize / pageSize; //numberOfPages = 16; // Get EEPROM size. fullEepromSize = ((eepromSize[1] << 8) | eepromSize[0]) + 1; string eeprom = fullEepromSize.ToString(); mainDisplay.AppendText( deviceSignatureValue.ToString() + "\nFirmware Date: " + firmwareDateString + "\nStatus: " + firmwareStatus.ToString("X2") + "\nSignature: " + deviceSignature + "\nPage Size: " + pageSizeString + "\nFlash Free: " + flashLeft + "\nEEPROM size: " + eeprom + "\n", System.Drawing.Color.White); commandInProgress = commands.none; setTsbConnectionSafely(true); } else { mainDisplay.AppendText("Could not handshake with TSB. Please reset and try again.\n", System.Drawing.Color.Crimson); } }
public void updateActionInProgress(commands commandNumber) { commandInProgress = commandNumber; }
private async void TakeCareOfTCPClient(TcpClient paramClient) { reader = null; try { MyLogger.Log("Preparing to read and write Data"); stream = paramClient.GetStream(); reader = new StreamReader(stream); while (running) { sendToClient("provide UserName", paramClient); Debug.WriteLine("*** Ready to read "); MyLogger.Log("ready to read data"); size = await stream.ReadAsync(buffMessage, 0, buffMessage.Length); //start reading data and get the size username = Encoding.ASCII.GetString(buffMessage, 0, size); //decode the data in the buffer to a string MyLogger.Log($"username provided is {username}"); Array.Clear(buffMessage, 0, buffMessage.Length); sendToClient("Provide Password", paramClient); size = await stream.ReadAsync(buffMessage, 0, buffMessage.Length); //start reading data and get the size password = Encoding.ASCII.GetString(buffMessage, 0, size); //decode the data in the buffer to a string MyLogger.Log($"password provided is {password}"); if (size == 0) { MyLogger.Log("data to read is null"); RemoveClient(paramClient); Debug.WriteLine("Socket disconnected"); MyLogger.Log("Socket disconnected"); break; } checkAuthorization(username, password); // if the user is authorozied, startlistening to commands. "user inside the server" if (isAuthorized == true) { Array.Clear(buffMessage, 0, buffMessage.Length); sendToClient("your options are : '1 for list' ' 2 for delete' '3 for upload' '4 for download'", paramClient); MyLogger.Log($"the path to directory is {pathToDirectory} "); Debug.WriteLine($"the path to directory is {pathToDirectory}"); size = await stream.ReadAsync(buffMessage, 0, buffMessage.Length);//start reading data and get the size string getvalue = Encoding.ASCII.GetString(buffMessage, 0, size); commands comandNum = (commands)int.Parse(getvalue);// cust the comand integer to enum switch (comandNum) { case commands.list: listAllStoredFiles(); break; case commands.delete: sendToClient("provide file name", returnedByAccept); size = await stream.ReadAsync(buffMessage, 0, buffMessage.Length); //start reading data and get the size fileName = Encoding.ASCII.GetString(buffMessage, 0, size); //decode the data in the buffer to a string await delteFileAsync(fileName); break; case commands.download: break; case commands.upload: break; default: break; } } //clear the buffer Array.Clear(buffMessage, 0, buffMessage.Length); } } catch (Exception excp) { MyLogger.Log($"will remove client- error accured {paramClient}"); RemoveClient(paramClient); MyLogger.Log(excp.ToString()); } }
public string SendCommandExposed(commands commandToSend, List <string> parameters) { var commandText = string.Empty; switch (commandToSend) { case commands.Connect: commandText = $"connect {parameters.FirstOrDefault() }"; break; case commands.Disconnect: commandText = $"disconnect {parameters.FirstOrDefault() }"; break; case commands.StartServer: commandText = $"start-server"; break; case commands.KillServer: commandText = $"kill-server"; break; case commands.ListDevices: commandText = $"devices"; break; case commands.Reboot: commandText = $"reboot"; break; case commands.RebootBootloader: commandText = $"reboot bootloader"; break; case commands.RebootRecovery: commandText = $"reboot recovery"; break; case commands.Execute: commandText = $"shell {parameters.FirstOrDefault() }"; break; case commands.ExecuteAsRoot: commandText = $"shell su -c \"{parameters.FirstOrDefault() }\""; break; case commands.Remount: commandText = $"shell su -c \"mount -o rw,remount /system\""; break; case commands.Push: commandText = $"push { string.Join(" ", parameters.Select(x => string.Concat("\"", x, "\""))) }"; break; case commands.Pull: commandText = $"pull {parameters}"; break; case commands.Install: case commands.ForceInstall: commandText = $"install \"{parameters}\""; break; case commands.Uninstall: commandText = $"uninstall \"{parameters}\""; break; case commands.Backup: commandText = $"backup \"{parameters}\""; break; case commands.Restore: commandText = $"backup \"{parameters}\""; break; case commands.Logcat: commandText = $"logcat >> \"{parameters}\""; break; case commands.LogcatOverwrite: commandText = $"logcat > \"{parameters}\""; break; } SendCommand($"\"{adbPath}\" {commandText}"); return(Output); }