Files
DP44/DataPRO/SensorDB/IsoCode.cs
2026-04-17 14:55:32 -04:00

205 lines
6.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTS.SensorDB
{
public class IsoCode
{
private char[] _isoCodeFull = new char[] { '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0' };
private char _TestObject { get { return _isoCodeFull[0]; } set { _isoCodeFull[0] = value; } }
public string TestObject
{
get { return new string(new char[] { _TestObject }); }
set
{
if (string.IsNullOrEmpty(value)) { _TestObject = '?'; }
else { _TestObject = value[0]; }
}
}
private char _Position { get { return _isoCodeFull[1]; } set { _isoCodeFull[1] = value; } }
public string Position
{
get { return new string(new char[] { _Position }); }
set
{
if (string.IsNullOrEmpty(value)) { _Position = '?'; }
else { _Position = value[0]; }
}
}
private char[] _MainLocation
{
get { return new char[] { _isoCodeFull[2], _isoCodeFull[3], _isoCodeFull[4], _isoCodeFull[5] }; }
set
{
for (int i = 0; i < 4; i++)
{
if (value.Length <= i) { _isoCodeFull[i + 2] = '0'; }
else { _isoCodeFull[i + 2] = value[i]; }
}
}
}
public string MainLocation
{
get { return new string(_MainLocation); }
set
{
string main = value;
if (main.Length < 4) { main = main.PadRight(4, '?'); }
else if (main.Length > 4) { main = main.Substring(0, 4); }
_MainLocation = main.ToCharArray(0, 4);
}
}
private char[] _FineLocation1
{
get { return new char[] { _isoCodeFull[6], _isoCodeFull[7] }; }
set
{
for (int i = 0; i < 2; i++)
{
if (value.Length < i) { _isoCodeFull[i + 6] = '0'; }
else { _isoCodeFull[i + 6] = value[i]; }
}
}
}
public string FineLocation1
{
get { return new string(_FineLocation1); }
set
{
string loc = value;
if (loc.Length < 2) { loc = loc.PadRight(2, '?'); }
else if (loc.Length > 2) { loc = loc.Substring(0, 2); }
_FineLocation1 = loc.ToCharArray(0, 2);
}
}
private char[] _FineLocation2
{
get { return new char[] { _isoCodeFull[8], _isoCodeFull[9] }; }
set
{
for (int i = 0; i < 2; i++)
{
if (value.Length < i) { _isoCodeFull[i + 8] = '0'; }
else { _isoCodeFull[i + 8] = value[i]; }
}
}
}
public string FineLocation2
{
get { return new string(_FineLocation2); }
set
{
string loc = value;
if (loc.Length < 2) { loc = loc.PadRight(2, '?'); }
else if (loc.Length > 2) { loc = loc.Substring(0, 2); }
_FineLocation2 = loc.ToCharArray(0, 2);
}
}
private char[] _FineLocations3
{
get { return new char[] { _isoCodeFull[10], _isoCodeFull[11] }; }
set
{
for (int i = 0; i < 2; i++)
{
if (value.Length < i) { _isoCodeFull[i + 10] = '0'; }
else { _isoCodeFull[i + 10] = value[i]; }
}
}
}
public string FineLocation3
{
get { return new string(_FineLocations3); }
set
{
string loc = value;
if (loc.Length < 2) { loc = loc.PadRight(2, '?'); }
else if (loc.Length > 2) { loc = loc.Substring(0, 2); }
_FineLocations3 = loc.ToCharArray(0, 2);
}
}
private char[] _PhysicalDimension
{
get { return new char[] { _isoCodeFull[12], _isoCodeFull[13] }; }
set
{
for (int i = 0; i < 2; i++)
{
if (value.Length < i) { _isoCodeFull[i + 12] = '0'; }
else { _isoCodeFull[i + 12] = value[i]; }
}
}
}
public string PhysicalDimension
{
get { return new string(_PhysicalDimension); }
set
{
string dim = value;
if (dim.Length < 2) { dim = dim.PadRight(2, '?'); }
else if (dim.Length > 2) { dim = dim.Substring(0, 2); }
_PhysicalDimension = dim.ToCharArray(0, 2);
}
}
private char _Direction { get { return _isoCodeFull[14]; } set { _isoCodeFull[14] = value; } }
public string Direction
{
get { return new string(new char[] { _Direction }); }
set
{
if (string.IsNullOrEmpty(value)) { _Direction = '?'; }
else { _Direction = value[0]; }
}
}
private char _FilterClass { get { return _isoCodeFull[15]; } set { _isoCodeFull[15] = value; } }
public string FilterClass
{
get { return new string(new char[] { _FilterClass }); }
set
{
if (string.IsNullOrEmpty(value)) { _FilterClass = '?'; }
else { _FilterClass = value[0]; }
}
}
public IsoCode(string isoCode)
{
if (null == isoCode) { isoCode = ""; }
if (isoCode.Length > 16) { isoCode = isoCode.Substring(0, 16); }
if (isoCode.Length < 16)
{
isoCode = isoCode.PadRight(16, '?');
}
for (int i = 0; i < 16; i++) { _isoCodeFull[i] = isoCode[i]; }
}
public string StringRepresentation
{
get
{
StringBuilder sb = new StringBuilder();
foreach (char c in _isoCodeFull) { sb.Append(c); }
return sb.ToString();
}
set
{
for (int i = 0; i < 16; i++)
{
if (i >= value.Length) { _isoCodeFull[i] = '0'; }
else { _isoCodeFull[i] = value[i]; }
}
}
}
}
}