private static void HandleSpecialFlag_OpenChargePort(string _flagconfig, string _oldState, string _newState) { string pattern = "([PRND]+)->([PRND]+)"; Match m = Regex.Match(_flagconfig, pattern); if (m.Success && m.Groups.Count == 3 && m.Groups[1].Captures.Count == 1 && m.Groups[2].Captures.Count == 1 && m.Groups[1].Captures[0].ToString().Contains(_oldState) && m.Groups[2].Captures[0].ToString().Contains(_newState)) { Logfile.Log("OpenChargePort ..."); string result = webhelper.PostCommand("command/charge_port_door_open", null).Result; Logfile.Log("openChargePort(): " + result); } }
private static void HandleSpecialFlag_SetChargeLimit(Address _addr, string _flagconfig) { string pattern = "([0-9]+)"; Match m = Regex.Match(_flagconfig, pattern); if (m.Success && m.Groups.Count == 2 && m.Groups[1].Captures.Count == 1) { if (m.Groups[1].Captures[0] != null && int.TryParse(m.Groups[1].Captures[0].ToString(), out int chargelimit)) { if (!lastSetChargeLimitAddressName.Equals(_addr.name)) { Task.Factory.StartNew(() => { Logfile.Log($"SetChargeLimit to {chargelimit} ..."); string result = webhelper.PostCommand("command/set_charge_limit", "{\"percent\":" + chargelimit + "}", true).Result; Logfile.Log("set_charge_limit(): " + result); lastSetChargeLimitAddressName = _addr.name; }); } } } }