private void CloseAll() { IDictionaryEnumerator enu = SFTable.GetEnumerator(); while (enu.MoveNext()) { SerialForwarder sf = (SerialForwarder)enu.Value; sf.CloseAll(); } }
private SerialForwarder findSFByPort(int port) { IDictionaryEnumerator enu = SFTable.GetEnumerator(); while (enu.MoveNext()) { SerialForwarder sf = (SerialForwarder)enu.Value; if (sf.port == port) return sf; } return null; }
private void LaunchSF(ArrayList args) { SerialForwarder sf = new SerialForwarder(args, prompt, sfId); if (sf.running) { SFTable.Add(sf.id, sf); sf.moteConnLost += sf_moteConnLost; sfId++; } }
private void List() { if (SFTable.Count == 0) { prompt.WriteLine("No running sf servers."); } IDictionaryEnumerator enu = SFTable.GetEnumerator(); while (enu.MoveNext()) { SerialForwarder sf = (SerialForwarder)enu.Value; sf.PrintIdMessage(); } }
public void PrintHelp(ArrayList args) { if (args.Count < 2) { PrintMainHelp(); return; } string cname = args[1].ToString(); switch (cname) { case "start":SerialForwarder.PrintStartHelp(prompt); break; case "stop":SerialForwarder.PrintStopHelp(prompt); break; case "help": PrintHelp(args); break; case "list": SerialForwarder.PrintListHelp(prompt); break; case "info": SerialForwarder.PrintInfoHelp(prompt); break; case "close": PrintHelpClose(prompt); break; case "exit": PrintHelpExit(prompt); break; case "ports": PrintHelpPorts(prompt); break; case "set": PrintSetHelp(prompt); break; case "listen": Listener.PrintHelp(prompt); break; case "clear": PrintHelpClear(prompt); break; case "send": Sender.PrintHelp(prompt); break; default: PrintMainHelp(); break; } }
private void Info(string id) { uint _id; try { _id = Convert.ToUInt32(id); } catch (Exception e) { Debug.WriteLine(e.Message); prompt.WriteLine("info: wrong arguments"); return; } SerialForwarder sf = findSF(_id); if (sf == null) { prompt.WriteLine("SF not found"); return; } sf.Info(); }
private void StopSF(string id) { uint _id; try { _id = Convert.ToUInt32(id); } catch (Exception e) { Debug.WriteLine(e.Message); prompt.WriteLine("stop: wrong arguments"); return; } SerialForwarder sf = findSF(_id); if (sf == null) { prompt.WriteLine("SF not found"); return; } sf.CloseAll(); SFTable.Remove(sf.id); }
void sf_moteConnLost(object sender, EventArgs e) { SerialForwarder sf = (SerialForwarder)sender; StopSF(sf.port.ToString()); }