|
@@ -49,6 +49,8 @@ namespace TeamAAS_VP.Services
|
|
|
// 光源控制器配置
|
|
// 光源控制器配置
|
|
|
private ObservableCollection<LightControllerConfig> LightControllers { get; set; }
|
|
private ObservableCollection<LightControllerConfig> LightControllers { get; set; }
|
|
|
|
|
|
|
|
|
|
+ private PlcAddressConfig PlcAddressConfig { get; set; }
|
|
|
|
|
+
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// 初始化一个新的 <see cref="ConfigService"/> 实例。
|
|
/// 初始化一个新的 <see cref="ConfigService"/> 实例。
|
|
|
/// 构造函数不会自动加载配置文件(避免在构造期间进行 I/O 操作);可调用 <see cref="LoadAll"/> 或 <see cref="LoadAllAsync"/> 显式加载。
|
|
/// 构造函数不会自动加载配置文件(避免在构造期间进行 I/O 操作);可调用 <see cref="LoadAll"/> 或 <see cref="LoadAllAsync"/> 显式加载。
|
|
@@ -131,6 +133,15 @@ namespace TeamAAS_VP.Services
|
|
|
{
|
|
{
|
|
|
LightControllers = FileHelper.ReadJsonFile<ObservableCollection<LightControllerConfig>>(ConfigPaths.LightControllersConfigurationPath);
|
|
LightControllers = FileHelper.ReadJsonFile<ObservableCollection<LightControllerConfig>>(ConfigPaths.LightControllersConfigurationPath);
|
|
|
}
|
|
}
|
|
|
|
|
+ // load plc addresses
|
|
|
|
|
+ var plcAddressPath = "..//Config//PlcAddressConfiguration.cfg";
|
|
|
|
|
+ if (File.Exists(plcAddressPath))
|
|
|
|
|
+ PlcAddressConfig = FileHelper.ReadJsonFile<PlcAddressConfig>(plcAddressPath);
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ PlcAddressConfig = new PlcAddressConfig();
|
|
|
|
|
+ FileHelper.WriteJsonFile(PlcAddressConfig, plcAddressPath);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -158,6 +169,8 @@ namespace TeamAAS_VP.Services
|
|
|
FileHelper.WriteJsonFile(BgCommunicate, ConfigPaths.BgTcpIpConfigurationPath);
|
|
FileHelper.WriteJsonFile(BgCommunicate, ConfigPaths.BgTcpIpConfigurationPath);
|
|
|
FileHelper.WriteJsonFile(BgModbusCommunicate, ConfigPaths.BgModbusTcpConfigurationPath);
|
|
FileHelper.WriteJsonFile(BgModbusCommunicate, ConfigPaths.BgModbusTcpConfigurationPath);
|
|
|
FileHelper.WriteJsonFile(LightControllers, ConfigPaths.LightControllersConfigurationPath);
|
|
FileHelper.WriteJsonFile(LightControllers, ConfigPaths.LightControllersConfigurationPath);
|
|
|
|
|
+ // save plc addresses
|
|
|
|
|
+ //FileHelper.WriteJsonFile(PlcAddressConfig, "..//Config//PlcAddressConfiguration.cfg");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -903,6 +916,10 @@ namespace TeamAAS_VP.Services
|
|
|
|
|
|
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
+ #region Plc Addresses
|
|
|
|
|
+ public PlcAddressConfig GetPlcAddresses() { lock (_sync) { return PlcAddressConfig; } }
|
|
|
|
|
+ #endregion
|
|
|
|
|
+
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// 释放资源并保存当前内存中的所有配置到文件。
|
|
/// 释放资源并保存当前内存中的所有配置到文件。
|
|
|
/// </summary>
|
|
/// </summary>
|