コード例 #1
0
 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;
     }
 }
コード例 #2
0
ファイル: Laser.cs プロジェクト: asimay/LMS511Laser
 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;
     }
 }