341 lines
10 KiB
C#
341 lines
10 KiB
C#
//using System;
|
|
//using System.Collections.Generic;
|
|
//using System.ComponentModel;
|
|
//using System.Linq;
|
|
//using System.Text;
|
|
|
|
//namespace COMM
|
|
//{
|
|
// public abstract class VarData<T> : INotifyPropertyChanged
|
|
// {
|
|
// protected T[] _values;
|
|
// protected T defaultvalue;
|
|
// protected string[] _code;
|
|
// protected string[] _desc;
|
|
|
|
// public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
// protected void OnPropertyChanged(string name)
|
|
// {
|
|
// PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
|
// }
|
|
|
|
// public T this[int idx]
|
|
// {
|
|
// get { return Get(idx); }
|
|
// set { Set(idx, value); }
|
|
// }
|
|
|
|
// public string StrType
|
|
// {
|
|
// get
|
|
// {
|
|
// return typeof(T).ToString();
|
|
// }
|
|
// }
|
|
// public VarData(int capa, T defvalue = default(T))
|
|
// {
|
|
// _values = new T[capa];
|
|
// _code = new string[capa];
|
|
// _desc = new string[capa];
|
|
|
|
// defaultvalue = defvalue;
|
|
// Clear();
|
|
|
|
// if (typeof(T) == typeof(UInt16)) SupportAdd = true;
|
|
// else if (typeof(T) == typeof(UInt32)) SupportAdd = true;
|
|
// else if (typeof(T) == typeof(Int16)) SupportAdd = true;
|
|
// else if (typeof(T) == typeof(Int32)) SupportAdd = true;
|
|
// else if (typeof(T) == typeof(Int64)) SupportAdd = true;
|
|
// else if (typeof(T) == typeof(UInt64)) SupportAdd = true;
|
|
// else if (typeof(T) == typeof(byte)) SupportAdd = true;
|
|
// else if (typeof(T) == typeof(double)) SupportAdd = true;
|
|
// else if (typeof(T) == typeof(Single)) SupportAdd = true;
|
|
// else if (typeof(T) == typeof(string)) SupportAdd = false;
|
|
// else if (typeof(T) == typeof(bool)) SupportAdd = false;
|
|
// else if (typeof(T) == typeof(DateTime)) SupportAdd = false;
|
|
// else throw new Exception($"Support Data Type : {typeof(T)}");
|
|
// }
|
|
|
|
// public virtual void Set(int idx, T value)
|
|
// {
|
|
// var changed = _values[idx].Equals(value);
|
|
// _values[idx] = value;
|
|
// if (changed) OnPropertyChanged($"{idx}|{value}"); //idx값을 알림한다
|
|
// }
|
|
// public virtual T Get(int idx)
|
|
// {
|
|
// return _values[idx];
|
|
// }
|
|
|
|
// public virtual void Clear(T value)
|
|
// {
|
|
// for (int i = 0; i < _values.Length; i++)
|
|
// _values[i] = value;
|
|
// }
|
|
// public virtual void Clear()
|
|
// {
|
|
// Clear(defaultvalue);
|
|
// }
|
|
// public void Clear(int idx)
|
|
// {
|
|
// _values[idx] = defaultvalue;
|
|
// }
|
|
// public Tuple<string, string> GetCodeDesc(int idx)
|
|
// {
|
|
// return new Tuple<string, string>(_code[idx], _desc[idx]);
|
|
// }
|
|
// public virtual bool SupportAdd { get; private set; }
|
|
// }
|
|
|
|
// public abstract class VarDataNumber<T> : VarData<T>
|
|
// {
|
|
// public VarDataNumber(int capa) : base(capa) { }
|
|
|
|
// public abstract void Add(T value);
|
|
// public abstract void Add(int idx, T value);
|
|
// }
|
|
|
|
// public class VarDataI32 : VarDataNumber<Int32>
|
|
// {
|
|
// public VarDataI32(int capa) : base(capa) { }
|
|
|
|
// public override void Add(Int32 value)
|
|
// {
|
|
// for (int i = 0; i < _values.Length; i++)
|
|
// _values[i] += value;
|
|
// }
|
|
|
|
// public override void Add(int idx, Int32 value)
|
|
// {
|
|
// _values[idx] += value;
|
|
// }
|
|
// public void Add(eVarInt32 idx, Int32 value = 1)
|
|
// {
|
|
// Add((int)idx, value);
|
|
// }
|
|
// public void Clear(eVarInt32 idx)
|
|
// {
|
|
// Clear((int)idx);
|
|
// }
|
|
// public Int32 this[eVarInt32 idx]
|
|
// {
|
|
// get { return Get((int)idx); }
|
|
// set { Set((int)idx, value); }
|
|
// }
|
|
|
|
// }
|
|
// public class VarDataDBL : VarDataNumber<double>
|
|
// {
|
|
// public VarDataDBL(int capa) : base(capa) { }
|
|
|
|
// public override void Add(double value)
|
|
// {
|
|
// for (int i = 0; i < _values.Length; i++)
|
|
// _values[i] += value;
|
|
// }
|
|
|
|
// public override void Add(int idx, double value)
|
|
// {
|
|
// _values[idx] += value;
|
|
// }
|
|
// public void Add(eVarDBL idx, double value = 1)
|
|
// {
|
|
// Add((int)idx, value);
|
|
// }
|
|
// public void Clear(eVarDBL idx)
|
|
// {
|
|
// Clear((int)idx);
|
|
// }
|
|
// public double this[eVarDBL idx]
|
|
// {
|
|
// get { return Get((int)idx); }
|
|
// set { Set((int)idx, value); }
|
|
// }
|
|
// }
|
|
// public class VarDataUI32 : VarDataNumber<UInt32>
|
|
// {
|
|
// public VarDataUI32(int capa) : base(capa) { }
|
|
|
|
// public override void Add(UInt32 value)
|
|
// {
|
|
// for (int i = 0; i < _values.Length; i++)
|
|
// _values[i] += value;
|
|
// }
|
|
|
|
// public override void Add(int idx, UInt32 value)
|
|
// {
|
|
// _values[idx] += value;
|
|
// }
|
|
// public void Add(eVarUInt32 idx, UInt32 value = 1)
|
|
// {
|
|
// Add((int)idx, value);
|
|
// }
|
|
// public void Clear(eVarUInt32 idx)
|
|
// {
|
|
// Clear((int)idx);
|
|
// }
|
|
// public UInt32 this[eVarUInt32 idx]
|
|
// {
|
|
// get { return Get((int)idx); }
|
|
// set { Set((int)idx, value); }
|
|
// }
|
|
// }
|
|
|
|
// public class VarDataByte : VarDataNumber<byte>
|
|
// {
|
|
// public VarDataByte(int capa) : base(capa) { }
|
|
|
|
// public override void Add(byte value)
|
|
// {
|
|
// for (int i = 0; i < _values.Length; i++)
|
|
// _values[i] += value;
|
|
// }
|
|
// public override void Add(int idx, byte value)
|
|
// {
|
|
// _values[idx] += value;
|
|
// }
|
|
// public void Add(eVarByte idx, byte value)
|
|
// {
|
|
// Add((int)idx, value);
|
|
// }
|
|
// public byte this[eVarByte idx]
|
|
// {
|
|
// get
|
|
// {
|
|
// return Get((int)idx);
|
|
// }
|
|
// set
|
|
// {
|
|
// Set((int)idx, value);
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
// public class VarDataBool : VarData<bool>
|
|
// {
|
|
// public VarDataBool(int capa) : base(capa) { }
|
|
|
|
// public bool this[eVarBool idx]
|
|
// {
|
|
// get
|
|
// {
|
|
// return Get(idx);
|
|
// }
|
|
// set
|
|
// {
|
|
// Set(idx, value);
|
|
// }
|
|
// }
|
|
// public bool Get(eVarBool idx)
|
|
// {
|
|
// return Get((int)idx);
|
|
// }
|
|
// public void Set(eVarBool idx, bool value)
|
|
// {
|
|
// Set((int)idx, value);
|
|
// }
|
|
// }
|
|
|
|
// public class VarDataStr : VarData<string>
|
|
// {
|
|
// public VarDataStr(int capa) : base(capa, string.Empty) { }
|
|
// public string Get(eVarString idx)
|
|
// {
|
|
// return Get((int)idx);
|
|
// }
|
|
// public void Set(eVarString idx, string value)
|
|
// {
|
|
// Set((int)idx, value);
|
|
// }
|
|
// public string this[eVarString idx]
|
|
// {
|
|
// get { return Get(idx); }
|
|
// set { Set(idx, value); }
|
|
// }
|
|
// }
|
|
// public class VarDataDateTime : VarData<DateTime>
|
|
// {
|
|
// public VarDataDateTime(int capa) : base(capa, new DateTime(1982, 11, 23)) { }
|
|
|
|
// public DateTime this[eVarTime idx]
|
|
// {
|
|
// get
|
|
// {
|
|
// return Get((int)idx);
|
|
// }
|
|
// set
|
|
// {
|
|
// Set(idx, value);
|
|
// }
|
|
// }
|
|
|
|
// public TimeSpan RUN(int idx)
|
|
// {
|
|
// return DateTime.Now - _values[idx];
|
|
// }
|
|
// public TimeSpan RUN(eVarTime idx)
|
|
// {
|
|
// return RUN((int)idx);
|
|
// }
|
|
// [Browsable(false)]
|
|
// public void Add(int idx, TimeSpan value)
|
|
// {
|
|
// _values[idx] += value;
|
|
// }
|
|
|
|
// public void Add(eVarTime idx, TimeSpan value)
|
|
// {
|
|
// Add((int)idx, value);
|
|
// }
|
|
// /// <summary>
|
|
// /// 지정된 시간으로 업데이트 합니다
|
|
// /// </summary>
|
|
// /// <param name="idx"></param>
|
|
// /// <param name="value"></param>
|
|
// public void Set(eVarTime idx, DateTime value)
|
|
// {
|
|
// Set((int)idx, value);
|
|
// }
|
|
// /// <summary>
|
|
// /// 현재시간으로 업데이트 합니다
|
|
// /// </summary>
|
|
// /// <param name="idx"></param>
|
|
// public void Set(eVarTime idx)
|
|
// {
|
|
// Set(idx, DateTime.Now);
|
|
// }
|
|
// public bool IsSet(eVarTime idx)
|
|
// {
|
|
// return this[idx].Year != 1982;
|
|
// }
|
|
// }
|
|
// //공용변수(시간)
|
|
// public static class VAR
|
|
// {
|
|
// public static VarDataBool BOOL;
|
|
// public static VarDataByte BYTE;
|
|
// public static VarDataStr STR;
|
|
// public static VarDataDateTime TIME;
|
|
// public static VarDataI32 I32;
|
|
// public static VarDataUI32 U32;
|
|
// public static VarDataDBL DBL;
|
|
|
|
// public static bool isInit { get; private set; } = false;
|
|
|
|
// public static void Init(int varlen)
|
|
// {
|
|
// if (isInit) return; //already init
|
|
// //가변 데이트타임변수
|
|
// BOOL = new VarDataBool(varlen);
|
|
// BYTE = new VarDataByte(varlen);
|
|
// STR = new VarDataStr(varlen);
|
|
// TIME = new VarDataDateTime(varlen);
|
|
// I32 = new VarDataI32(varlen);
|
|
// U32 = new VarDataUI32(varlen);
|
|
// DBL = new VarDataDBL(varlen);
|
|
// isInit = true;
|
|
// }
|
|
// }
|
|
//}
|