Minor changes

This commit is contained in:
Duc
2025-01-06 11:29:57 -07:00
parent d8d73197a9
commit c689fcb7f9
6 changed files with 22 additions and 28 deletions

View File

@@ -33,9 +33,6 @@ namespace ProgramLib
// List data folder + its subfolders
DATA,
DATA_TEMP,
// List app folder + its folders
APP
}
public enum Files

View File

@@ -15,13 +15,11 @@ GOVERNMENT.
UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
-------------------------------------------------------------------------*/
using Raytheon.Common;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Raytheon.Common;
using System.Reflection;
namespace ProgramLib
{
@@ -44,9 +42,9 @@ namespace ProgramLib
{
_programConfig = programConfig;
buildFolders();
createFolders();
buildFiles();
ConstructFolderPaths();
CreateFolders();
ConstructFilePaths();
}
/// <summary>
@@ -54,16 +52,18 @@ namespace ProgramLib
/// </summary>
/// <param name="iniObj"></param>
/// <returns></returns>
private void buildFolders()
private void ConstructFolderPaths()
{
string dataBasePath = _programConfig.ReadValue(ProgramConfigIni.GENERAL.ToString(), ProgramConfigIni.DATA_BASE_PATH.ToString(), "NOT SET");
foldersDict[Folders.DATA] = dataBasePath;
string assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string dataRootPath = _programConfig.ReadValue(ProgramConfigIni.GENERAL.ToString(), ProgramConfigIni.DATA_BASE_PATH.ToString(), "NOT SET");
if (!Path.IsPathRooted(dataRootPath))
dataRootPath = Path.Combine(assemblyFolder, dataRootPath);
foldersDict[Folders.DATA] = Path.GetFullPath(dataRootPath);
string val = _programConfig.ReadValue(ProgramConfigIni.GENERAL.ToString(), ProgramConfigIni.DATA_TEMP_PATH.ToString(), "NOT SET");
foldersDict[Folders.DATA_TEMP] = Path.Combine(dataBasePath, val);
string appBasePath = _programConfig.ReadValue(ProgramConfigIni.GENERAL.ToString(), ProgramConfigIni.APP_BASE_PATH.ToString(), "NOT SET");
foldersDict[Folders.APP] = dataBasePath;
foldersDict[Folders.DATA_TEMP] = Path.Combine(dataRootPath, val);
}
/// <summary>
@@ -71,7 +71,7 @@ namespace ProgramLib
/// </summary>
/// <param name="iniObj"></param>
/// <returns></returns>
private void createFolders()
private void CreateFolders()
{
Directory.CreateDirectory(foldersDict[Folders.DATA_TEMP]);
}
@@ -81,7 +81,7 @@ namespace ProgramLib
/// </summary>
/// <param name="iniObj"></param>
/// <returns></returns>
private void buildFiles()
private void ConstructFilePaths()
{
string val = _programConfig.ReadValue(ProgramConfigIni.GENERAL.ToString(), ProgramConfigIni.POWER_SUPPLY_SELF_TEST_DATETIME.ToString(), "NOT SET");
filesDict[Files.POWER_SUPPLY_SELF_TEST_DATETIME] = Path.Combine(foldersDict[Folders.DATA_TEMP], val);

View File

@@ -59,12 +59,13 @@ namespace ProgramLib
lock (syncObjDict[moduleName])
{
if (!_powerSupplyDataDict.ContainsKey(moduleName))
PowerSupplyData data = null;
if (_powerSupplyDataDict.ContainsKey(moduleName))
{
throw new Exception($"{moduleName} is invalid");
data = _powerSupplyDataDict[moduleName];
}
return _powerSupplyDataDict[moduleName];
return data;
}
}

View File

@@ -1,11 +1,8 @@
[GENERAL]
; specify data folder and all subfolders in it
DATA_BASE_PATH = C:\NGSRI\Data
DATA_BASE_PATH = .\Output
DATA_TEMP_PATH = Temp
; specify app folder and all subfolders in it
APP_BASE_PATH = C:\NGSRI\App
; Log names
POWER_SUPPLY_SELF_TEST_DATETIME = power_supply_self_test_datetime.xml

View File

@@ -131,7 +131,6 @@ namespace ProgramLib
EventGroup<Events, EventWaitHandle> eventGroup = new EventGroup<Events, EventWaitHandle>(eventDict);
Random rnd = new Random();
while (true)
{
Events id = eventGroup.WaitAny(pollRateMs);
@@ -140,7 +139,7 @@ namespace ProgramLib
{
PowerSupplyData data = Program.Instance()._powerSupplySharedData.GetData(PowerSupplyConstants.POWER_DEVICE.STE_PVM_5V.ToString());
if (data._initialized)
if (data != null && data._initialized)
{
_powerModuleToPowerDataModelDict["UUT_P20V"].ActualVoltage = data._voltage.ToString("0.00");
_powerModuleToPowerDataModelDict["UUT_P20V"].ExpectedVoltage = data._powerSupplyModuleInfo.voltageSetpoint_.ToString("0.00");

Binary file not shown.