private void SendProjCmd(MonitorConfig mc, ProjectorCommand pc) { try { //send the command if (mc.m_displayconnectionenabled == false) { DebugLogger.Instance().LogWarning("Display connection not enabled"); return; } //Find the driver DeviceDriver driver = UVDLPApp.Instance().m_deviceinterface.FindProjDriverByComName(mc.m_displayconnection.comname); if (driver == null) { DebugLogger.Instance().LogError("Driver not found"); return; } if (driver.Connected == true) { //send the command. driver.Write(pc.GetBytes(), pc.GetBytes().Length); } else { DebugLogger.Instance().LogError("Driver not connected"); return; } } catch (Exception ex) { DebugLogger.Instance().LogError(ex); } }
// load from xml file -SHS public bool Load(String filename) { m_commands.Clear(); XmlHelper xh = new XmlHelper(); xh.Start(filename, "ProjectorCmdList"); List<XmlNode> ndlist = xh.GetAllSections(null, "Command"); foreach (XmlNode nd in ndlist) { ProjectorCommand pc = new ProjectorCommand(); pc.name = xh.GetString(nd, "Name", "none"); pc.hex = xh.GetBool(nd, "IsHex", false); pc.command = xh.GetString(nd, "Cmd", ""); m_commands.Add(pc); } return true; }
// load from xml file -SHS public bool Load(String filename) { m_commands.Clear(); XmlHelper xh = new XmlHelper(); xh.Start(filename, "ProjectorCmdList"); List <XmlNode> ndlist = xh.GetAllSections(null, "Command"); foreach (XmlNode nd in ndlist) { ProjectorCommand pc = new ProjectorCommand(); pc.name = xh.GetString(nd, "Name", "none"); pc.hex = xh.GetBool(nd, "IsHex", false); pc.command = xh.GetString(nd, "Cmd", ""); m_commands.Add(pc); } return(true); }
public bool SendProjCommand(string displayname, string commandname) { try { // get the projector command for 'on' // ACER_ON ProjectorCommand pcmd = UVDLPApp.Instance().m_proj_cmd_lst.FindByName(commandname); if (pcmd != null) { DeviceDriver dd = DisplayManager.Instance().FindDisplaySerialPortDriverByName(displayname); if (dd != null) { if (dd.Connected) { byte[] data = pcmd.GetBytes(); dd.Write(data, data.Length); return(true); } else { DebugLogger.Instance().LogError("Projector Driver not connected"); } } else { DebugLogger.Instance().LogError("Projector Driver not found"); } } else { DebugLogger.Instance().LogError("Projector command not found"); } } catch (Exception ex) { DebugLogger.Instance().LogError(ex); } return(false); }
/// <summary> /// This function sends commands to the projector(s) /// The format is <DispCmd> MonitorID , cmdname /// Monitor ID can be any monitor on the system, or ALL /// </summary> /// <param name="line"></param> private void PerformDisplayCommand(string line) { try { line = line.Replace(';', ' '); // remove comments line = line.Replace(')', ' '); // remove comments int bidx = line.IndexOf('>'); if (bidx == -1) { DebugLogger.Instance().LogError("Improperly formated display command"); return; } string ss1 = line.Substring(bidx + 1); string[] lines = ss1.Split(','); if (lines.Length != 2) { DebugLogger.Instance().LogError("Improperly formated display command"); return; } string monname = lines[0].Trim(); string cmdname = lines[1].Trim(); //get the command name ProjectorCommand pc = null; pc = UVDLPApp.Instance().m_proj_cmd_lst.FindByName(cmdname); if (pc == null) { DebugLogger.Instance().LogError("Could not find Display Command " + cmdname); return; } // get the monitor ID if (monname.Equals("All")) { //iterate through all configured monitors in machine monitor list foreach (MonitorConfig mc in UVDLPApp.Instance().m_printerinfo.m_lstMonitorconfigs) { SendProjCmd(mc, pc); } } else { MonitorConfig mc = UVDLPApp.Instance().m_printerinfo.FindMonitorByName(monname); if (mc != null) { SendProjCmd(mc, pc); } else { DebugLogger.Instance().LogError("Monitor ID " + monname + " not found"); return; } } // get the commands name //find the command in the projector command list // make sure the com port for the projector is open //send the command to the projector over serial } catch (Exception ex) { DebugLogger.Instance().LogError(ex); } }