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,131 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
namespace DatabaseExport
{
public class MMEFigures : AbstractOLEDbWrapper
{
public long ID { get; }
public string TxtShortName { get; }
public string TxtDescription { get; }
public string TxtRemarks { get; }
public DateTime DatRevision { get; }
public long IntAuthor { get; }
public ushort IntPage { get; }
public ushort IntPages { get; }
public string TxtImageFile { get; }
public long IntVersion { get; }
public bool BolExpired { get; }
public string TxtSortKey { get; }
public bool BitStdPath { get; }
public long IntIDStdPath { get; }
public string TxtPath { get; }
public DateTime Last_Change { get; }
public string Last_Change_Text { get; }
public string History { get; }
public MMEFigures(long id, string txtShortName, string txtDescription, string txtRemarks, DateTime datRevision, long intAuthor,
ushort intPage, ushort intPages, string txtImageFile, long version, bool bExpired, string txtSortKey,
bool bitStdPath, long intIDStdPath, string txtPath, DateTime lastChange, string lastChangeText, string history)
{
ID = id;
TxtShortName = txtShortName;
TxtDescription = txtDescription;
TxtRemarks = txtRemarks;
DatRevision = datRevision;
IntAuthor = intAuthor;
IntPage = intPage;
IntPages = intPages;
TxtImageFile = txtImageFile;
IntVersion = version;
BolExpired = bExpired;
TxtSortKey = txtSortKey;
BitStdPath = bitStdPath;
IntIDStdPath = intIDStdPath;
TxtPath = txtPath;
Last_Change = lastChange;
Last_Change_Text = lastChangeText;
History = history;
}
public static MMEFigures[] GetFigures()
{
var figures = new List<MMEFigures>();
using (var cmd = DbOperations.GetISOCommand())
{
cmd.CommandText = "SELECT * FROM MMEFIGURES";
cmd.CommandType = CommandType.Text;
try
{
using (var ISOReader = cmd.ExecuteReader())
{
while (ISOReader.Read())
{
try
{
var id = Convert.ToInt64(ISOReader["ID"]);
var txtShortName = ISOReader["txtShortName"].ToString();
var txtDescription = ISOReader["txtDescription"].ToString();
var txtRemarks = ISOReader["txtRemarks"].ToString();
var datRevision = DateTime.MinValue;
if (!DBNull.Value.Equals(ISOReader["datRevision"]))
{
datRevision = (DateTime)ISOReader["datRevision"];
}
var intAuthor = Convert.ToInt64(ISOReader["intAuthor"]);
var intPage = Convert.ToUInt16(ISOReader["intPage"]);
var intPages = Convert.ToUInt16(ISOReader["intPages"]);
var txtImageFile = ISOReader["txtImageFile"].ToString();
var version = Convert.ToInt64(ISOReader["intVersion"]);
var bExpired = (bool)ISOReader["bolExpired"];
var txtSortKey = ISOReader["txtSortKey"].ToString();
var bitStdPath = (bool)ISOReader["bitStdPath"];
var intIDStdPath = Convert.ToInt64(ISOReader["IntIDStdPath"]);
var txtPath = ISOReader["txtPath"].ToString();
var lastChange = DateTime.MinValue;
if (!DBNull.Value.Equals(ISOReader["LAST_CHANGE"]))
{
datRevision = (DateTime)ISOReader["LAST_CHANGE"];
}
var lastChangeText = ISOReader["LAST_CHANGE_TEXT"].ToString();
var history = ISOReader["HISTORY"].ToString();
figures.Add(new MMEFigures(id, txtShortName, txtDescription, txtRemarks, datRevision, intAuthor, intPage,
intPages, txtImageFile, version, bExpired, txtSortKey, bitStdPath, intIDStdPath, txtPath, lastChange,
lastChangeText, history));
}
catch (Exception)
{
//ignore
}
}
ISOReader.Close();
}
}
finally
{
cmd.Connection.Dispose();
}
}
return figures.ToArray();
}
}
}

View File

@@ -0,0 +1,147 @@
using System;
namespace DatabaseExport
{
/// <summary>
/// the scaler is a bit different than an ordinary scaler, so the name here is inaccurate, however the idea is
/// that we allow the user to transform collected data, primarly by allowing them to define the 0,1 value of the digital output
/// </summary>
public class DigitalInputScaleMultiplier
{
/// <summary>
/// these are the different input modes for the data
/// </summary>
public enum InputModes
{
TLH = 1 << 1, //Transition Low to High
THL = 1 << 2, //Transition High to Low
CCNO = 1 << 3, //set to contact closure normally open
CCNC = 1 << 4 //set to contact closure normally closed
}
/// <summary>
/// the format the scaler is in
/// </summary>
public enum Forms { ArbitraryLowAndHigh };
public Forms Form { get; set; } = Forms.ArbitraryLowAndHigh;
// /// <summary>
// /// for arbirary low/high, this is the low value, the value 0 should be displayed as (OFF)
// /// </summary>
public double DefaultValue { get; set; }
/// <summary>
/// for arbitrary low/high, this is the high value, the value 1 should be displayed as (ON)
/// </summary>
public double ActiveValue { get; set; } = 1D;
// public bool SimpleEquals(DigitalInputScaleMultiplier rhs)
// {
// return Form == rhs.Form && DefaultValue == rhs.DefaultValue && ActiveValue == rhs.ActiveValue;
// }
// public override bool Equals(object obj)
// {
// if (obj is DigitalInputScaleMultiplier)
// {
// var b = obj as DigitalInputScaleMultiplier;
// return b.Form == Form
// && b.ActiveValue == ActiveValue
// && b.DefaultValue == DefaultValue;
// }
// else { return false; }
// }
// public override int GetHashCode()
// {
// //the idea here is to use two primes to avoid collisions, it's not perfect but should work in general and we can predict when it won't
// if (ActiveValue == 31 || DefaultValue == 31 || DefaultValue == 79 || ActiveValue == 79)
// {
// return (int)Form + Convert.ToInt32(ActiveValue * 127) + Convert.ToInt32(DefaultValue * 23);
// }
// else
// {
// return (int)Form + Convert.ToInt32(ActiveValue * 31) + Convert.ToInt32(DefaultValue * 79);
// }
// }
// /// <summary>
// /// constructor and copy constructor
// /// </summary>
public DigitalInputScaleMultiplier()
{
DefaultValue = 0D;
}
public DigitalInputScaleMultiplier(DigitalInputScaleMultiplier copy)
{
Form = copy.Form;
DefaultValue = copy.DefaultValue;
ActiveValue = copy.ActiveValue;
}
/// <summary>
/// serializes scaler to a string
/// </summary>
/// <returns></returns>
public string ToSerializeDbString()
{
switch (Form)
{
case Forms.ArbitraryLowAndHigh: return ToSerializeDbStringLowAndHigh();
default: throw new NotSupportedException("DigitalScaleMultiplier::ToSerializeDbString unsupported form: " + Form.ToString());
}
}
/// <summary>
/// serializes an ArbitraryLowHigh to a string
/// </summary>
/// <returns></returns>
private string ToSerializeDbStringLowAndHigh() { return string.Format("{1}{0}{2}{0}{3}", System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator, Form.ToString(), DefaultValue.ToString(System.Globalization.CultureInfo.InvariantCulture), ActiveValue.ToString(System.Globalization.CultureInfo.InvariantCulture)); }
// /// <summary>
// /// deserializes an arbitrary low/high from a string
// /// </summary>
// /// <param name="tokens"></param>
// private void FromDbSerializeStringLowAndHigh(string[] tokens)
// {
// if (tokens.Length < 3) { throw new NotSupportedException("DigitalInputScaleMultiplier::FromDbSerializeStringLowAndHigh invalid format for scale multiplier"); }
// double d;
// if (double.TryParse(tokens[1], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out d))
// {
// DefaultValue = d;
// }
// else { throw new NotSupportedException("DigitalInputScaleMultiplier::FromDbSerializeStringLowAndHigh invalid format for low value: " + tokens[1]); }
// if (double.TryParse(tokens[2], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out d))
// {
// ActiveValue = d;
// }
// else { throw new NotSupportedException("DigitalInputScaleMultiplier::FromDbSerializeStringLowAndHigh invalid format for high value: " + tokens[2]); }
// }
/// <summary>
/// deserializes a scaler from a string, regardless of format
/// </summary>
/// <param name="s"></param>
public void FromDbSerializeString(string s)
{
if (null == s)
{
//Utilities.Logging.APILogger.Log("Unable to serialize Db. String is null.");
//FIXME is this the right thing to do?
return;
//throw new NotSupportedException("DigitalINputScaleMultiplier::FromDbSerializeString nothing to parse");
}
// string[] tokens = s.Split(new[] { System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator }, StringSplitOptions.None);
// Forms form;
// if (Enum.TryParse(tokens[0], out form))
// {
// Form = form;
// switch (form)
// {
// case Forms.ArbitraryLowAndHigh: FromDbSerializeStringLowAndHigh(tokens); break;
// default: throw new NotSupportedException("DigitalInputScaleMultiplier::FromDbSerializeString unsupported form " + form.ToString());
// }
// }
// else { throw new NotSupportedException("DigitalINputScaleMultiplier::FromDbSerializeString unsupported format: " + s); }
}
}
}