using System.Collections.Generic;
public static void Main(string[] args)
FuncCommand cmd = new FuncCommand(@"1|1|0|主缸進水|FILL|2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,65535,0,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|進水水位,進水閥號,,,,,,,,,,,,,,,,,,|LEVEL,FILL No,,,,,,,,,,,,,,,,,,|升,,,,,,,,,,,,,,,,,,,|L,,,,,,,,,,,,,,,,,,,|1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0");
Console.WriteLine("機型號: {0}", cmd.MachineType);
Console.WriteLine("編號: {0:000}", cmd.Code);
Console.WriteLine("組別號: {0:000}", cmd.Group);
Console.WriteLine("中文名稱: {0}", cmd.NameCn);
Console.WriteLine("英文名稱: {0}", cmd.Name);
if (cmd.Parameters.Count > 0 )
Console.WriteLine("功能參數列表:");
Console.WriteLine("{0,-4}{1,-10}{2,-10}{3,-5}{4,-5}{5,-10}{6,-5}{7,-5}{8,-5}{9,-10}{10,-5}{11,-5}", "序", "中文名稱", "英文名稱", "中文單位", "英文單位", "類型", "最小值", "最大值", "標準值", "選表號", "顯示進度", "數據位");
for (int i = 0; i < cmd.Parameters.Count; i++)
Console.WriteLine("{0,-5}{1,-10}{2,-10}{3,-5}{4,-5}{5,-10}{6,-5}{7,-5}{8,-5}{9,-10}{10,-5}{11,-5}"
, cmd.Parameters[i].NameCn
, cmd.Parameters[i].UnitCn
, cmd.Parameters[i].Selection
, cmd.Parameters[i].ShowStatus
, cmd.Parameters[i].DataOffset
Console.WriteLine("實際大小: {0}BYTES", cmd.ActualDataSize);
public class FuncCommandPanel
public static List<FuncCommandPanel> ListFuncCommandPanels = new List<FuncCommandPanel>();
#region Maintain Func Command Panels
public static void RefreshFuncCommandPanels(byte[] bytes, int index)
if (index + bytes.Length < 24) return;
ListFuncCommandPanels.Clear();
while (index + 24 < bytes.Length)
int dataSize = 256 * bytes[index++] + bytes[index++];
Console.WriteLine("Data Size of Panel Read: {0}", dataSize);
FuncCommandPanel p = new FuncCommandPanel(bytes, index);
ListFuncCommandPanels.Add(p);
Console.WriteLine("p.DataSize: {0}", p.DataSize);
Console.WriteLine("End Index: {0}", index);
public static bool PanelsToBytes(byte[] bytes, int index)
int dataSize = DataSizeOfPanels;
if (index + dataSize > bytes.Length) return false;
foreach (FuncCommandPanel panel in ListFuncCommandPanels)
dataSize = panel.DataSize;
bytes[index++] = (byte)((2 + dataSize) / 256);
bytes[index++] = (byte)((2 + dataSize) % 256);
panel.ToBytes(bytes, index);
public static int DataSizeOfPanels
foreach (FuncCommandPanel panel in ListFuncCommandPanels)
dataSize += 2 + panel.DataSize;
public static void TestData()
if (FuncCommand.FuncCommands.Count == 0)
FuncCommand.FuncCommands.Add(
FuncCommand.FuncCommandID(FuncCommand.eMachineType.Liquor, 1)
, new FuncCommand(@"1|1|0|主缸進水|FILL|2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,65535,0,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|進水水位,進水閥號,,,,,,,,,,,,,,,,,,|LEVEL,FILL No,,,,,,,,,,,,,,,,,,|升,,,,,,,,,,,,,,,,,,,|L,,,,,,,,,,,,,,,,,,,|1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0")
FuncCommand.FuncCommands.Add(
FuncCommand.FuncCommandID(FuncCommand.eMachineType.Liquor, 2)
, new FuncCommand(@"1|2|0|主缸排水|DRAIN|2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,65535,0,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|排水水位,排水閥號,,,,,,,,,,,,,,,,,,|LEVEL,DRAIN No,,,,,,,,,,,,,,,,,,|升,,,,,,,,,,,,,,,,,,,|L,,,,,,,,,,,,,,,,,,,|1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0")
if (ListFuncCommandPanels.Count == 0)
ListFuncCommandPanels.Add(new FuncCommandPanel(0));
foreach (KeyValuePair<int, FuncCommand> kvp in FuncCommand.FuncCommands)
FuncCommandButton btn = new FuncCommandButton(FuncCommandButton.FuncCommandButtonID(0, count), kvp.Key);
ListFuncCommandPanels[0].DictPanelButtons.Add(FuncCommandButton.FuncCommandButtonID(0, count), btn);
byte[] bytes = new byte[DataSizeOfPanels];
public Dictionary<int, FuncCommandButton> DictPanelButtons = new Dictionary<int, FuncCommandButton>();
return 1 + 20 + 1 + DictPanelButtons.Count * FuncCommandButton.DATA_SIZE;
public bool ToBytes(byte[] bytes, int index)
if (index + DataSize > bytes.Length) return false;
bytes[index++] = (byte)(PanelNo % 256);
Array.Clear(bytes, index, 20);
int bytesCount = Encoding.Unicode.GetByteCount(Name);
if (bytesCount > 0) Array.Copy(Encoding.Unicode.GetBytes(Name), 0, bytes, index, Math.Min(bytesCount, 20));
bytes[index++] = (byte)(DictPanelButtons.Count % 256);
foreach (KeyValuePair<int, FuncCommandButton> kvp in DictPanelButtons)
kvp.Value.ToBytes(bytes, index); index += FuncCommandButton.DATA_SIZE;
public FuncCommandPanel()
DictPanelButtons = new Dictionary<int, FuncCommandButton>();
public FuncCommandPanel(byte[] bytes, int index)
if (index + 22 > bytes.Length) return;
PanelNo = bytes[index++];
Name = Encoding.Unicode.GetString(bytes, index, 20).Replace("\0", string.Empty) ; index += 20;
int numButtons = bytes[index++];
if (index + numButtons * FuncCommandButton.DATA_SIZE > bytes.Length) return;
for (int i = 0; i < numButtons; i++)
int id = FuncCommandButton.FuncCommandButtonID (bytes[index + 1] , bytes[index + 2]);
DictPanelButtons.Add(id, new FuncCommandButton( bytes, index));
index += FuncCommandButton.DATA_SIZE;
public FuncCommandPanel(int panelID)
Name = string.Format("{0}{1}","PG " , PanelNo);
public class FuncCommandButton
public const int MAX_BUTTONS_PER_PAGE = 64;
public const int NUM_COLS_PER_PAGE = 2;
public static Dictionary<int, FuncCommandButton> FuncCommandButtons = new Dictionary<int, FuncCommandButton>();
public static void TestData()
FuncCommandButtons.Add(1, new FuncCommandButton(1, FuncCommand.eMachineType.Liquor, 1));
FuncCommandButtons.Add(2, new FuncCommandButton(2, FuncCommand.eMachineType.Liquor, 2));
public static int NumOfFuncCommandButtonPages
foreach (KeyValuePair<int, FuncCommandButton> kvp in FuncCommandButtons)
if (kvp.Key > maxID) maxID = kvp.Key;
if (!(maxID > 0)) return 0;
return 1 + (maxID / 100);
#region Maintain Function Command Buttons
public static void RefreshFuncCommandButtons(byte[] bytes, int index)
FuncCommandButtons.Clear();
while (index + FuncCommandButton.DATA_SIZE < bytes.Length)
FuncCommandButton btn = new FuncCommandButton(bytes, index);
index += FuncCommandButton.DATA_SIZE;
if (FuncCommandButtons.ContainsKey(btn.ID)) continue;
FuncCommandButtons.Add(btn.ID, btn);
public static void FuncCommandButtonsToBytes(byte[] bytes, int index)
if (index + FuncCommandButtons.Count * FuncCommandButton.DATA_SIZE > bytes.Length) return;
foreach (KeyValuePair<int, FuncCommandButton> kvp in FuncCommandButtons)
kvp.Value.ToBytes(bytes, index); index += FuncCommandButton.DATA_SIZE;
public static Dictionary<int, FuncCommandButton> RunningFuncCommandButtons = new Dictionary<int, FuncCommandButton>();
#region Methods to refresh Running Function Command Buttons from ARM
public static void RefreshRunningFuncCommandButtons(byte[] bytes, int index)
int numOfRunningButtons = bytes[index++];
if (numOfRunningButtons == 0)
ClearRunningFuncCommandButtons();
if (index + numOfRunningButtons * (FuncCommandButton.DATA_SIZE + FuncCommand.DATA_SIZE_PARAMETERS) > bytes.Length) return;
List<int> buttonsToRemove = new List<int>();
foreach(KeyValuePair<int, FuncCommandButton> kvp in RunningFuncCommandButtons) buttonsToRemove.Add(kvp.Key);
for (int i = 0; i < numOfRunningButtons; i++)
FuncCommandButton btn = new FuncCommandButton(bytes, index);
index += FuncCommandButton.DATA_SIZE;
btn.RefreshParametersStatus(bytes, index); index += FuncCommand.DATA_SIZE_PARAMETERS;
buttonsToRemove.Remove(btn.ID);
if (RunningFuncCommandButtons.ContainsKey(btn.ID))
RunningFuncCommandButtons[btn.ID].Copy(btn);
RunningFuncCommandButtons.Add(btn.ID, btn);
foreach (int id in buttonsToRemove)
RunningFuncCommandButtons.Remove(id);
public static void ClearRunningFuncCommandButtons()
RunningFuncCommandButtons.Clear();
public static int FuncCommandButtonID(int pageID, int buttonNo)
return 100 * pageID + buttonNo;
public static int FuncCommandButtonID2PageID(int id)
public static int FuncCommandButtonID2ButtonNo(int id)
public static readonly int DATA_SIZE = 3 + FuncCommand.DATA_SIZE;
public enum eAction : byte { Stop = 0, Start = 1, EditParameters = 2 };
public enum eState : byte { Off = 0, On = 1 };
public FuncCommand.eMachineType MachineType;
public byte FuncCommandCode;
public int[] ParameterValues;
public int[] ParameterStatus;
return FuncCommand.FuncCommandID(MachineType, FuncCommandCode);
public FuncCommandButton(byte[] bytes, int index)
if (index + DATA_SIZE > bytes.Length) return;
State = (eState)bytes[index++];
ID = FuncCommandButtonID(bytes[index++] ,bytes[index++]);
MachineType = (FuncCommand.eMachineType)bytes[index++];
FuncCommandCode = bytes[index++];
int funcCommandID = FuncCommand.FuncCommandID(MachineType, FuncCommandCode);
if (!FuncCommand.FuncCommands.ContainsKey(funcCommandID)) return;
ParameterValues = new int[FuncCommand.FuncCommands[funcCommandID].Parameters.Count];
ParameterStatus = new int[FuncCommand.FuncCommands[funcCommandID].Parameters.Count];
RefreshParametersValues(bytes, index);
public FuncCommandButton(int id, FuncCommand.eMachineType machineType, byte funcCommandCode)
: this(id, FuncCommand.FuncCommandID(machineType, funcCommandCode))
public FuncCommandButton(int id, int funcCommandID)
if (!FuncCommand.FuncCommands.ContainsKey(funcCommandID)) return;
FuncCommand command = FuncCommand.FuncCommands[funcCommandID];
MachineType = FuncCommand.FuncCommandID2MachineType(funcCommandID);
FuncCommandCode = FuncCommand.FuncCommandID2FuncCommandCode(funcCommandID);
ParameterValues = new int[command.Parameters.Count];
ParameterStatus = new int[command.Parameters.Count];
for (int i = 0; i < command.Parameters.Count; i++)
ParameterValues[i] = command.Parameters[i].Std;
public FuncCommandButton()
MachineType = FuncCommand.eMachineType.Any;
ParameterValues = new int[] { };
ParameterStatus = new int[] { };
public void Copy(FuncCommandButton btn)
this.MachineType = btn.MachineType;
this.FuncCommandCode = btn.FuncCommandCode;
Array.Copy(btn.ParameterValues, this.ParameterValues, Math.Min(btn.ParameterValues.Length, this.ParameterValues.Length));
Array.Copy(btn.ParameterStatus, this.ParameterStatus, Math.Min(btn.ParameterStatus.Length, this.ParameterStatus.Length));
public void RefreshParametersValues(byte[] bytes, int index)
if (index + FuncCommand.DATA_SIZE_PARAMETERS > bytes.Length) return;
int funcCommandID = FuncCommand.FuncCommandID(MachineType, FuncCommandCode);
if (!FuncCommand.FuncCommands.ContainsKey(funcCommandID)) return;
FuncCommand command = FuncCommand.FuncCommands[funcCommandID];
byte[] bytes4 = new byte[4];
for (int i = 0; i < command.Parameters.Count; i++)
if (i > ParameterValues.Length - 1) break;
switch (command.Parameters[i].DataSize)
bytes4[0] = bytes[index + command.Parameters[i].DataOffset + 3];
bytes4[1] = bytes[index + command.Parameters[i].DataOffset + 2];
bytes4[2] = bytes[index + command.Parameters[i].DataOffset + 1];
bytes4[3] = bytes[index + command.Parameters[i].DataOffset];
ParameterValues[i] = (int)BitConverter.ToUInt32(bytes4, 0);
ParameterValues[i] = 256 * bytes[index + command.Parameters[i].DataOffset] + bytes[index + command.Parameters[i].DataOffset + 1];
ParameterValues[i] = bytes[index + command.Parameters[i].DataOffset];
public void RefreshParametersStatus(byte[] bytes, int index)
if (index + FuncCommand.DATA_SIZE_PARAMETERS > bytes.Length) return;
int funcCommandID = FuncCommand.FuncCommandID(MachineType, FuncCommandCode);
if (!FuncCommand.FuncCommands.ContainsKey(funcCommandID)) return;
FuncCommand command = FuncCommand.FuncCommands[funcCommandID];
byte[] bytes4 = new byte[4];
for (int i = 0; i < command.Parameters.Count; i++)
if (i > ParameterStatus.Length - 1) break;
switch (command.Parameters[i].DataSize)
bytes4[0] = bytes[index + command.Parameters[i].DataOffset + 3];
bytes4[1] = bytes[index + command.Parameters[i].DataOffset + 2];
bytes4[2] = bytes[index + command.Parameters[i].DataOffset + 1];
bytes4[3] = bytes[index + command.Parameters[i].DataOffset ];
ParameterStatus[i] = (int)BitConverter.ToUInt32(bytes4, 0);
ParameterStatus[i] = 256 * bytes[index + command.Parameters[i].DataOffset] + bytes[index + command.Parameters[i].DataOffset + 1];
ParameterValues[i] = bytes[index + command.Parameters[i].DataOffset];
public void ToBytes(byte[] bytes, int index)
if (index + DATA_SIZE > bytes.Length) return;
int funcCommandID = FuncCommand.FuncCommandID(MachineType, FuncCommandCode);
if (!FuncCommand.FuncCommands.ContainsKey(funcCommandID)) return;
bytes[index++] = (byte)State;
bytes[index++] = (byte)(ID / 256);
bytes[index++] = (byte)(ID % 256);
bytes[index++] = (byte)MachineType;
bytes[index++] = (byte)FuncCommandCode;
FuncCommand command = FuncCommand.FuncCommands[funcCommandID];
byte[] bytes4 = new byte[4];
for (int i = 0; i < command.Parameters.Count; i++)
if (i > ParameterValues.Length - 1) break;
switch (command.Parameters[i].DataSize)
bytes4 = BitConverter.GetBytes((UInt32)ParameterValues[i]);
bytes[index + command.Parameters[i].DataOffset + 3] = bytes4[0];
bytes[index + command.Parameters[i].DataOffset + 2] = bytes4[1];
bytes[index + command.Parameters[i].DataOffset + 1] = bytes4[2];
bytes[index + command.Parameters[i].DataOffset] = bytes4[3];
bytes[index + command.Parameters[i].DataOffset] = (byte)(ParameterValues[i] / 256);
bytes[index + command.Parameters[i].DataOffset + 1] = (byte)(ParameterValues[i] % 256);
bytes[index + command.Parameters[i].DataOffset] = (byte)(ParameterValues[i] % 256);
public byte[] BytesAction(eAction action)
byte[] bytes = new byte[DATA_SIZE];
bytes[index++] = (byte)action;
bytes[index++] = (byte)(ID / 256);
bytes[index++] = (byte)(ID % 256);
bytes[index++] = (byte)MachineType;
bytes[index++] = (byte)FuncCommandCode;
int funcCommandID = FuncCommand.FuncCommandID(MachineType, FuncCommandCode);
if (!FuncCommand.FuncCommands.ContainsKey(funcCommandID)) return bytes;
FuncCommand command = FuncCommand.FuncCommands[funcCommandID];
for (int i = 0; i < command.Parameters.Count; i++)
if (i > ParameterValues.Length - 1) break;
switch (command.Parameters[i].DataSize)
byte[] bytes4 = BitConverter.GetBytes((UInt32)ParameterValues[i]);
bytes[index + command.Parameters[i].DataOffset + 3] = bytes4[0];
bytes[index + command.Parameters[i].DataOffset + 2] = bytes4[1];
bytes[index + command.Parameters[i].DataOffset + 1] = bytes4[2];
bytes[index + command.Parameters[i].DataOffset] = bytes4[3];
bytes[index + command.Parameters[i].DataOffset] = (byte)(ParameterValues[i] / 256);
bytes[index + command.Parameters[i].DataOffset + 1] = (byte)(ParameterValues[i] % 256);
bytes[index + command.Parameters[i].DataOffset] = (byte)(ParameterValues[i] % 256);
public static Dictionary<int, FuncCommand> FuncCommands = new Dictionary<int, FuncCommand>();
public static void TestData()
FuncCommand.FuncCommandID(eMachineType.Liquor, 1)
, new FuncCommand(@"1|1|0|主缸進水|FILL|2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,65535,0,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|進水水位,進水閥號,,,,,,,,,,,,,,,,,,|LEVEL,FILL No,,,,,,,,,,,,,,,,,,|升,,,,,,,,,,,,,,,,,,,|L,,,,,,,,,,,,,,,,,,,|1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0")
FuncCommand.FuncCommandID(eMachineType.Liquor, 2)
, new FuncCommand(@"1|2|0|主缸排水|DRAIN|2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,65535,0,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|排水水位,排水閥號,,,,,,,,,,,,,,,,,,|LEVEL,DRAIN No,,,,,,,,,,,,,,,,,,|升,,,,,,,,,,,,,,,,,,,|L,,,,,,,,,,,,,,,,,,,|1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0")
public static int FuncCommandID(eMachineType machineType, byte funcCommandCode)
return 256 * (byte)machineType + funcCommandCode;
public static eMachineType FuncCommandID2MachineType(int id)
return (eMachineType)((byte)(id / 256));
public static byte FuncCommandID2FuncCommandCode(int id)
public enum eMachineType : byte { Any = 0, Liquor = 1, Air = 2, Bobbin = 3 };
public const int DATA_SIZE_PARAMETERS = 20;
public static readonly int DATA_SIZE = 2 + DATA_SIZE_PARAMETERS;
public const int MAX_PARAMETERS = 20;
private static readonly char[] colSep = new char[] { '|' };
private static readonly char[] paramSep = new char[] { ',' };
public eMachineType MachineType;
public List<FuncParameter> Parameters;
private int actualDataSize;
public int ActualDataSize
MachineType = eMachineType.Any; Code = 0; Group = 0; NameCn = string.Empty; Name = string.Empty; Parameters = new List<FuncParameter>(); actualDataSize = 0;
public FuncCommand(string def)
string[] cols = def.Split(colSep);
if (cols.Length < 14) return;
MachineType = eMachineType.Bobbin;
MachineType = eMachineType.Air;
MachineType = eMachineType.Liquor;
MachineType = eMachineType.Any;
Code = byte.Parse(cols[index++]);
Group = byte.Parse(cols[index++]);
string[] paramTypeCols = cols[index++].Split(paramSep);
string[] paramValueRangeCols = cols[index++].Split(paramSep);
string[] paramStdCols = cols[index++].Split(paramSep);
string[] paramSelectionCols = cols[index++].Split(paramSep);
string[] paramNameCnCols = cols[index++].Split(paramSep);
string[] paramNameCols = cols[index++].Split(paramSep);
string[] paramUnitCnCols = cols[index++].Split(paramSep);
string[] paramUnitCols = cols[index++].Split(paramSep);
string[] paramShowStatusCols = cols[index++].Split(paramSep);
if (paramTypeCols.Length < MAX_PARAMETERS) return;
if (paramValueRangeCols.Length < 2 * MAX_PARAMETERS) return;
if (paramStdCols.Length < MAX_PARAMETERS) return;
if (paramSelectionCols.Length < MAX_PARAMETERS) return;
if (paramNameCnCols.Length < MAX_PARAMETERS) return;
if (paramNameCols.Length < MAX_PARAMETERS) return;
if (paramUnitCnCols.Length < MAX_PARAMETERS) return;
if (paramUnitCols.Length < MAX_PARAMETERS) return;
if (paramShowStatusCols.Length < MAX_PARAMETERS) return;
for (int i = 0; i < MAX_PARAMETERS; i++)
if (paramTypeCols[i] == "0" && paramValueRangeCols[2 * i + 1] == "0") continue;
if (paramTypeCols[i] == "0")
actualDataSize += FuncParameter.MaxToDataSize(paramValueRangeCols[2 * i + 1]);
FuncParameter.eType paramType = FuncParameter.eType.Unknown;
switch (paramTypeCols[i])
paramType = FuncParameter.eType.Bits;
paramType = FuncParameter.eType.Float;
paramType = FuncParameter.eType.Integer;
FuncParameter.eSelection paramSelection = FuncParameter.eSelection.Unknown;
switch (paramSelectionCols[i])
paramSelection = FuncParameter.eSelection.OnOff;
paramSelection = FuncParameter.eSelection.Prompt;
paramSelection = FuncParameter.eSelection.DosingCurve;
paramSelection = FuncParameter.eSelection.LevelFormula;
paramter = new FuncParameter(paramType, int.Parse(paramValueRangeCols[2 * i]), int.Parse(paramValueRangeCols[2 * i + 1]), int.Parse(paramStdCols[i]), actualDataSize, paramSelection, paramNameCnCols[i], paramNameCols[i], paramUnitCnCols[i], paramUnitCols[i], paramShowStatusCols[i] == "1");
Parameters.Add(paramter);
actualDataSize += paramter.DataSize;
public class FuncParameter
public enum eType : int { Unknown, Integer, Float, Bits };
public enum eSelection : int { Unknown, OnOff, Prompt, DosingCurve, LevelFormula };
public eSelection Selection;
private int dataSize = -1;
private string format = string.Empty;
public FuncParameter(eType type, int min, int max, int std, int dataOffset, eSelection selection, string nameCn, string name, string unitCn, string unit, bool showStatus)
Type = type; Min = min; Max = max; Std = std; DataOffset = dataOffset; Selection = selection; NameCn = nameCn; Name = name; UnitCn = unitCn; Unit = unit; ShowStatus = showStatus;
public static int MaxToDataSize(string max)
if (format == string.Empty)
format = string.Format("0:{0}", "0".PadLeft((int)Math.Floor(Math.Log10(Max) + 1), '0'));