Skip to content

Commit

Permalink
Added default calculation settings to service config at startup
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchiecarroll committed Feb 9, 2025
1 parent 2e351ce commit 9335dbf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Source/Applications/SIEGate/SIEGate/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
<add name="RemoteCertificatesPath" value="Certs\Remotes" description="Path to the directory where remote certificates are stored." encrypted="false"/>
<add name="InstalledBitSize" value="64" description="Target installation bit size (used by installer)." encrypted="false"/>
<add name="PointTagNameExpression" value="{CompanyAcronym}_{DeviceAcronym}[?{SignalType.Source}=Phasor[:eval{'{PhasorLabel}'.Trim().ToUpper().Replace(' ','_')}_eval{'{SignalType.Abbreviation}'.Substring(0,1)}eval{'{Phase}'=='+'?'1':('{Phase}'=='-'?'2':'{Phase}')}[?{BaseKV}&gt;0[_{BaseKV}]][?{SignalType.Suffix}=PA[.ANG]][?{SignalType.Suffix}=PM[.MAG]]]][?{SignalType.Acronym}=ALOG[:eval{('{Label}'.Trim().Length&gt;0?'{Label}'.Trim().ToUpper().Replace(' ','_'):'ALOG'+((int){SignalIndex}).ToString().PadLeft(2,(char)48))}]][?{SignalType.Source}!=Phasor[?{SignalType.Acronym}!=ALOG[:{SignalType.Acronym}[?{SignalIndex}!=-1[eval{((int){SignalIndex}).ToString().PadLeft(2,(char)48)}]]]]]" description="Defines the expression used to create point tag names. NOTE: if updating this setting, synchronize value in both the manager and service config files." encrypted="false" scope="Application"/>
</systemSettings>
<add name="DefaultCalculationLagTime" value="5" description="Defines the default lag-time value, in seconds, for template calculations" encrypted="false" />
<add name="DefaultCalculationLeadTime" value="5" description="Defines the default lead-time value, in seconds, for template calculations" encrypted="false" /> </systemSettings>
<serviceHelper>
<add name="MonitorServiceHealth" value="True" description="True if the service health is to be monitored; otherwise False." encrypted="false"/>
<add name="HealthMonitorInterval" value="5" description="The interval, in seconds, over which to sample the performance montitor for health statistics." encrypted="false"/>
Expand Down
2 changes: 2 additions & 0 deletions Source/Applications/SIEGate/SIEGate/AppDebug.config
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
<add name="RemoteCertificatesPath" value="Certs\Remotes" description="Path to the directory where remote certificates are stored." encrypted="false"/>
<add name="InstalledBitSize" value="64" description="Target installation bit size (used by installer)." encrypted="false"/>
<add name="PointTagNameExpression" value="{CompanyAcronym}_{DeviceAcronym}[?{SignalType.Source}=Phasor[:eval{'{PhasorLabel}'.Trim().ToUpper().Replace(' ','_')}_eval{'{SignalType.Abbreviation}'.Substring(0,1)}eval{'{Phase}'=='+'?'1':('{Phase}'=='-'?'2':'{Phase}')}[?{BaseKV}&gt;0[_{BaseKV}]][?{SignalType.Suffix}=PA[.ANG]][?{SignalType.Suffix}=PM[.MAG]]]][?{SignalType.Acronym}=ALOG[:eval{('{Label}'.Trim().Length&gt;0?'{Label}'.Trim().ToUpper().Replace(' ','_'):'ALOG'+((int){SignalIndex}).ToString().PadLeft(2,(char)48))}]][?{SignalType.Source}!=Phasor[?{SignalType.Acronym}!=ALOG[:{SignalType.Acronym}[?{SignalIndex}!=-1[eval{((int){SignalIndex}).ToString().PadLeft(2,(char)48)}]]]]]" description="Defines the expression used to create point tag names. NOTE: if updating this setting, synchronize value in both the manager and service config files." encrypted="false" scope="Application"/>
<add name="DefaultCalculationLagTime" value="5" description="Defines the default lag-time value, in seconds, for template calculations" encrypted="false" />
<add name="DefaultCalculationLeadTime" value="5" description="Defines the default lead-time value, in seconds, for template calculations" encrypted="false" />
</systemSettings>
<serviceHelper>
<add name="MonitorServiceHealth" value="True" description="True if the service health is to be monitored; otherwise False." encrypted="false"/>
Expand Down
22 changes: 18 additions & 4 deletions Source/Applications/SIEGate/SIEGate/ServiceHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
//
//******************************************************************************************************

using System;
using GSF.TimeSeries;
using GSF;
using GSF.Configuration;
using GSF.Diagnostics;

namespace SIEGate
{
Expand All @@ -39,11 +41,23 @@ protected override void ServiceStartingHandler(object sender, EventArgs<string[]
// Handle base class service starting procedures
base.ServiceStartingHandler(sender, e);

// Make sure SIEGate specific default service settings exist
CategorizedSettingsElementCollection systemSettings = ConfigurationFile.Current.Settings["systemSettings"];
try
{
// Make sure SIEGate specific default service settings exist
CategorizedSettingsElementCollection systemSettings = ConfigurationFile.Current.Settings["systemSettings"];

systemSettings.Add("CompanyName", "Grid Protection Alliance", "The name of the company who owns this instance of the SIEGate.");
systemSettings.Add("CompanyAcronym", "GPA", "The acronym representing the company who owns this instance of the SIEGate.");
systemSettings.Add("CompanyName", "Grid Protection Alliance", "The name of the company who owns this instance of the SIEGate.");
systemSettings.Add("CompanyAcronym", "GPA", "The acronym representing the company who owns this instance of the SIEGate.");
systemSettings.Add("DefaultCalculationLagTime", 5.0, "Defines the default lag-time value, in seconds, for template calculations");
systemSettings.Add("DefaultCalculationLeadTime", 5.0, "Defines the default lead-time value, in seconds, for template calculations");
systemSettings.Add("DefaultCalculationFramesPerSecond", 30, "Defines the default frames-per-second value for template calculations");

ConfigurationFile.Current.Save();
}
catch (Exception ex)
{
Logger.SwallowException(new InvalidOperationException($"{nameof(ServiceStartingHandler)} failed while adding default settings: {ex.Message}", ex));
}
}
}
}

0 comments on commit 9335dbf

Please sign in to comment.