private string GetComPortDescription(string portSpec) { string ret = ""; StorableHashtable settings = new StorableHashtable(portSpec); if (settings.ContainsKey("type")) { switch (settings["type"].ToString()) { case "comport": if (settings.ContainsKey("port_name")) { ret = settings["port_name"].ToString(); } break; case "file": if (settings.ContainsKey("file_name")) { ret = settings["file_name"].ToString(); } break; case "webserver": if (settings.ContainsKey("path_id")) { ret = settings["path_id"].ToString(); } break; } } return(ret); }
public IPort GetPort(IExtension sender, string portSpec) { StorableHashtable settings = new StorableHashtable(portSpec); if (! settings.ContainsKey("type")) throw new Exception("COM port type not specified"); switch ((string)settings["type"]) { // Regular COM port. case "comport": if (! settings.ContainsKey("port_name")) throw new Exception("No COM port name specified"); if (! settings.ContainsKey("baud_rate")) throw new Exception("No baud rate specified"); return new OpenNETCFSerialPort((string)settings["port_name"], int.Parse((string)settings["baud_rate"])); // File case "file": if (! settings.ContainsKey("file_name")) throw new Exception("No file name specified"); if (! settings.ContainsKey("file_mode")) throw new Exception("No file mode specified"); return new FileBasedPort((string)settings["file_name"], (string)settings["file_mode"]); // web server case "webserver": if (!settings.ContainsKey("path_id")) throw new Exception("Path id specified"); if (!settings.ContainsKey("is_inputport")) throw new Exception("Path id specified"); Int32 pathID = Int32.Parse(settings["path_id"].ToString()); bool bIsInput = bool.Parse(settings["is_inputport"].ToString()); return new WebServiceBasedPort(pathID, "", "WM", bIsInput, false); // Oops! default: throw new Exception("Invalid COM port type: " + (string)settings["type"]); } }
private string GetComPortDescription(string portSpec) { string ret = ""; StorableHashtable settings = new StorableHashtable(portSpec); if (settings.ContainsKey("type")) { switch (settings["type"].ToString()) { case "comport": if (settings.ContainsKey("port_name")) ret = settings["port_name"].ToString(); break; case "file": if (settings.ContainsKey("file_name")) ret = settings["file_name"].ToString(); break; case "webserver": if (settings.ContainsKey("path_id")) ret = settings["path_id"].ToString(); break; } } return ret; }