This commit is contained in:
2026-04-17 14:55:32 -04:00
commit bc3ac1d4c9
18017 changed files with 4371742 additions and 0 deletions

View File

@@ -0,0 +1,151 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTS.SensorDB.TSF
{
/// <summary>
/// handles the module information section of a TSF
/// </summary>
public class TSFModuleInformationSection
{
private const string SECTION_START_HEADER = "---- Start Module Information ----";
private const string COLUMN_HEADER = "rack,module,trigmode,trigchan,trigdir,triglevel,moduletype";
private const string SECTION_END_HEADER = "---- End Module Information ----";
/// <summary>
/// reads the section from a TSF
/// assumes currentline is the start of the section
/// </summary>
/// <param name="lines"></param>
/// <param name="currentLine"></param>
/// <param name="errors"></param>
/// <param name="system"></param>
/// <param name="rackSection"></param>
public void ReadFrom(List<string> lines, ref int currentLine, ref List<ReadTSFError> errors, TSFSystemDescription system, TSFRackInformationSection rackSection)
{
if (currentLine == lines.Count)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_UNEXPECTED_EOF, currentLine));
return;
}
string sectionHeader = lines[currentLine++];
if (sectionHeader != SECTION_START_HEADER)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.MODULEINFORMATIONSECTION_BADHEADER, currentLine, sectionHeader));
return;
}
if (currentLine == lines.Count)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_UNEXPECTED_EOF, currentLine));
return;
}
string columnHeader = lines[currentLine++];
if (columnHeader != COLUMN_HEADER)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.MODULEINFORMATIONSECTION_BADCOLUMHEADER, currentLine, columnHeader));
return;
}
var invariant = System.Globalization.CultureInfo.InvariantCulture;
bool done = false;
while (!done)
{
if (currentLine == lines.Count)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_UNEXPECTED_EOF, currentLine));
return;
}
string line = lines[currentLine++];
if (!line.Contains("End Module Information"))
{
string[] tokens = line.Split(new char[] { ',' });
if (tokens.Length < 7)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_SKIPPING_MODULE_TOO_FEW_TOKENS, currentLine));
continue;
}
int r;
try { r = int.Parse(tokens[0], invariant); }
catch (System.Exception)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_MODULE_INVALID_RACK_FIELD, currentLine, tokens[0]));
continue;
}
int m;
try { m = int.Parse(tokens[1], invariant); }
catch (System.Exception)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_MODULE_INVALID_MODULE_FIELD, currentLine, tokens[1]));
continue;
}
int trigMode;
try { trigMode = int.Parse(tokens[2], invariant); }
catch (System.Exception)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_MODULE_INVALID_TRIGGERMODE_FIELD, currentLine, tokens[2]));
continue;
}
int trigChan;
try { trigChan = int.Parse(tokens[3], invariant); }
catch (System.Exception)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_MODULE_INVALID_TRIGGERCHAN_FIELD, currentLine, tokens[3]));
continue;
}
int trigDir;
try { trigDir = int.Parse(tokens[4], invariant); }
catch (System.Exception)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_MODULE_INVALID_TRIGGERDIR_FIELD, currentLine, tokens[4]));
continue;
}
double trigLevel;
try { trigLevel = double.Parse(tokens[5], invariant); }
catch (System.Exception)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_MODULE_INVALID_TRIGGERLEVEL_FIELD, currentLine, tokens[5]));
continue;
}
int moduleType;
try { moduleType = int.Parse(tokens[6], invariant); }
catch (System.Exception)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_MODULE_INVALID_MODULETYPE_FIELD, currentLine, tokens[6]));
continue;
}
//var rackHW = system.HWRack[r];
bool bFound = false;
foreach (var curRack in rackSection.Racks)
{
if (curRack.Number == r)
{
curRack.SetModule(m, trigMode, trigChan, trigDir, trigLevel, moduleType);
bFound = true;
break;
}
}
if (!bFound)
{
errors.Add(new ReadTSFError(ReadTSFError.TSF_ERRORS.TSF_MODULE_SKIPPED_RACKNOTFOUND, currentLine));
continue;
}
}
else { done = true; }
}
}
}
}

View File

@@ -0,0 +1,53 @@
using DTS.Common.Enums;
using DTS.Common.Enums.Sensors;
using DTS.Common.Interface.Sensors;
using DTS.Slice.Users.UserSettings;
using System;
namespace DTS.SensorDB
{
public class StreamInputSettingDefaults : DTS.Common.Base.BasePropertyChanged, IStreamInputSettingDefaults
{
private ISensorData _defaultStreamInput;
public string UDPAddress { get => _defaultStreamInput.StreamInUDPAddress; set => _defaultStreamInput.StreamInUDPAddress = value; }
public bool Validate()
{
if (!UDPAddress.ToLower().StartsWith("udp") || !Uri.IsWellFormedUriString(UDPAddress, UriKind.Absolute))
{
return false;
}
return true;
}
public static void CommitChange(StreamInputSettingDefaults settingDefaults, int userID)
{
TestSetupDefaults.SetUserSetting(userID, PropertyEnums.PropertyIds.DefaultUDPStreamAddress, settingDefaults.UDPAddress);
}
public static StreamInputSettingDefaults GetStreamInputSettingsDefault(int userID)
{
var sd = new SensorData()
{
StreamInUDPAddress = TestSetupDefaults.GetUserSettingValueString(userID, PropertyEnums.PropertyIds.DefaultUDPStreamAddress),
};
return new StreamInputSettingDefaults(sd);
}
public static StreamInputSettingDefaults GetStreamInputSettingsDefault(string user)
{
var sd = DTS.SensorDB.SensorsCollection.SensorsList.GetSensorBySerialNumber(SensorConstants.TEST_SPECIFIC_STREAM_IN_SERIAL);
return new StreamInputSettingDefaults(sd);
}
private StreamInputSettingDefaults(SensorData sd)
{
_defaultStreamInput = sd;
}
}
}