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

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -0,0 +1,34 @@
namespace DTS.Common.Enums.DBExport
{
/// <summary>
/// possible root tags in the xml
/// </summary>
public enum TopLevelFields
{
CustomerDetails,
TestEngineerDetails,
LabDetails,
DASList,
SensorModels,
Sensors,
Calibrations,
CustomDirections,
CustomFilterClasses,
CustomTestObjects,
CustomFinLoc1s,
CustomFinLoc2s,
CustomFinLoc3s,
CustomMainLocs,
CustomPhysicalDimensions,
CustomPositions,
CustomChannels,
GroupTemplates,
Groups,
TestSetups,
Users,
GlobalSettings,
//introduce in V7,
//15390 Store the ZMO in EU in the DataPRO DB
SensorChangeHistory
}
}

View File

@@ -0,0 +1,179 @@
using DTS.Common.Interface.Sensors;
using DTS.Common.Interface.TestSetups;
using System;
using System.Collections.Generic;
namespace DTS.Common.Classes.TestSetups
{
public static class ArrayExtensions
{
public static void Fill<T>(this T[] sourceArray, T with)
{
for (var i = 0; i < sourceArray.Length; i++)
{
sourceArray[i] = with;
}
}
public static void SubFill<T>(this T[] source, T with, int startIndex, int finalIndex)
{
for (var i = startIndex; i < source.Length && i < finalIndex; i ++ )
{
source[i] = with;
}
}
public static void SetValues<T>(this T[] source, T[] with, int startIndex, int length, T pad)
{
source.SubFill(pad, startIndex, startIndex + length );
Array.Copy(with, 0, source, startIndex, Math.Min(length, with.Length));
}
public static T[] GetValues<T>(this T[] source, int startIndex, int length)
{
var ret = new T[length];
Array.Copy(source, startIndex, ret, 0, length);
return ret;
}
}
/// <summary>
/// handles writing, reading from an ISF file
/// </summary>
public class ISFFile
{
private char[] _HeaderLine1 = new char [ConstantsAndEnums.RECORD_LENGTH];
/// <summary>
/// RECORD_LENGTH bytes (80)
/// </summary>
public char[] HeaderLine1
{
get => _HeaderLine1;
set
{
_HeaderLine1.Fill(' ');
Array.Copy(value, _HeaderLine1, Math.Min(value.Length, _HeaderLine1.Length));
}
}
/// <summary>
/// 8 characters, starting at character 7
/// </summary>
public char[] TestSetupName
{
get => _HeaderLine1.GetValues(7, 8);
set => _HeaderLine1.SetValues(value, 7, 8, ' ');
}
/// <summary>
/// starts at character 15, 5 characters long
/// </summary>
public char[] NumberOfRecords
{
get => _HeaderLine1.GetValues(15, 5);
private set => _HeaderLine1.SetValues(value, 15, 5, ' ');
}
private void SetNumberOfRecords(int i)
{
var s = i.ToString();
NumberOfRecords = s.ToCharArray();
}
/// <summary>
/// 22 characters, starting at character 20
/// </summary>
public char[] TestType
{
get => _HeaderLine1.GetValues(20, 22);
set => _HeaderLine1.SetValues(value, 20, 22, ' ');
}
/// <summary>
/// 30 characters, starting at character 42
/// </summary>
public char[] TestDivision
{
get => _HeaderLine1.GetValues(42, 30);
set => _HeaderLine1.SetValues(value, 42, 30, ' ');
}
/// <summary>
/// 8 characters start at character 72, without .TCF extension
/// </summary>
public char[] TCFile
{
get => _HeaderLine1.GetValues(72, 8);
set => _HeaderLine1.SetValues(value, 72, 8, ' ');
}
/// <summary>
/// RECORD_LENGTH, we don't use anything from it currently...
/// </summary>
private char[] HeaderLine2 { get; set; } = new char[ConstantsAndEnums.RECORD_LENGTH];
/// <summary>
/// RECORD_LENGTH, we don't use anything from it currently
/// </summary>
private char[] HeaderLine3 { get; set; } = new char[ConstantsAndEnums.RECORD_LENGTH];
private List<IISFSensorRecord> _records = new List<IISFSensorRecord>();
public IISFSensorRecord[] Records => _records.ToArray();
/// <summary>
/// adds a record, updates record count
/// </summary>
/// <param name="record"></param>
public void AddRecord(IISFSensorRecord record)
{
record.SetDataChannelNumber(Convert.ToInt16(1 + _records.Count));
_records.Add(record);
SetNumberOfRecords(Records.Length * 4); //4 "records" per record
}
/// <summary>
/// writes file to path
/// </summary>
/// <param name="pathToFile"></param>
public void WriteToFile(string pathToFile)
{
if (System.IO.File.Exists(pathToFile))
{
Utils.FileUtils.DeleteFileOrMove(pathToFile, LogFunction);
}
using (var fs = new System.IO.FileStream(pathToFile, System.IO.FileMode.CreateNew))
{
using (var bw = new System.IO.BinaryWriter(fs))
{
bw.Write(HeaderLine1);
bw.Write(HeaderLine2);
bw.Write(HeaderLine3);
foreach (var record in Records)
{
record.Write(bw);
bw.Flush();
}
}
}
}
public void AddSensors(ISensorData[] sensors)
{
foreach (var sensor in sensors)
{
var record = new ISFSensorRecord();
record.SetSensor(sensor);
AddRecord(record);
}
}
private void LogFunction(params object[] paramlist)
{
}
public ISFFile()
{
_HeaderLine1.Fill(' ');
}
}
}

View File

@@ -0,0 +1,180 @@
using DTS.Common.Base;
using DTS.Common.Enums;
using DTS.Common.Interface.Sensors;
using System;
using System.Data;
using System.Linq;
namespace DTS.Common.Classes.Sensors
{
public class DigitalOutDbRecord : BasePropertyChanged, IDigitalOutDbRecord
{
private string _serialNumber = "";
public string SerialNumber
{
get => _serialNumber;
set => SetProperty(ref _serialNumber, value, "SerialNumber");
}
private double _doDelay = 0D;
public double DODelay
{
get => _doDelay;
set => SetProperty(ref _doDelay, value, "DODelay");
}
private double _doDuration = 0D;
public double DODuration
{
get => _doDuration;
set => SetProperty(ref _doDuration, value, "DODuration");
}
private string _modifiedBy = "";
public string ModifiedBy
{
get => _modifiedBy;
set => SetProperty(ref _modifiedBy, value, "ModifiedBy");
}
private DateTime _lastModified = DateTime.MinValue;
public DateTime LastModified
{
get => _lastModified;
set => SetProperty(ref _lastModified, value, "LastModified");
}
private int _databaseId = -1;
public int DatabaseId
{
get => _databaseId;
set => SetProperty(ref _databaseId, value, "DatabaseId");
}
private string _isoCode = "";
public string ISOCode
{
get => _isoCode;
set => SetProperty(ref _isoCode, value, "ISOCode");
}
private string _isoChannelName = "";
public string ISOChannelName
{
get => _isoChannelName;
set => SetProperty(ref _isoChannelName, value, "ISOChannelName");
}
private string _userCode = "";
public string UserCode
{
get => _userCode;
set => SetProperty(ref _userCode, value, "UserCode");
}
private string _userChannelName = "";
public string UserChannelName
{
get => _userChannelName;
set => SetProperty(ref _userChannelName, value, "UserChannelName");
}
private bool _broken = false;
public bool Broken
{
get => _broken;
set => SetProperty(ref _broken, value, "Broken");
}
private bool _doNotUse = false;
public bool DoNotUse
{
get => _doNotUse;
set => SetProperty(ref _doNotUse, value, "DoNotUse");
}
private DigitalOutputModes _doMode = DigitalOutputModes.CCNC;
public DigitalOutputModes DOMode
{
get => _doMode;
set => SetProperty(ref _doMode, value, "DOMode");
}
private bool _limitDuration = true;
public bool LimitDuration
{
get => _limitDuration;
set => SetProperty(ref _limitDuration, value, "LimitDuration");
}
private int _version = 0;
public int Version
{
get => _version;
set => SetProperty(ref _version, value, "Version");
}
private byte[] _tagsBlobBytes = null;
public byte [] TagsBlobBytes
{
get => _tagsBlobBytes;
set => SetProperty(ref _tagsBlobBytes, value, "TagsBlobBytes");
}
public DigitalOutDbRecord()
{
}
public DigitalOutDbRecord(ISensorData copy, byte [] tagsBlobBytes)
{
SerialNumber = copy.SerialNumber;
DatabaseId = copy.DatabaseId;
Broken = copy.Broken;
DoNotUse = copy.DoNotUse;
Version = copy.Version;
DOMode = copy.DigitalOutputMode;
LimitDuration = copy.DigitalOutputLimitDuration;
ModifiedBy = copy.LastUpdatedBy;
LastModified = copy.LastModified;
DODuration = copy.DigitalOutputDurationMS;
DODelay = copy.DigitalOutputDelayMS;
if (null == tagsBlobBytes)
{
TagsBlobBytes = null;
}
else if (tagsBlobBytes.Any())
{
var bytes = new byte[tagsBlobBytes.Length];
Array.Copy(tagsBlobBytes, bytes, tagsBlobBytes.Length);
TagsBlobBytes = bytes;
}
else { TagsBlobBytes = new byte[0]; }
}
public DigitalOutDbRecord(IDigitalOutDbRecord copy)
{
SerialNumber = copy.SerialNumber;
DatabaseId = copy.DatabaseId;
Broken = copy.Broken;
DoNotUse = copy.DoNotUse;
Version = copy.Version;
DOMode = copy.DOMode;
LimitDuration = copy.LimitDuration;
ModifiedBy = copy.ModifiedBy;
LastModified = copy.LastModified;
DODuration = copy.DODuration;
DODelay = copy.DODelay;
if( null == copy.TagsBlobBytes)
{
TagsBlobBytes = null;
}
else if(copy.TagsBlobBytes.Any())
{
var tagsBlobBytes = new byte[copy.TagsBlobBytes.Length];
Array.Copy(copy.TagsBlobBytes, tagsBlobBytes, copy.TagsBlobBytes.Length);
TagsBlobBytes = tagsBlobBytes;
}
else { TagsBlobBytes = new byte[0]; }
}
public DigitalOutDbRecord(IDataReader reader)
{
DatabaseId = Utility.GetInt(reader, "Id", -1);
Broken = Utility.GetBool(reader, "Broken", false);
DoNotUse = Utility.GetBool(reader, "DoNotUse");
SerialNumber = Utility.GetString(reader, "SerialNumber");
Version = Utility.GetInt(reader, "Version");
DOMode = (DigitalOutputModes)Utility.GetInt(reader, "OutputMode");
LimitDuration = Utility.GetBool(reader, "LimitDuration", true);
ModifiedBy = Utility.GetString(reader, "LastModifiedBy", string.Empty);
LastModified = Utility.GetDateTime(reader, "LastModified", DateTime.MinValue);
DODuration = Utility.GetDouble(reader, "DurationMSFloat");
DODelay = Utility.GetDouble(reader, "DelayMS");
TagsBlobBytes = (byte[])reader["UserTags"];
}
}
}