778 lines
26 KiB
C#
778 lines
26 KiB
C#
using Aurora.Api;
|
|
using AuroraLaser.Amplitude.Satsuma;
|
|
using AuroraLaser.Coherent.Arm;
|
|
using AuroraLaser.Coherent.Compact;
|
|
using AuroraLaser.Coherent.HyperRapid;
|
|
using AuroraLaser.Coherent.RapidLX;
|
|
using AuroraLaser.Ekspla;
|
|
using AuroraLaser.Ekspla.NL202;
|
|
using AuroraLaser.IPG.YLPN;
|
|
using AuroraLaser.IPG.YLPP;
|
|
using AuroraLaser.IPG.YLS;
|
|
using AuroraLaser.Trumpf.TruDisk;
|
|
using AuroraLaser.Trumpf.TruPulseNano;
|
|
using Hermes;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Media.Animation;
|
|
|
|
namespace AuroraLaser
|
|
{
|
|
public enum eLaserType
|
|
{
|
|
Amplitude_Satsuma_Laser,
|
|
|
|
Coherent_Arm_Laser,
|
|
Coherent_Compact_Laser,
|
|
Coherent_HyperRapid_Laser,
|
|
Coherent_RapidLX_Laser,
|
|
|
|
Ekspla_NL202_Laser,
|
|
|
|
IPG_YLPN_Laser,
|
|
IPG_YLPP_Laser,
|
|
IPG_YLS_Laser,
|
|
|
|
Trumpf_TruDisk_Laser,
|
|
Trumpf_TruPulseNano_Laser,
|
|
|
|
Coherent_Arm_Laser_IO,
|
|
IPG_Laser_IO,
|
|
Trumpf_Laser_IO,
|
|
}
|
|
|
|
public class LaserDevice : Device, ILaserDevice
|
|
{
|
|
protected Logger Log = new Logger("Laser");
|
|
|
|
private ILaserDevice _LaserDevice;
|
|
private ILaserDevice _LaserDeviceWithIO;
|
|
|
|
private IDeviceConfig _LaserDeviceDefaultConfig;
|
|
public LaserConfig Config { get; set; }
|
|
|
|
public LaserDevice(string deviceId, ILaserDevice laserDeviceWithIO)
|
|
{
|
|
CommType = CommunicationType.Etc;
|
|
DeviceId = deviceId;
|
|
|
|
_LaserDeviceWithIO = laserDeviceWithIO;
|
|
}
|
|
|
|
protected override int DoActivate(IDeviceConfig config)
|
|
{
|
|
Config = config as LaserConfig;
|
|
return ActivateDevice();
|
|
}
|
|
|
|
protected override int DoDeactivate()
|
|
{
|
|
return DeactivateDevice();
|
|
}
|
|
|
|
public IDeviceConfig GetConfig()
|
|
{
|
|
return Config;
|
|
}
|
|
|
|
public int ActivateDevice()
|
|
{
|
|
if (IsActivated) {
|
|
return E1.OK;
|
|
}
|
|
if (IsSimul) {
|
|
return E1.OK;
|
|
}
|
|
|
|
switch (Config.LaserType) {
|
|
case eLaserType.Amplitude_Satsuma_Laser:
|
|
_LaserDevice = new LaserDeviceSatsumaDisplay(DeviceId);
|
|
_LaserDeviceDefaultConfig = LaserSatsumaConfig.GetDefaultConfig();
|
|
(_LaserDevice as LaserDeviceSatsumaDisplay).Config = (_LaserDeviceDefaultConfig as LaserSatsumaConfig);
|
|
// Modbus localhost 로 붙음. SerialConfig or SocketConfig 불필요
|
|
break;
|
|
|
|
case eLaserType.Coherent_Arm_Laser:
|
|
_LaserDevice = new LaserDeviceArm(DeviceId);
|
|
_LaserDeviceDefaultConfig = LaserArmConfig.GetDefaultConfig();
|
|
//_LaserDeviceDefaultConfig.ConnConfig = Config.ConnConfig;
|
|
_LaserDeviceDefaultConfig.ConnConfig = Config.SocketConfig;
|
|
(_LaserDevice as LaserDeviceArm).Config = (_LaserDeviceDefaultConfig as LaserArmConfig);
|
|
break;
|
|
|
|
case eLaserType.Coherent_Compact_Laser:
|
|
_LaserDevice = new LaserDeviceCompact(DeviceId);
|
|
_LaserDeviceDefaultConfig = LaserCompactMiniConfig.GetDefaultConfig();
|
|
//_LaserDeviceDefaultConfig.ConnConfig = Config.ConnConfig;
|
|
_LaserDeviceDefaultConfig.ConnConfig = Config.SerialConfig;
|
|
(_LaserDevice as LaserDeviceCompact).Config = (_LaserDeviceDefaultConfig as LaserCompactMiniConfig);
|
|
break;
|
|
|
|
case eLaserType.Coherent_HyperRapid_Laser:
|
|
_LaserDevice = new LaserDeviceHyperRapid(DeviceId, 1);
|
|
_LaserDeviceDefaultConfig = LaserHyperRapidConfig.GetDefaultConfig();
|
|
//_LaserDeviceDefaultConfig.ConnConfig = Config.ConnConfig;
|
|
_LaserDeviceDefaultConfig.ConnConfig = Config.SerialConfig;
|
|
(_LaserDevice as LaserDeviceHyperRapid).Config = (_LaserDeviceDefaultConfig as LaserHyperRapidConfig);
|
|
break;
|
|
|
|
case eLaserType.Coherent_RapidLX_Laser:
|
|
_LaserDevice = new LaserDeviceRapidLX(DeviceId);
|
|
_LaserDeviceDefaultConfig = LaserRapidLXConfig.GetDefaultConfig();
|
|
//_LaserDeviceDefaultConfig.ConnConfig = Config.ConnConfig;
|
|
_LaserDeviceDefaultConfig.ConnConfig = Config.SocketConfig;
|
|
(_LaserDevice as LaserDeviceRapidLX).Config = (_LaserDeviceDefaultConfig as LaserRapidLXConfig);
|
|
break;
|
|
|
|
case eLaserType.Ekspla_NL202_Laser:
|
|
_LaserDevice = new LaserDeviceNL202(DeviceId);
|
|
_LaserDeviceDefaultConfig = LaserEksplaConfig.GetDefaultConfig(eLaserEksplaDeviceType.NL202);
|
|
//_LaserDeviceDefaultConfig.ConnConfig = Config.ConnConfig;
|
|
_LaserDeviceDefaultConfig.ConnConfig = Config.SerialConfig;
|
|
(_LaserDevice as LaserDeviceNL202).Config = (_LaserDeviceDefaultConfig as LaserEksplaConfig);
|
|
break;
|
|
|
|
case eLaserType.IPG_YLPN_Laser:
|
|
_LaserDevice = new LaserDeviceYLPN(DeviceId);
|
|
_LaserDeviceDefaultConfig = LaserYLPNConfig.GetDefaultConfig();
|
|
//_LaserDeviceDefaultConfig.ConnConfig = Config.ConnConfig;
|
|
_LaserDeviceDefaultConfig.ConnConfig = Config.SerialConfig;
|
|
(_LaserDevice as LaserDeviceYLPN).Config = (_LaserDeviceDefaultConfig as LaserYLPNConfig);
|
|
break;
|
|
|
|
case eLaserType.IPG_YLPP_Laser:
|
|
_LaserDevice = new LaserDeviceYLPP(DeviceId);
|
|
_LaserDeviceDefaultConfig = LaserYLPPConfig.GetDefaultConfig();
|
|
//_LaserDeviceDefaultConfig.ConnConfig = Config.ConnConfig;
|
|
_LaserDeviceDefaultConfig.ConnConfig = Config.SocketConfig;
|
|
(_LaserDevice as LaserDeviceYLPP).Config = (_LaserDeviceDefaultConfig as LaserYLPPConfig);
|
|
break;
|
|
|
|
case eLaserType.IPG_YLS_Laser:
|
|
_LaserDevice = new LaserDeviceYLS(DeviceId);
|
|
_LaserDeviceDefaultConfig = LaserYLSConfig.GetDefaultConfig();
|
|
//_LaserDeviceDefaultConfig.ConnConfig = Config.ConnConfig;
|
|
_LaserDeviceDefaultConfig.ConnConfig = Config.SocketConfig;
|
|
(_LaserDevice as LaserDeviceYLS).Config = (_LaserDeviceDefaultConfig as LaserYLSConfig);
|
|
break;
|
|
|
|
case eLaserType.Trumpf_TruDisk_Laser:
|
|
_LaserDevice = new LaserDeviceTruDisk(DeviceId);
|
|
_LaserDeviceDefaultConfig = LaserTruDiskConfig.GetDefaultConfig();
|
|
//_LaserDeviceDefaultConfig.ConnConfig = Config.ConnConfig;
|
|
_LaserDeviceDefaultConfig.ConnConfig = Config.SocketConfig;
|
|
(_LaserDevice as LaserDeviceTruDisk).Config = (_LaserDeviceDefaultConfig as LaserTruDiskConfig);
|
|
break;
|
|
|
|
case eLaserType.Trumpf_TruPulseNano_Laser:
|
|
_LaserDevice = new LaserDeviceTruPulseNano(DeviceId);
|
|
_LaserDeviceDefaultConfig = LaserTruPulseNanoConfig.GetDefaultConfig();
|
|
//_LaserDeviceDefaultConfig.ConnConfig = Config.ConnConfig;
|
|
_LaserDeviceDefaultConfig.ConnConfig = Config.SocketConfig;
|
|
(_LaserDevice as LaserDeviceTruPulseNano).Config = (_LaserDeviceDefaultConfig as LaserTruPulseNanoConfig);
|
|
break;
|
|
|
|
// Laser IO Control
|
|
case eLaserType.Coherent_Arm_Laser_IO:
|
|
case eLaserType.IPG_Laser_IO:
|
|
case eLaserType.Trumpf_Laser_IO:
|
|
_LaserDevice = _LaserDeviceWithIO;
|
|
break;
|
|
|
|
default:
|
|
Log.E(string.Format("Check Laser Type Setting"));
|
|
_LaserDevice = null;
|
|
break;
|
|
}
|
|
|
|
if (_LaserDevice == null) {
|
|
Log.E(string.Format("LaserDevice is Null"));
|
|
return E1.ARGUMENT;
|
|
}
|
|
|
|
int result = _LaserDevice.ActivateDevice();
|
|
if (result == E1.OK) {
|
|
SetIsActivated_InAllLaserDevice(true);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
private void SetIsActivated_InAllLaserDevice(bool isActivated_InAllLaserDevice)
|
|
{
|
|
switch (Config.LaserType) {
|
|
case eLaserType.Amplitude_Satsuma_Laser:
|
|
(_LaserDevice as LaserDeviceSatsumaDisplay).IsActivated_InAllLaserDevice = isActivated_InAllLaserDevice;
|
|
break;
|
|
|
|
case eLaserType.Coherent_Arm_Laser:
|
|
(_LaserDevice as LaserDeviceArm).IsActivated_InAllLaserDevice = isActivated_InAllLaserDevice;
|
|
break;
|
|
|
|
case eLaserType.Coherent_Compact_Laser:
|
|
(_LaserDevice as LaserDeviceCompact).IsActivated_InAllLaserDevice = isActivated_InAllLaserDevice;
|
|
break;
|
|
|
|
case eLaserType.Coherent_HyperRapid_Laser:
|
|
(_LaserDevice as LaserDeviceHyperRapid).IsActivated_InAllLaserDevice = isActivated_InAllLaserDevice;
|
|
break;
|
|
|
|
case eLaserType.Coherent_RapidLX_Laser:
|
|
(_LaserDevice as LaserDeviceRapidLX).IsActivated_InAllLaserDevice = isActivated_InAllLaserDevice;
|
|
break;
|
|
|
|
case eLaserType.Ekspla_NL202_Laser:
|
|
(_LaserDevice as LaserDeviceNL202).IsActivated_InAllLaserDevice = isActivated_InAllLaserDevice;
|
|
break;
|
|
|
|
case eLaserType.IPG_YLPN_Laser:
|
|
(_LaserDevice as LaserDeviceYLPN).IsActivated_InAllLaserDevice = isActivated_InAllLaserDevice;
|
|
break;
|
|
|
|
case eLaserType.IPG_YLPP_Laser:
|
|
(_LaserDevice as LaserDeviceYLPP).IsActivated_InAllLaserDevice = isActivated_InAllLaserDevice;
|
|
break;
|
|
|
|
case eLaserType.IPG_YLS_Laser:
|
|
(_LaserDevice as LaserDeviceYLS).IsActivated_InAllLaserDevice = isActivated_InAllLaserDevice;
|
|
break;
|
|
|
|
case eLaserType.Trumpf_TruDisk_Laser:
|
|
(_LaserDevice as LaserDeviceTruDisk).IsActivated_InAllLaserDevice = isActivated_InAllLaserDevice;
|
|
break;
|
|
|
|
case eLaserType.Trumpf_TruPulseNano_Laser:
|
|
(_LaserDevice as LaserDeviceTruPulseNano).IsActivated_InAllLaserDevice = isActivated_InAllLaserDevice;
|
|
break;
|
|
|
|
// Laser IO Control
|
|
case eLaserType.Coherent_Arm_Laser_IO:
|
|
case eLaserType.IPG_Laser_IO:
|
|
case eLaserType.Trumpf_Laser_IO:
|
|
// IO LaserDevice 는 IsActivated check 를 IO Device 로 해야 하므로 불필요
|
|
break;
|
|
}
|
|
}
|
|
|
|
public int DeactivateDevice()
|
|
{
|
|
if (!IsActivated) {
|
|
return E1.OK;
|
|
}
|
|
if (IsSimul) {
|
|
return E1.OK;
|
|
}
|
|
|
|
if (_LaserDevice == null) {
|
|
Log.E(string.Format("LaserDevice is Null"));
|
|
return E1.ARGUMENT;
|
|
}
|
|
|
|
int result = _LaserDevice.DeactivateDevice();
|
|
if (result == E1.OK) {
|
|
SetIsActivated_InAllLaserDevice(false);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public int LaserOn()
|
|
{
|
|
if (IsSimul) {
|
|
if (_LaserDevice != null) {
|
|
_LaserDevice.LaserOff(); // 시뮬 모드에서는 절대 레이저를 사용하지 않도록하기 위함.
|
|
}
|
|
return E1.OK;
|
|
}
|
|
if (IsActivated == false || _LaserDevice == null) {
|
|
return E1.GENERIC;
|
|
}
|
|
|
|
return _LaserDevice.LaserOn();
|
|
}
|
|
|
|
public int LaserOff()
|
|
{
|
|
if (IsSimul) {
|
|
return E1.OK;
|
|
}
|
|
if (IsActivated == false || _LaserDevice == null) {
|
|
return E1.GENERIC;
|
|
}
|
|
|
|
return _LaserDevice.LaserOff();
|
|
}
|
|
|
|
public int PilotLaserOn()
|
|
{
|
|
if (IsSimul) {
|
|
return E1.OK;
|
|
}
|
|
if (IsActivated == false || _LaserDevice == null) {
|
|
return E1.GENERIC;
|
|
}
|
|
|
|
return _LaserDevice.PilotLaserOn();
|
|
}
|
|
|
|
public int PilotLaserOff()
|
|
{
|
|
if (IsSimul) {
|
|
return E1.OK;
|
|
}
|
|
if (IsActivated == false || _LaserDevice == null) {
|
|
return E1.GENERIC;
|
|
}
|
|
|
|
return _LaserDevice.PilotLaserOff();
|
|
}
|
|
|
|
public bool GetPilotLaserStatus()
|
|
{
|
|
if (IsSimul) {
|
|
return true;
|
|
}
|
|
if (IsActivated == false || _LaserDevice == null) {
|
|
return false;
|
|
}
|
|
|
|
return _LaserDevice.GetPilotLaserStatus();
|
|
}
|
|
|
|
public bool GetWarningStatus()
|
|
{
|
|
if (IsSimul)
|
|
{
|
|
return true;
|
|
}
|
|
if (IsActivated == false || _LaserDevice == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return _LaserDevice.GetWarningStatus();
|
|
}
|
|
public bool GetEStop()
|
|
{
|
|
if (IsSimul)
|
|
{
|
|
return true;
|
|
}
|
|
if (IsActivated == false || _LaserDevice == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return _LaserDevice.GetEStop();
|
|
}
|
|
public bool GetLaserError()
|
|
{
|
|
if (IsSimul)
|
|
{
|
|
return false;
|
|
}
|
|
if (IsActivated == false || _LaserDevice == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return _LaserDevice.GetLaserError();
|
|
}
|
|
|
|
public string GetControlMode()
|
|
{
|
|
if (IsSimul)
|
|
{
|
|
return "";
|
|
}
|
|
if (IsActivated == false || _LaserDevice == null)
|
|
{
|
|
return "";
|
|
}
|
|
|
|
return _LaserDevice.GetControlMode();
|
|
}
|
|
public bool GetEmissionStatus()
|
|
{
|
|
if (IsSimul)
|
|
{
|
|
return true;
|
|
}
|
|
if (IsActivated == false || _LaserDevice == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return _LaserDevice.GetEmissionStatus();
|
|
}
|
|
public bool GetStartLaserSetBitStatus()
|
|
{
|
|
if (IsSimul)
|
|
{
|
|
return true;
|
|
}
|
|
if (IsActivated == false || _LaserDevice == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return _LaserDevice.GetStartLaserSetBitStatus();
|
|
}
|
|
public bool GetLaserStartSetBitStatus()
|
|
{
|
|
if (IsSimul)
|
|
{
|
|
return true;
|
|
}
|
|
if (IsActivated == false || _LaserDevice == null)
|
|
{
|
|
return false;
|
|
}
|
|
return _LaserDevice.GetLaserStartSetBitStatus();
|
|
}
|
|
public bool GetLaserReady()
|
|
{
|
|
if (IsSimul) {
|
|
return true;
|
|
}
|
|
if (IsActivated == false || _LaserDevice == null) {
|
|
return false;
|
|
}
|
|
|
|
return _LaserDevice.GetLaserReady();
|
|
}
|
|
|
|
public bool GetPilotLaserSetBitStatus()
|
|
{
|
|
if (IsSimul) {
|
|
return true;
|
|
}
|
|
if (IsActivated == false || _LaserDevice == null) {
|
|
return false;
|
|
}
|
|
|
|
return _LaserDevice.GetPilotLaserSetBitStatus();
|
|
}
|
|
public bool GetLaserResetSetBitStatus()
|
|
{
|
|
if (IsSimul)
|
|
{
|
|
return true;
|
|
}
|
|
if (IsActivated == false || _LaserDevice == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return _LaserDevice.GetLaserResetSetBitStatus();
|
|
}
|
|
|
|
public string GetPowerCenter()
|
|
{
|
|
if (IsSimul)
|
|
{
|
|
return "";
|
|
}
|
|
if (IsActivated == false || _LaserDevice == null)
|
|
{
|
|
return "";
|
|
}
|
|
return _LaserDevice.GetPowerCenter();
|
|
}
|
|
public string GetPowerRing()
|
|
{
|
|
if (IsSimul)
|
|
{
|
|
return "";
|
|
}
|
|
if (IsActivated == false || _LaserDevice == null)
|
|
{
|
|
return "";
|
|
}
|
|
return _LaserDevice.GetPowerRing();
|
|
}
|
|
|
|
public bool GetControlModeSetStatus()
|
|
{
|
|
if (IsSimul)
|
|
{
|
|
return true;
|
|
}
|
|
if (IsActivated == false || _LaserDevice == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return _LaserDevice.GetControlModeSetStatus();
|
|
}
|
|
public bool GetInitCommunication()
|
|
{
|
|
if (IsSimul)
|
|
{
|
|
return true;
|
|
}
|
|
if (IsActivated == false || _LaserDevice == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return _LaserDevice.GetInitCommunication();
|
|
}
|
|
public bool GetConnected()
|
|
{
|
|
if (IsSimul) {
|
|
return true;
|
|
}
|
|
if (IsActivated == false || _LaserDevice == null) {
|
|
return false;
|
|
}
|
|
|
|
return _LaserDevice.GetConnected();
|
|
}
|
|
|
|
public int SetData(int nTarget, int value)
|
|
{
|
|
if (IsSimul) {
|
|
return E1.OK;
|
|
}
|
|
if (IsActivated == false || _LaserDevice == null) {
|
|
return E1.GENERIC;
|
|
}
|
|
|
|
return _LaserDevice.SetData(nTarget, value);
|
|
}
|
|
|
|
public int ResetLaser()
|
|
{
|
|
if (IsSimul) {
|
|
return E1.OK;
|
|
}
|
|
if (IsActivated == false || _LaserDevice == null) {
|
|
return E1.GENERIC;
|
|
}
|
|
|
|
return _LaserDevice.ResetLaser();
|
|
}
|
|
|
|
|
|
#region IPG Ethernet 전용 Alarm 및 Status 정보 수신
|
|
public List<string> Alarm1String()
|
|
{
|
|
if (IsSimul) {
|
|
return null;
|
|
}
|
|
if (Config.LaserType != eLaserType.IPG_YLS_Laser) {
|
|
return null;
|
|
}
|
|
if (IsActivated == false || _LaserDevice == null) {
|
|
return null;
|
|
}
|
|
return ((_LaserDevice as LaserDeviceYLS)).Alarm1String();
|
|
}
|
|
public List<string> Alarm2String()
|
|
{
|
|
if (IsSimul) {
|
|
return null;
|
|
}
|
|
if (Config.LaserType != eLaserType.IPG_YLS_Laser) {
|
|
return null;
|
|
}
|
|
if (IsActivated == false || _LaserDevice == null) {
|
|
return null;
|
|
}
|
|
return ((_LaserDevice as LaserDeviceYLS)).Alarm2String();
|
|
}
|
|
|
|
public List<string> AlarmString()
|
|
{
|
|
if (IsSimul) {
|
|
return null;
|
|
}
|
|
if (Config.LaserType != eLaserType.Coherent_Arm_Laser) {
|
|
return null;
|
|
}
|
|
if (IsActivated == false || _LaserDevice == null) {
|
|
return null;
|
|
}
|
|
return ((_LaserDevice as LaserDeviceArm)).GetErrorMessages();
|
|
}
|
|
|
|
public List<string> StatusString()
|
|
{
|
|
if (IsSimul) {
|
|
return null;
|
|
}
|
|
if (Config.LaserType != eLaserType.IPG_YLS_Laser) {
|
|
return null;
|
|
}
|
|
if (IsActivated == false || _LaserDevice == null) {
|
|
return null;
|
|
}
|
|
return ((_LaserDevice as LaserDeviceYLS)).StatusString();
|
|
}
|
|
|
|
public bool GetLaserInterlock() // [25.09.16] ubs.cmy - Laser Interlock 추가
|
|
{
|
|
if(IsSimul)
|
|
return true;
|
|
|
|
if (IsActivated == false || _LaserDevice == null)
|
|
return false;
|
|
|
|
return _LaserDevice.GetLaserInterlock();
|
|
}
|
|
public eLaserType GetLaserType()
|
|
{
|
|
return Config.LaserType;
|
|
}
|
|
#endregion
|
|
|
|
#region PowerProfile
|
|
// PowerMeter 로 측정된 Calibration data 는 Laser 에 Dependent 하므로 Laser Class 에서 관리한다.
|
|
private string pathPowerProfile = "PowerProfileTest.json";
|
|
|
|
public TopRootObject LoadPowerProfile()
|
|
{
|
|
//TopRootObject toproot;
|
|
|
|
var json = File.ReadAllText(pathPowerProfile);
|
|
var root = JsonConvert.DeserializeObject<TopRootObject>(json);
|
|
|
|
return root;
|
|
|
|
}
|
|
public void AddPowerProfile()
|
|
{
|
|
TopRootObject root;
|
|
|
|
if (File.Exists(pathPowerProfile)) {
|
|
var json = File.ReadAllText(pathPowerProfile);
|
|
root = JsonConvert.DeserializeObject<TopRootObject>(json);
|
|
|
|
} else {
|
|
root = new TopRootObject {
|
|
PowerProfilesLists = new List<PowerProfilesList>()
|
|
};
|
|
}
|
|
|
|
PowerProfilesList profilelist = new PowerProfilesList();
|
|
|
|
PowerProfile profile = new PowerProfile();
|
|
|
|
PowerProfileParam param = new PowerProfileParam();
|
|
|
|
profile.PowerProfileParams.Add(param);
|
|
profilelist.PowerProfiles.Add(profile);
|
|
root.PowerProfilesLists.Add(profilelist);
|
|
|
|
|
|
var outputjson = JsonConvert.SerializeObject(root, Formatting.Indented);
|
|
|
|
File.WriteAllText(pathPowerProfile, outputjson);
|
|
|
|
}
|
|
public void CopyPowerProfile(int profileListSelectedIndex)
|
|
{
|
|
var json = File.ReadAllText(pathPowerProfile);
|
|
var root = JsonConvert.DeserializeObject<TopRootObject>(json);
|
|
|
|
PowerProfilesList profilelist = new PowerProfilesList();
|
|
|
|
for (int i = 0; i < root.PowerProfilesLists[profileListSelectedIndex].PowerProfiles.Count; i++) {
|
|
PowerProfile profile = new PowerProfile();
|
|
profile.PowerProfileParams.Add(new PowerProfileParam());
|
|
profile.PowerProfileParams[0].Copy(root.PowerProfilesLists[profileListSelectedIndex].PowerProfiles[i].PowerProfileParams[0]);
|
|
profilelist.PowerProfiles.Add(profile);
|
|
}
|
|
|
|
root.PowerProfilesLists.Add(profilelist);
|
|
|
|
var outputjson = JsonConvert.SerializeObject(root, Formatting.Indented);
|
|
File.WriteAllText(pathPowerProfile, outputjson);
|
|
|
|
}
|
|
public void SavePowerProfile(int profileListSelectedIndex)
|
|
{
|
|
var json = File.ReadAllText(pathPowerProfile);
|
|
var root = JsonConvert.DeserializeObject<TopRootObject>(json);
|
|
|
|
}
|
|
public void DeleteProfiles(int profileListSelectedIndex)
|
|
{
|
|
try {
|
|
var json = File.ReadAllText(pathPowerProfile);
|
|
var root = JsonConvert.DeserializeObject<TopRootObject>(json);
|
|
|
|
root.PowerProfilesLists.RemoveAt(profileListSelectedIndex);
|
|
|
|
var outputjson = JsonConvert.SerializeObject(root, Formatting.Indented);
|
|
|
|
File.WriteAllText(pathPowerProfile, outputjson);
|
|
} catch (Exception ex) {
|
|
Log.E($"{ex.Message}");
|
|
}
|
|
}
|
|
|
|
public void AddPowerProfileParam(int profileListSelectedIndex)
|
|
{
|
|
TopRootObject root = new TopRootObject();
|
|
|
|
if (File.Exists(pathPowerProfile)) {
|
|
var json = File.ReadAllText(pathPowerProfile);
|
|
root = JsonConvert.DeserializeObject<TopRootObject>(json);
|
|
} else {
|
|
Log.E(string.Format($"PowerPorfile Jason file이 존재하지 않습니다."));
|
|
}
|
|
|
|
PowerProfile profile = new PowerProfile();
|
|
|
|
PowerProfileParam param = new PowerProfileParam();
|
|
|
|
profile.PowerProfileParams.Add(param);
|
|
|
|
root.PowerProfilesLists[profileListSelectedIndex].PowerProfiles.Add(profile);
|
|
|
|
var JASON = JsonConvert.SerializeObject(root, Formatting.Indented);
|
|
|
|
File.WriteAllText(pathPowerProfile, JASON);
|
|
|
|
}
|
|
public void CopyProfileParam(int profileListSelectedIndex, int listboxProfileListSelectedIndex)
|
|
{
|
|
var json = File.ReadAllText(pathPowerProfile);
|
|
var root = JsonConvert.DeserializeObject<TopRootObject>(json);
|
|
|
|
PowerProfilesList profilelist = new PowerProfilesList();
|
|
PowerProfile profile = new PowerProfile();
|
|
|
|
profile.PowerProfileParams.Add(new PowerProfileParam());
|
|
profile.PowerProfileParams[0].Copy(root.PowerProfilesLists[profileListSelectedIndex].PowerProfiles[listboxProfileListSelectedIndex].PowerProfileParams[0]);
|
|
root.PowerProfilesLists[profileListSelectedIndex].PowerProfiles.Add(profile);
|
|
|
|
var outputjson = JsonConvert.SerializeObject(root, Formatting.Indented);
|
|
File.WriteAllText(pathPowerProfile, outputjson);
|
|
}
|
|
public void DeleteProfileParam(int profileListSelectedIndex, int listboxProfileListSelectedIndex)
|
|
{
|
|
try {
|
|
var json = File.ReadAllText(pathPowerProfile);
|
|
var root = JsonConvert.DeserializeObject<TopRootObject>(json);
|
|
|
|
root.PowerProfilesLists[profileListSelectedIndex].PowerProfiles.RemoveAt(listboxProfileListSelectedIndex);
|
|
|
|
var outputjson = JsonConvert.SerializeObject(root, Formatting.Indented);
|
|
|
|
File.WriteAllText(pathPowerProfile, outputjson);
|
|
} catch (Exception ex) {
|
|
Log.E($"{ex.Message}");
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
}
|
|
}
|
|
|