public string SetFan(string command) { try { var sIndex = command.IndexOf('S') + 1; FanSpeed = int.Parse(command.Substring(sIndex)); FanSpeedChanged?.Invoke(this, null); } catch (Exception e) { Console.WriteLine(e); } return("ok\n"); }
public string SetFan(string command) { try { var sIndex = command.IndexOf('S') + 1; string fanSpeed = command.Substring(sIndex); int spaceIndex = fanSpeed.IndexOf(' '); if (spaceIndex != -1) { fanSpeed = fanSpeed.Substring(0, spaceIndex); } FanSpeed = int.Parse(fanSpeed); FanSpeedChanged?.Invoke(this, null); } catch (Exception e) { Console.WriteLine(e); } return("ok\n"); }