private string getLaserConfig() { try { using (FromIniOfFile laserConfigFromIniFile = new FromIniOfFile()) { uint pwd; laserConfigFromIniFile.ReadData(); LaserConfig laserConfig = new LaserConfig(); if (laserConfigFromIniFile.FactoryDefault) { laserConfig.SetDefaults(); } else { laserConfig.IPAddress = laserConfigFromIniFile.IpAddress; if ((laserConfigFromIniFile.TriggerOutputChannelNumber > 0) && (laserConfigFromIniFile.TriggerOutputChannelNumber < 7)) { laserConfig.TriggerOutputChannelNumber = laserConfigFromIniFile.TriggerOutputChannelNumber; } else { throw new Exception("Bad Trigger Output Channel Number of laser from 'lms511.ini' file, from 1 to 6!"); } try { pwd = UInt32.Parse(laserConfigFromIniFile.Password_maintenance, NumberStyles.HexNumber); } catch (Exception) { throw new Exception("Bad Password_maintenance of laser from 'lms511.ini' file, not hexa format"); } laserConfig.PWD_maintenance = pwd; try { pwd = UInt32.Parse(laserConfigFromIniFile.Password_authorized_client, NumberStyles.HexNumber); } catch (Exception) { throw new Exception("Bad Password_authorized_client of laser from 'lms511.ini' file, not hexa format"); } laserConfig.PWD_authorized_client = pwd; try { pwd = UInt32.Parse(laserConfigFromIniFile.Password_service, NumberStyles.HexNumber); } catch (Exception) { throw new Exception("Bad Password_service of laser from 'lms511.ini' file, not hexa format"); } laserConfig.PWD_service = pwd; } return(laserConfig.SaveToXml()); } } catch (Exception) { throw; } }
public static ILaser CreateLaserController(LaserConfig laserPara, TcpClientStream tcpClient) { ILaser laser = null; string typeStr = laserPara.LaserType.ToString(); switch (typeStr) { case "Raycus": if (laserPara.ControlType == LaserControlTypes.Extern) { laser = new LaserController(tcpClient, laserPara.MaxVoltage); } else { var serialPortStream = new SerialPortStream(laserPara.PortName, 9600); laser = new RaycusLaserController(serialPortStream); } break; case "Other": laser = new LaserController(tcpClient, laserPara.MaxVoltage); break; default: throw new Exception("LaserFactory: not support!"); } return(laser); }
private void removeConfig(LaserConfig config) { foreach (GameObject laser in config.lasers) { laser.gameObject.SetActive(false); } }
private void applyConfig(LaserConfig config) { foreach (GameObject laser in config.lasers) { laser.gameObject.SetActive(true); } }
public TestBase() { s_log = new StringBuilder(); _traceWrapper = new TraceWrapper(); _laserCondig = new LaserConfig(); Log.AppendLine("TestBase.TestBase()"); }
private LaserConfig getRandomConfig(TunnelSelectionPreferences prefs) { int loopBreaker = 0; while (true) { LaserConfig candidate = laserConfigs [Random.Range(0, laserConfigs.Length)]; if (++loopBreaker > 20 || candidate.difficultyLevel <= prefs.preferredDifficulty) { return(candidate); } } }
public override void setup(TunnelSelectionPreferences prefs, TunnelPiece parent) { base.setup(prefs, parent); configInUse = getRandomConfig(prefs); applyConfig(configInUse); }