public override void RunInterface(string pluginName) { pName = pluginName; Log = new General.OSAELog(pName); Log.Debug("Running interface"); OSAEObjectType objt = OSAEObjectTypeManager.ObjectTypeLoad("ONKYO RECEIVER"); OSAEObjectTypeManager.ObjectTypeUpdate(objt.Name, objt.Name, objt.Description, pName, "THING", objt.Owner, objt.SysType, objt.Container, objt.HideRedundant); _UDPListen = new UDPListen(); _UDPSend = new UDPSend(); _UDPListen.OnkyoDevice += new DelegateOnkyoReply(OnkyoMessageHandler); _UDPListen.Listen(); _UDPSend.Send(); OSAEObjectCollection objects = OSAEObjectManager.GetObjectsByType("ONKYO RECEIVER"); foreach (OSAEObject obj in objects) { Receiver r = new Receiver(obj.Name); foreach (OSAEObjectProperty prop in obj.Properties) { switch (prop.Name) { case "Communication Type": r.Type = prop.Value; break; case "IP": r.IP = prop.Value; break; case "Network Port": try { r.NetworkPort = Int32.Parse(prop.Value); } catch { r.NetworkPort = 0; } break; case "COM Port": try { r.ComPort = Int32.Parse(prop.Value); } catch { r.ComPort = 0; } break; } } receivers.Add(r); Log.Debug("Added receiver to list: " + r.Name); try { if (r.Type == "Network" && r.IP != "" && r.NetworkPort != 0) { Log.Debug("Creating TCP Client: ip-" + r.IP + " port-" + r.NetworkPort); r.tcpClient = new TcpClient(r.IP, r.NetworkPort); //get a network stream from server r.clientSockStream = r.tcpClient.GetStream(); // create new writer and reader stream to send and receive r.clientStreamWriter = new StreamWriter(r.clientSockStream); r.clientStreamReader = new StreamReader(r.clientSockStream); //Start listening r.Connect(); } else if (r.Type == "Serial" && r.ComPort != 0) { //not implemented } else { Log.Info(r.Name + " - Properties not set"); } } catch (Exception ex) { Log.Error("Error creating connection to receiver", ex); } } Log.Info("Run Interface Complete"); }
public void RunInterface(string pluginName) { osae.AddToLog("Running interface", false); pName = pluginName; osae.ObjectTypeUpdate("ONKYO RECEIVER", "ONKYO RECEIVER", "Onkyo Receiver", pluginName, "ONKYO RECEIVER", 0, 0, 0, 1); _UDPListen = new UDPListen(); _UDPSend = new UDPSend(); _UDPListen.OnkyoDevice += new DelegateOnkyoReply(OnkyoMessageHandler); _UDPListen.Listen(); _UDPSend.Send(); List <OSAEObject> objects = osae.GetObjectsByType("ONKYO RECEIVER"); foreach (OSAEObject obj in objects) { Receiver r = new Receiver(obj.Name); foreach (ObjectProperty prop in obj.Properties) { switch (prop.Name) { case "Communication Type": r.Type = prop.Value; break; case "IP": r.IP = prop.Value; break; case "Network Port": try { r.NetworkPort = Int32.Parse(prop.Value); } catch { r.NetworkPort = 0; } break; case "COM Port": try { r.ComPort = Int32.Parse(prop.Value); } catch { r.ComPort = 0; } break; } } receivers.Add(r); osae.AddToLog("Added receiver to list: " + r.Name, false); try { if (r.Type == "Network" && r.IP != "" && r.NetworkPort != 0) { osae.AddToLog("Creating TCP Client: ip-" + r.IP + " port-" + r.NetworkPort, false); r.tcpClient = new TcpClient(r.IP, r.NetworkPort); //get a network stream from server r.clientSockStream = r.tcpClient.GetStream(); // create new writer and reader stream to send and receive r.clientStreamWriter = new StreamWriter(r.clientSockStream); r.clientStreamReader = new StreamReader(r.clientSockStream); //Start listening r.Connect(); } else if (r.Type == "Serial" && r.ComPort != 0) { //not implemented } else { osae.AddToLog(r.Name + " - Properties not set", true); } } catch (Exception ex) { osae.AddToLog("Error creating connection to receiver: " + ex.Message, true); } } osae.AddToLog("Run Interface Complete", false); }