init
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public abstract class TagAwareBase : DbTimeStampBase
|
||||
{
|
||||
public byte[] TagsBlobBytes
|
||||
{
|
||||
get
|
||||
{
|
||||
byte[] result = new byte[TagIDs.Length * sizeof(int)];
|
||||
Buffer.BlockCopy(TagIDs, 0, result, 0, result.Length);
|
||||
return result;
|
||||
}
|
||||
set
|
||||
{
|
||||
var tagsBlob = new int[value.Length / sizeof(int)];
|
||||
try
|
||||
{
|
||||
Buffer.BlockCopy(value, 0, tagsBlob, 0, value.Length);
|
||||
TagIDs = tagsBlob;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//Utilities.Logging.APILogger.Log(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
private int[] _tagIDs = new int[0];
|
||||
public int[] TagIDs
|
||||
{
|
||||
get => _tagIDs;
|
||||
set => _tagIDs = value ?? new int[0];
|
||||
}
|
||||
public string GetTagsCommaSeperatedString()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
foreach (var s in GetTagsArray())
|
||||
{
|
||||
if (sb.Length > 0) { sb.Append(","); }
|
||||
sb.Append(s);
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public virtual string[] GetTagsArray()
|
||||
{
|
||||
return Tags.GetTagTextFromIDs(TagIDs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class ZeroMethod //: INotifyPropertyChanged
|
||||
{
|
||||
public Test.Module.Channel.Sensor.ZeroMethodType Method { get; set; }
|
||||
|
||||
public double Start { get; set; }
|
||||
|
||||
public double End { get; set; }
|
||||
|
||||
public ZeroMethod(Test.Module.Channel.Sensor.ZeroMethodType zm, double _start, double _end)
|
||||
{
|
||||
Method = zm;
|
||||
Start = _start;
|
||||
End = _end;
|
||||
}
|
||||
public ZeroMethod(string zm)
|
||||
{
|
||||
Initialize(zm, System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
/// <summary>
|
||||
/// do a deep copy
|
||||
/// </summary>
|
||||
/// <param name="copy"></param>
|
||||
public ZeroMethod(ZeroMethod copy)
|
||||
{
|
||||
Method = copy.Method;
|
||||
Start = copy.Start;
|
||||
End = copy.End;
|
||||
}
|
||||
private void Initialize(string zm, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
var tokens = zm.Split(',');
|
||||
if (tokens.Length < 3) { return; }
|
||||
Start = Convert.ToDouble(tokens[1], culture);
|
||||
End = Convert.ToDouble(tokens[2], culture);
|
||||
Method = (Test.Module.Channel.Sensor.ZeroMethodType)
|
||||
Enum.Parse(typeof(Test.Module.Channel.Sensor.ZeroMethodType), tokens[0]);
|
||||
}
|
||||
public string ToDbString()
|
||||
{
|
||||
return string.Format("{0},{1},{2}", Method.ToString(), Start, End);
|
||||
}
|
||||
public string ToSerializeString()
|
||||
{
|
||||
return string.Format("{0},{1},{2}",
|
||||
Method.ToString(),
|
||||
Start.ToString(System.Globalization.CultureInfo.InvariantCulture),
|
||||
End.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user