private double m_ZMaxFeedrate; // in mm/min

        #endregion Fields

        #region Constructors

        public MachineConfig()
        {
            m_PlatXSize = 102.0;
            m_PlatYSize = 77.0;
            m_PlatZSize = 100; // 100 mm default, we have to load this
            m_XMaxFeedrate = 100;
            m_YMaxFeedrate = 100;
            m_ZMaxFeedrate = 100;
            m_driverconfig = new DeviceDriverConfig();
            m_monitorconfig = new MonitorConfig();
            m_machinetype = eMachineType.UV_DLP;
            CalcPixPerMM();
        }
 /// <summary>
 /// This sets the screen identifier and display portion so this form knows which screen to display into
 /// </summary>
 /// 
 public void Setup(string screenid, MonitorConfig.MRect rect)
 {
     m_screenid = screenid;
     m_rect = rect;
 }
        public bool Load(string filename)
        {
            m_filename = filename;
            m_lstMonitorconfigs.Clear(); // clear any previously loaded monitors
            m_name = Path.GetFileNameWithoutExtension(filename);
            bool retval = false;
            XmlHelper xh = new XmlHelper();
            bool fileExist = xh.Start(m_filename, "MachineConfig");
            XmlNode mc = xh.m_toplevel;

            m_PlatXSize = xh.GetDouble(mc, "PlatformXSize", 102.0);
            m_PlatYSize = xh.GetDouble(mc, "PlatformYSize", 77.0);
            m_PlatZSize = xh.GetDouble(mc, "PlatformZSize", 100.0);
            m_XMaxFeedrate = xh.GetDouble(mc, "MaxXFeedRate", 100.0);
            m_YMaxFeedrate = xh.GetDouble(mc, "MaxYFeedRate", 100.0);
            m_ZMaxFeedrate = xh.GetDouble(mc, "MaxZFeedRate", 100.0);
            XRenderSize = xh.GetInt(mc, "XRenderSize", 1024);
            YRenderSize = xh.GetInt(mc, "YRenderSize", 768);
            MachineControls = xh.GetString(mc, "DisplayedControls", "XYZPG");
            m_machinetype = (eMachineType)xh.GetEnum(mc, "MachineType", typeof(eMachineType), eMachineType.UV_DLP);
            m_multimontype = (eMultiMonType)xh.GetEnum(mc, "MultiMonType", typeof(eMultiMonType), eMultiMonType.eHorizontal);
            
            if (m_driverconfig.Load(xh, mc))
            {
                retval = true;
            }

            //m_monitorconfig.Load(xh, mc);
            List<XmlNode> monitornodes = xh.FindAllChildElement(mc, "MonitorDriverConfig");
            m_lstMonitorconfigs = new List<MonitorConfig>();
            foreach (XmlNode node in monitornodes) 
            {
                MonitorConfig monc = new MonitorConfig();
                monc.Load(xh, node);
                m_lstMonitorconfigs.Add(monc);
            }
            if (m_lstMonitorconfigs.Count > 0)
            {
                // we need at least 1 monitor
                //m_monitorconfig = m_lstMonitorconfigs[0];
            }
            else 
            {
                DebugLogger.Instance().LogError("No monitor configurations found!");
            }

            CalcPixPerMM();

            if (!fileExist)
            {
                xh.Save(FILE_VERSION);
            }
            CorrectMonitorConfig();
            return retval;
        }
 /// <summary>
 /// This sets the screen identifier and display portion so this form knows which screen to display into
 /// </summary>
 /// 
 public void Setup(string screenid, MonitorConfig monitorconfig)
 {
     m_screenid = screenid;
     m_monitorconfig = monitorconfig;
     m_rect = monitorconfig.m_monitorrect;
 }
        bool Load(XmlHelper xh)
        {
            bool retval = false;

            XmlNode mc = xh.m_toplevel;

            m_PlatXSize = xh.GetDouble(mc, "PlatformXSize", 102.0);
            m_PlatYSize = xh.GetDouble(mc, "PlatformYSize", 77.0);
            m_PlatZSize = xh.GetDouble(mc, "PlatformZSize", 100.0);
            m_XMaxFeedrate = xh.GetDouble(mc, "MaxXFeedRate", 100.0);
            m_YMaxFeedrate = xh.GetDouble(mc, "MaxYFeedRate", 100.0);
            m_ZMaxFeedrate = xh.GetDouble(mc, "MaxZFeedRate", 100.0);
            XRenderSize = xh.GetInt(mc, "XRenderSize", 1024);
            YRenderSize = xh.GetInt(mc, "YRenderSize", 768);
            MachineControls = xh.GetString(mc, "DisplayedControls", "XYZPG");
            m_machinetype = (eMachineType)xh.GetEnum(mc, "MachineType", typeof(eMachineType), eMachineType.UV_DLP);
            m_multimontype = (eMultiMonType)xh.GetEnum(mc, "MultiMonType", typeof(eMultiMonType), eMultiMonType.eHorizontal);

            if (m_driverconfig.Load(xh, mc))
            {
                retval = true;
            }

            //m_monitorconfig.Load(xh, mc);
            List<XmlNode> monitornodes = xh.FindAllChildElement(mc, "MonitorDriverConfig");
            m_lstMonitorconfigs = new List<MonitorConfig>();
            foreach (XmlNode node in monitornodes)
            {
                MonitorConfig monc = new MonitorConfig();
                monc.Load(xh, node);
                m_lstMonitorconfigs.Add(monc);
            }
            if (m_lstMonitorconfigs.Count > 0)
            {
                // we need at least 1 monitor
                //m_monitorconfig = m_lstMonitorconfigs[0];
            }
            else
            {
                DebugLogger.Instance().LogError("No monitor configurations found!");
            }

            CalcPixPerMM();

            CorrectMonitorConfig();
            userParams = new UserParameterList();
            xh.LoadUserParamList(userParams);
            return retval;
        }
 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);
     }
 }
 // create a null loop-back machine for test
 public void CreateNullMachine()
 {
     m_PlatXSize = 102.0;
     m_PlatYSize = 77.0;
     m_PlatZSize = 100; // 100 mm default, we have to load this
     m_XMaxFeedrate = 100;
     m_YMaxFeedrate = 100;
     m_ZMaxFeedrate = 100;
     m_driverconfig = new DeviceDriverConfig();
     m_driverconfig.m_drivertype = Drivers.eDriverType.eNULL_DRIVER;
     m_monitorconfig = new MonitorConfig();
     m_machinetype = eMachineType.UV_DLP;
     m_driverconfig.m_connection.comname = "LoopBack";
     CalcPixPerMM();
 }