[성현모] CPXV2 Init
This commit is contained in:
155
SystemX.Net.CP.Platform/SystemX.Net.Platform/SystemX.Net/Base.cs
Normal file
155
SystemX.Net.CP.Platform/SystemX.Net.Platform/SystemX.Net/Base.cs
Normal file
@ -0,0 +1,155 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SystemX.Net
|
||||
{
|
||||
public static class Base
|
||||
{
|
||||
public static bool CheckPath(string strPath)
|
||||
{
|
||||
Regex r = new Regex(@"^(([a-zA-Z]\:)|(\\))(\\{1}|((\\{1})[^\\]([^/:*?<>""|]*))+)$");
|
||||
return r.IsMatch(strPath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Table Info(Serializatiopn) object.
|
||||
[Serializable]
|
||||
public class XTable
|
||||
{
|
||||
public string tableName;
|
||||
|
||||
public List<int> lstIndex;
|
||||
public List<string> lstName;
|
||||
public List<Type> lstType;
|
||||
public List<int> lstCharSize;
|
||||
public List<bool> lstNullAble;
|
||||
|
||||
public XTable(string fName)
|
||||
{
|
||||
this.tableName = fName;
|
||||
|
||||
lstIndex = new List<int>();
|
||||
lstName = new List<string>();
|
||||
lstType = new List<Type>();
|
||||
lstCharSize = new List<int>();
|
||||
lstNullAble = new List<bool>();
|
||||
}
|
||||
public void XTableAdd(int iIndex, string strName, Type SetType, int iCharSize, bool bNullable)
|
||||
{
|
||||
lstIndex.Add(iIndex);
|
||||
lstName.Add(strName);
|
||||
lstType.Add(SetType);
|
||||
lstCharSize.Add(iCharSize);
|
||||
lstNullAble.Add(bNullable);
|
||||
}
|
||||
}
|
||||
public enum eLogDataType
|
||||
{
|
||||
None = -1,
|
||||
|
||||
//CpLog
|
||||
Normal = 0,
|
||||
|
||||
//Leak
|
||||
CSV_Type0 = 1,
|
||||
|
||||
//Laser Trimming Vision
|
||||
CSV_Type1 = 2,
|
||||
|
||||
//Pin Vision
|
||||
CSV_Type2 = 3
|
||||
}
|
||||
public enum eLogAccessType
|
||||
{
|
||||
None = -1,
|
||||
|
||||
//File
|
||||
FileData = 0,
|
||||
|
||||
//VarBinary
|
||||
VarBinaryData = 1,
|
||||
}
|
||||
|
||||
// implements IEnumerable so that it can be used
|
||||
[Serializable]
|
||||
public class XTableInfo : IEnumerable
|
||||
{
|
||||
public XTable[] _table;
|
||||
public XTableInfo(XTable[] pArrayTable)
|
||||
{
|
||||
_table = new XTable[pArrayTable.Length];
|
||||
|
||||
for (int i = 0; i < pArrayTable.Length; i++)
|
||||
{
|
||||
_table[i] = pArrayTable[i];
|
||||
}
|
||||
}
|
||||
|
||||
// Implementation for the GetEnumerator method.
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return (IEnumerator)GetEnumerator();
|
||||
}
|
||||
|
||||
public TableEnum GetEnumerator()
|
||||
{
|
||||
return new TableEnum(_table);
|
||||
}
|
||||
}
|
||||
|
||||
//implement IEnumerable, implement IEnumerator.
|
||||
[Serializable]
|
||||
public class TableEnum : IEnumerator
|
||||
{
|
||||
public XTable[] _table;
|
||||
|
||||
// Enumerators are positioned before the first element
|
||||
// until the first MoveNext() call.
|
||||
int position = -1;
|
||||
|
||||
public TableEnum(XTable[] list)
|
||||
{
|
||||
_table = list;
|
||||
}
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
position++;
|
||||
return (position < _table.Length);
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
position = -1;
|
||||
}
|
||||
|
||||
object IEnumerator.Current
|
||||
{
|
||||
get
|
||||
{
|
||||
return Current;
|
||||
}
|
||||
}
|
||||
|
||||
public XTable Current
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
return _table[position];
|
||||
}
|
||||
catch (IndexOutOfRangeException)
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SystemX.Common;
|
||||
using SystemX.Net.BaseProtocol;
|
||||
|
||||
namespace SystemX.Net
|
||||
{
|
||||
}
|
||||
551
SystemX.Net.CP.Platform/SystemX.Net.Platform/SystemX.Net/Info.cs
Normal file
551
SystemX.Net.CP.Platform/SystemX.Net.Platform/SystemX.Net/Info.cs
Normal file
@ -0,0 +1,551 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using SystemX.Net.BaseProtocol;
|
||||
|
||||
namespace SystemX.Net
|
||||
{
|
||||
/// <summary>
|
||||
/// Num, Command Port, Stream Port, Use, ProcessCode, TestID, ProcessName, PLCCOnfilgFileName, PLCUseType
|
||||
/// </summary>
|
||||
//using PLC_DEVICE_BASE_CONFIG = Tuple<int, int, int, bool, int, string, string, Tuple<string, string>>;
|
||||
|
||||
using static SystemX.Net.Platform.Common.Util.LogMessage;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class PLCDeviceBaseConfig {
|
||||
public int nNum;
|
||||
public int nCommandPort;
|
||||
public int nStreamPort;
|
||||
public bool bUse;
|
||||
public int nProcessCode;
|
||||
public string strTestID;
|
||||
public string strProcessName;
|
||||
public string strPLCCOnfilgFileName;
|
||||
public string strPLCUseType;
|
||||
}
|
||||
|
||||
public class ServerInfo {
|
||||
public bool READ_INFO_STATE { set; get; }
|
||||
|
||||
private string strInfoFilePos;
|
||||
|
||||
private int MAX_PROCESS_NUM;
|
||||
|
||||
public string SERVER_IP;
|
||||
public bool LOOP_BACK;
|
||||
|
||||
public string TITLE;
|
||||
|
||||
public int[] nListenCommandPort;
|
||||
public int[] nListenStreamPort;
|
||||
|
||||
public int nListenCommandPortNum;
|
||||
public int nListenCommandStartPort;
|
||||
public int nListenCommandEndPort;
|
||||
|
||||
public int nListenStreamPortNum;
|
||||
public int nListenStreamStartPort;
|
||||
public int nListenStreamEndPort;
|
||||
|
||||
public int nDistributionCommandPortNum;
|
||||
public int nDistributionCommandStartPort;
|
||||
public int nDistributionCommandEndPort;
|
||||
|
||||
public int nDistributionStreamPortNum;
|
||||
public int nDistributionStreamStartPort;
|
||||
public int nDistributionStreamEndPort;
|
||||
|
||||
public bool USE_HOST_INFO;
|
||||
public string HOST_TABLE_NAME;
|
||||
public string USER_TABLE_NAME;
|
||||
|
||||
public string DISK_MONITOR_POS1;
|
||||
public string DISK_MONITOR_POS2;
|
||||
|
||||
public string SERVER_SAVE_POS;
|
||||
public string MES_SAVE_POS;
|
||||
|
||||
public string SyncTimeServerAddress;
|
||||
public int SyncTimeServerPort;
|
||||
public int TimeServerSyncTimeHour;
|
||||
public int TimeServerSyncTimeMinute;
|
||||
public int TimeServerSyncTimeSecond;
|
||||
|
||||
public ServerInfo(string strGetInfoPath, int iMaxProcessNum)
|
||||
{
|
||||
strInfoFilePos = strGetInfoPath;
|
||||
|
||||
MAX_PROCESS_NUM = iMaxProcessNum;
|
||||
}
|
||||
public bool Load()
|
||||
{
|
||||
READ_INFO_STATE = true;
|
||||
|
||||
try
|
||||
{
|
||||
XDocument xDoc = XDocument.Load(strInfoFilePos);
|
||||
var xElement = xDoc.Element("ROOT");
|
||||
|
||||
int iPort = 0;
|
||||
if (xElement != null)
|
||||
{
|
||||
var xGetElement = xElement.Element("Configure");
|
||||
|
||||
SERVER_IP = xGetElement.Element("UseIP").Value;
|
||||
iPort = Convert.ToInt32((xGetElement.Element("Port").Value.IndexOf("-") >= 0) ? "0" : xGetElement.Element("Port").Value);
|
||||
LOOP_BACK = Convert.ToBoolean(xGetElement.Element("Loopback").Value);
|
||||
|
||||
TITLE = xGetElement.Element("Title").Value;
|
||||
|
||||
nListenCommandStartPort = Convert.ToInt32(xGetElement.Element("ListenCommandPort").Attribute("Start").Value);
|
||||
nListenCommandEndPort = Convert.ToInt32(xGetElement.Element("ListenCommandPort").Attribute("End").Value);
|
||||
|
||||
nListenCommandPortNum = nListenCommandEndPort - nListenCommandStartPort;
|
||||
|
||||
nListenStreamStartPort = Convert.ToInt32(xGetElement.Element("ListenStreamPort").Attribute("Start").Value);
|
||||
nListenStreamEndPort = Convert.ToInt32(xGetElement.Element("ListenStreamPort").Attribute("End").Value);
|
||||
|
||||
nListenStreamPortNum = nListenStreamEndPort - nListenStreamStartPort;
|
||||
|
||||
nListenCommandPort = new int[nListenCommandPortNum];
|
||||
nListenStreamPort = new int[nListenStreamPortNum];
|
||||
|
||||
for (int i = 0; i < nListenCommandPortNum; i++)
|
||||
nListenCommandPort[i] = nListenCommandStartPort + i;
|
||||
|
||||
for (int i = 0; i < nListenStreamPortNum; i++)
|
||||
nListenStreamPort[i] = nListenStreamStartPort + i;
|
||||
|
||||
nDistributionCommandStartPort = Convert.ToInt32(xGetElement.Element("DistributionCommandPort").Attribute("Start").Value);
|
||||
nDistributionCommandEndPort = Convert.ToInt32(xGetElement.Element("DistributionCommandPort").Attribute("End").Value);
|
||||
|
||||
nDistributionCommandPortNum = nDistributionCommandEndPort - nDistributionCommandStartPort;
|
||||
|
||||
nDistributionStreamStartPort = Convert.ToInt32(xGetElement.Element("DistributionStreamPort").Attribute("Start").Value);
|
||||
nDistributionStreamEndPort = Convert.ToInt32(xGetElement.Element("DistributionStreamPort").Attribute("End").Value);
|
||||
|
||||
nDistributionStreamPortNum = nDistributionStreamEndPort - nDistributionStreamStartPort;
|
||||
|
||||
SERVER_SAVE_POS = @xGetElement.Element("LogFileSavePos").Value;
|
||||
MES_SAVE_POS = @xGetElement.Element("MESFileSavePos").Value;
|
||||
|
||||
USE_HOST_INFO = Convert.ToBoolean(xGetElement.Element("UseHostInfo").Value);
|
||||
HOST_TABLE_NAME = @xGetElement.Element("HostInfoTableName").Value;
|
||||
USER_TABLE_NAME = @xGetElement.Element("UserInfoTableName").Value;
|
||||
|
||||
DISK_MONITOR_POS1 = xGetElement.Element("DiskMonitor1").Value;
|
||||
DISK_MONITOR_POS2 = xGetElement.Element("DiskMonitor2").Value;
|
||||
|
||||
if (DISK_MONITOR_POS1.Length <= 0)
|
||||
DISK_MONITOR_POS1 = @"C:\";
|
||||
if (DISK_MONITOR_POS2.Length <= 0)
|
||||
DISK_MONITOR_POS2 = @"D:\";
|
||||
|
||||
SyncTimeServerAddress = xGetElement.Element("SyncTimeServerAddress").Attribute("Address").Value;
|
||||
|
||||
SyncTimeServerPort = int.MinValue;
|
||||
|
||||
if (int.TryParse(xGetElement.Element("SyncTimePort").Attribute("Port").Value, out SyncTimeServerPort) == false)
|
||||
SyncTimeServerPort = int.MinValue;
|
||||
|
||||
TimeServerSyncTimeHour = 24;
|
||||
TimeServerSyncTimeMinute = 0;
|
||||
TimeServerSyncTimeSecond = 0;
|
||||
|
||||
if (int.TryParse(xGetElement.Element("TimeServer-SyncTime").Attribute("H").Value, out TimeServerSyncTimeHour) == false)
|
||||
TimeServerSyncTimeHour = 24;
|
||||
if (int.TryParse(xGetElement.Element("TimeServer-SyncTime").Attribute("M").Value, out TimeServerSyncTimeMinute) == false)
|
||||
TimeServerSyncTimeMinute = 0;
|
||||
if (int.TryParse(xGetElement.Element("TimeServer-SyncTime").Attribute("S").Value, out TimeServerSyncTimeSecond) == false)
|
||||
TimeServerSyncTimeSecond = 0;
|
||||
|
||||
if (Base.CheckPath(SERVER_SAVE_POS)) {
|
||||
if (Directory.Exists(SERVER_SAVE_POS) == false)
|
||||
Directory.CreateDirectory(SERVER_SAVE_POS);
|
||||
}
|
||||
else {
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"ServerInfo read failed.(SERVER SAVE POS - Folder name error)[SystemX.Common : SystemX.Net.ServerInfo]", ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
if (Base.CheckPath(MES_SAVE_POS)) {
|
||||
if (Directory.Exists(MES_SAVE_POS) == false) {
|
||||
Directory.CreateDirectory(MES_SAVE_POS);
|
||||
|
||||
/*MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"ServerInfo read failed.(MES SAVE POS - Folder exist error)[SystemX.Common : SystemX.Net.ServerInfo]", ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
|
||||
throw new Exception();*/
|
||||
}
|
||||
}
|
||||
else {
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"ServerInfo read failed.(MES SAVE POS - Folder name error)[SystemX.Common : SystemX.Net.ServerInfo]", ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
READ_INFO_STATE = false;
|
||||
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"ServerInfo read failed.[SystemX.Common : SystemX.Net.ServerInfo]\r\n" + e.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
|
||||
return READ_INFO_STATE;
|
||||
}
|
||||
}
|
||||
|
||||
public class MapLogOption
|
||||
{
|
||||
public bool bReadInfoState { set; get; }
|
||||
|
||||
private string strInfoFilePos;
|
||||
|
||||
public bool bUseMapLog;
|
||||
public string strMapLogEnterMutexName;
|
||||
public string strMapLogAccessMutexName;
|
||||
public string strMapLogPath;
|
||||
public string strMapLogFileName;
|
||||
public string strMapLogName;
|
||||
|
||||
public string strMapInfoLogEnterMutexName;
|
||||
public string strMapInfoLogAccessMutexName;
|
||||
public string strMapInfoLogPath;
|
||||
public string strMapInfoLogFileName;
|
||||
public string strMapInfoLogName;
|
||||
|
||||
public MapLogOption(string strGetInfoPath)
|
||||
{
|
||||
strInfoFilePos = strGetInfoPath;
|
||||
}
|
||||
public bool Load()
|
||||
{
|
||||
bReadInfoState = true;
|
||||
|
||||
try
|
||||
{
|
||||
XDocument xDoc = XDocument.Load(strInfoFilePos);
|
||||
var xElement = xDoc.Element("ROOT");
|
||||
|
||||
if (xElement != null)
|
||||
{
|
||||
var xGetElement = xElement.Element("Configure");
|
||||
|
||||
XElement xEle = xGetElement.Element("UseMapLog");
|
||||
|
||||
if (xEle?.IsEmpty == false)
|
||||
bUseMapLog = Convert.ToBoolean(xGetElement.Element("UseMapLog").Value);
|
||||
else
|
||||
bUseMapLog = false;
|
||||
|
||||
strMapLogEnterMutexName = xGetElement.Element("MapLogEnterMutexName").Value;
|
||||
strMapLogAccessMutexName = xGetElement.Element("MapLogAccessMutexName").Value;
|
||||
strMapLogPath = @xGetElement.Element("MapLogFilePath").Value;
|
||||
strMapLogFileName = xGetElement.Element("MapLogFileName").Value;
|
||||
strMapLogName = xGetElement.Element("MapLogName").Value;
|
||||
|
||||
strMapInfoLogEnterMutexName = xGetElement.Element("MapInfoLogEnterMutexName").Value;
|
||||
strMapInfoLogAccessMutexName = xGetElement.Element("MapInfoLogAccessMutexName").Value;
|
||||
strMapInfoLogPath = @xGetElement.Element("MapInfoLogFilePath").Value;
|
||||
strMapInfoLogFileName = xGetElement.Element("MapInfoLogFileName").Value;
|
||||
strMapInfoLogName = xGetElement.Element("MapInfoLogName").Value;
|
||||
|
||||
if (Base.CheckPath(strMapLogPath))
|
||||
{
|
||||
if (Directory.Exists(strMapLogPath) == false)
|
||||
Directory.CreateDirectory(strMapLogPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"MapLogOption read failed. (Map Log Path - Folder name error)[SystemX.Common : SystemX.Net.MapLogOption]", ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
if (Base.CheckPath(strMapInfoLogPath))
|
||||
{
|
||||
if (Directory.Exists(strMapInfoLogPath) == false)
|
||||
Directory.CreateDirectory(strMapInfoLogPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"MapLogOption read failed. (Map Info Log Path - Folder name error)[SystemX.Common : SystemX.Net.MapLogOption]", ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
bReadInfoState = false;
|
||||
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"MapLogOption read failed. [SystemX.Common : SystemX.Net.MapLogOption]\r\n" + e.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
|
||||
return bReadInfoState;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PLC Device Base Infomation
|
||||
/// </summary>
|
||||
/// <param name="index"> Num, Port, Use, ProcessCode, TestID, ProcessName, PLCCOnfilgFileName </param>
|
||||
public class PLCBaseInfo {
|
||||
public bool READ_INFO_STATE { set; get; }
|
||||
private string strInfoFilePos;
|
||||
private int MAX_DEVICE_NUM;
|
||||
|
||||
public string SERVER_IP;
|
||||
public bool LOOP_BACK;
|
||||
|
||||
public PLCDeviceBaseConfig[] BaseInfo;
|
||||
|
||||
public PLCBaseInfo(string strGetInfoPath, int iMaxDeviceNum) {
|
||||
strInfoFilePos = strGetInfoPath;
|
||||
|
||||
MAX_DEVICE_NUM = iMaxDeviceNum;
|
||||
|
||||
BaseInfo = new PLCDeviceBaseConfig[MAX_DEVICE_NUM];
|
||||
}
|
||||
public bool Load() {
|
||||
READ_INFO_STATE = true;
|
||||
|
||||
try
|
||||
{
|
||||
XDocument xDoc = XDocument.Load(strInfoFilePos);
|
||||
var xElement = xDoc.Element("ROOT");
|
||||
|
||||
int iPort = 0;
|
||||
if (xElement != null) {
|
||||
var xGetElement = xElement.Element("Configure");
|
||||
|
||||
SERVER_IP = xGetElement.Element("UseIP").Value;
|
||||
LOOP_BACK = Convert.ToBoolean(xGetElement.Element("Loopback").Value);
|
||||
|
||||
var ListGetElement = xElement.Elements("MiddlewareConnect").ToList();
|
||||
|
||||
foreach (var getXElement in ListGetElement) {
|
||||
if (getXElement.Attribute("INFO")?.Value.CompareTo("COMMON") == 0) {
|
||||
for (int i = 0; i < MAX_DEVICE_NUM; i++) {
|
||||
BaseInfo[i] = new PLCDeviceBaseConfig();
|
||||
BaseInfo[i].nNum = i;
|
||||
BaseInfo[i].nCommandPort = Convert.ToInt32(getXElement.Element("Device" + (i + 1).ToString()).Attribute("Command_PortNumber").Value);
|
||||
BaseInfo[i].nStreamPort = Convert.ToInt32(getXElement.Element("Device" + (i + 1).ToString()).Attribute("Stream_PortNumber").Value);
|
||||
BaseInfo[i].bUse = Convert.ToBoolean(getXElement.Element("Device" + (i + 1).ToString()).Attribute("Use").Value);
|
||||
BaseInfo[i].nProcessCode = Convert.ToInt32(getXElement.Element("Device" + (i + 1).ToString()).Attribute("ProcessCode").Value);
|
||||
BaseInfo[i].strTestID = getXElement.Element("Device" + (i + 1).ToString()).Attribute("TestID").Value;
|
||||
BaseInfo[i].strProcessName = getXElement.Element("Device" + (i + 1).ToString()).Attribute("ProcessName").Value;
|
||||
BaseInfo[i].strPLCCOnfilgFileName = getXElement.Element("Device" + (i + 1).ToString()).Attribute("PLCConfigFileName").Value;
|
||||
BaseInfo[i].strPLCUseType = getXElement.Element("Device" + (i + 1).ToString()).Attribute("PLCUseType").Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
READ_INFO_STATE = false;
|
||||
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"PLCBaseInfo read failed.[SystemX.Common : SystemX.Net.PLCBaseInfo]\r\n" + e.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
|
||||
return READ_INFO_STATE;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// PC Client Base Infomation
|
||||
/// </summary>
|
||||
public class ClientInfo {
|
||||
public bool READ_INFO_STATE { set; get; }
|
||||
private string strInfoFilePos;
|
||||
|
||||
public string CONNECT_IP;
|
||||
|
||||
public int COMMAND_PORT;
|
||||
public int STREAM_PORT;
|
||||
|
||||
public bool LOOP_BACK;
|
||||
|
||||
public string HOST_ID;
|
||||
public string SECTION;
|
||||
public string TEST_CODE;
|
||||
|
||||
/* TODO : UIM Mode 및 기존 코드 정리 필요 */
|
||||
//SIMPLE_LOOKUP_OPTION
|
||||
//ISSUE_WORKER_WAIT_TIME_ms
|
||||
//SESSION_TIMEOUT_TIME_S
|
||||
//UIM
|
||||
public bool SIMPLE_LOOKUP_OPTION;
|
||||
public double ISSUE_WORKER_WAIT_TIME_ms;
|
||||
public double SESSION_TIMEOUT_TIME_S;
|
||||
|
||||
//TODO : Client ALIS FTP
|
||||
public bool FTP_Use;
|
||||
|
||||
public string FTP_IPAddress;
|
||||
public string FTP_Port;
|
||||
public string FTP_Account;
|
||||
public string FTP_Password;
|
||||
|
||||
public ClientInfo() {
|
||||
strInfoFilePos = "";
|
||||
}
|
||||
public ClientInfo(string strGetInfoPath) {
|
||||
strInfoFilePos = strGetInfoPath;
|
||||
}
|
||||
public bool Load() {
|
||||
READ_INFO_STATE = true;
|
||||
|
||||
SIMPLE_LOOKUP_OPTION = false;
|
||||
|
||||
ISSUE_WORKER_WAIT_TIME_ms = 3000.0;
|
||||
SESSION_TIMEOUT_TIME_S = 300.0;
|
||||
|
||||
TEST_CODE = string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
XDocument xDoc = XDocument.Load(strInfoFilePos);
|
||||
var xElement = xDoc.Element("ROOT");
|
||||
|
||||
if (xElement != null) {
|
||||
var xGetElement = xElement.Element("Configure");
|
||||
|
||||
CONNECT_IP = xGetElement.Element("UseIP").Value;
|
||||
|
||||
COMMAND_PORT = Convert.ToInt32((xGetElement.Element("CommandPort").Value.IndexOf("-") >= 0) ? "0" : xGetElement.Element("CommandPort").Value);
|
||||
STREAM_PORT = Convert.ToInt32((xGetElement.Element("StreamPort").Value.IndexOf("-") >= 0) ? "0" : xGetElement.Element("StreamPort").Value);
|
||||
|
||||
LOOP_BACK = Convert.ToBoolean(xGetElement.Element("Loopback").Value);
|
||||
|
||||
HOST_ID = @xGetElement.Element("HostID").Value;
|
||||
SECTION = @xGetElement.Element("Section").Value;
|
||||
|
||||
XElement xEle = xGetElement.Element("TestCode");
|
||||
|
||||
if (xEle?.IsEmpty == false)
|
||||
TEST_CODE = @xGetElement.Element("TestCode").Value;
|
||||
|
||||
/*SCAN_LOG_FOLDER = Convert.ToBoolean(xGetElement.Element("LogFileScan").Value);
|
||||
SCAN_LOG_FOLDER_POS = xGetElement.Element("LogFileScanPos").Value;
|
||||
|
||||
if (SCAN_LOG_FOLDER) {
|
||||
if (Base.CheckPath(SCAN_LOG_FOLDER_POS)) {
|
||||
if (Directory.Exists(SCAN_LOG_FOLDER_POS) == false) {
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"ClientInfo read failed.(Scan log folder not exist)[SystemX.Common : SystemX.Net.ClientInfo]", ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
else {
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"ClientInfo read failed.(Scan log folder name error)[SystemX.Common : SystemX.Net.ClientInfo]", ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
|
||||
SCAN_DEVICE_FOLDER = Convert.ToBoolean(xGetElement.Element("DeviceFileScan").Value);
|
||||
SCAN_DEVICE_FOLDER_TYPE = xGetElement.Element("DeviceFileScanType").Value;
|
||||
SCAN_DEVICE_FOLDER_POS = xGetElement.Element("DeviceFileScanPos").Value;
|
||||
|
||||
if (SCAN_DEVICE_FOLDER) {
|
||||
if (Base.CheckPath(SCAN_DEVICE_FOLDER_POS)) {
|
||||
if (Directory.Exists(SCAN_DEVICE_FOLDER_POS) == false) {
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"ClientInfo read failed.(Scan device folder not exist)[SystemX.Common : SystemX.Net.ClientInfo]", ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"ClientInfo read failed.(Scan device folder name error)[SystemX.Common : SystemX.Net.ClientInfo]", ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
|
||||
throw new Exception();
|
||||
}
|
||||
}*/
|
||||
|
||||
xEle = xGetElement.Element("SimpleLookUpOption");
|
||||
|
||||
bool bValue = false;
|
||||
//string strValue;
|
||||
|
||||
if (xEle?.IsEmpty == false) {
|
||||
if (bool.TryParse(xEle.Value, out bValue))
|
||||
SIMPLE_LOOKUP_OPTION = Convert.ToBoolean(xEle.Value);
|
||||
}
|
||||
|
||||
xEle = xGetElement.Element("IssueWorkerWaitTime_ms");
|
||||
|
||||
double dValue = double.NaN;
|
||||
|
||||
if (xEle?.IsEmpty == false) {
|
||||
if(double.TryParse(xEle.Value, out dValue))
|
||||
ISSUE_WORKER_WAIT_TIME_ms = Convert.ToDouble(xEle.Value);
|
||||
}
|
||||
|
||||
xEle = xGetElement.Element("SessionTimeout_s");
|
||||
|
||||
if (xGetElement.Element("SessionTimeout_s")?.IsEmpty == false) {
|
||||
dValue = double.NaN;
|
||||
if (double.TryParse(xEle.Value, out dValue))
|
||||
SESSION_TIMEOUT_TIME_S = Convert.ToDouble(xEle.Value);
|
||||
}
|
||||
|
||||
//TODO : Client ALIS FTP
|
||||
xEle = xGetElement.Element("UseFTP");
|
||||
|
||||
if (xEle?.IsEmpty == false)
|
||||
{
|
||||
if (bool.TryParse(xEle.Value, out bValue))
|
||||
FTP_Use = bValue;
|
||||
}
|
||||
else
|
||||
FTP_Use = false;
|
||||
|
||||
xEle = xGetElement.Element("IPAddressFTP");
|
||||
|
||||
if (xEle?.IsEmpty == false)
|
||||
FTP_IPAddress = xEle.Value;
|
||||
else
|
||||
FTP_IPAddress = "0.0.0.0";
|
||||
|
||||
xEle = xGetElement.Element("PortFTP");
|
||||
|
||||
if (xEle?.IsEmpty == false)
|
||||
FTP_Port = xEle.Value;
|
||||
else
|
||||
FTP_Port = "21";
|
||||
|
||||
xEle = xGetElement.Element("AccountFTP");
|
||||
|
||||
if (xEle?.IsEmpty == false)
|
||||
FTP_Account = xEle.Value;
|
||||
else
|
||||
FTP_Account = "";
|
||||
|
||||
xEle = xGetElement.Element("PasswordFTP");
|
||||
|
||||
if (xEle?.IsEmpty == false)
|
||||
FTP_Password = xEle.Value;
|
||||
else
|
||||
FTP_Password = "";
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
READ_INFO_STATE = false;
|
||||
|
||||
MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @"ClientInfo read failed.[SystemX.Common : SystemX.Net.ClientInfo]\r\n" + e.Message, ConsoleColor.Yellow, LogMessageLevel.DEBUG);
|
||||
}
|
||||
|
||||
return READ_INFO_STATE;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,672 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SystemX.Net.BaseProtocol
|
||||
{
|
||||
[Serializable]
|
||||
public enum PROCESS_TYPE
|
||||
{
|
||||
NONE = -1,
|
||||
SYSTEM = 0,
|
||||
PLC = 1,
|
||||
PC = 2,
|
||||
DEVICE = 3,
|
||||
UIM = 4,
|
||||
UIM_SERVER = 5,
|
||||
PC_PORT_SERVER = 6
|
||||
}
|
||||
|
||||
/*
|
||||
* Adaptor
|
||||
*/
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode), Serializable]
|
||||
public struct STRING_4
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4)]
|
||||
public string Data;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode), Serializable]
|
||||
public struct STRING_8
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 8)]
|
||||
public string Data;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode), Serializable]
|
||||
public struct STRING_16
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
|
||||
public string Data;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode), Serializable]
|
||||
public struct STRING_32
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
|
||||
public string Data;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode), Serializable]
|
||||
public struct STRING_64
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
|
||||
public string Data;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode), Serializable]
|
||||
public struct STRING_128
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
|
||||
public string Data;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode), Serializable]
|
||||
public struct STRING_256
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||
public string Data;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode), Serializable]
|
||||
public struct STRING_512
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 512)]
|
||||
public string Data;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode), Serializable]
|
||||
public struct STRING_1024
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)]
|
||||
public string Data;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode), Serializable]
|
||||
public struct STRING_2048
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 2048)]
|
||||
public string Data;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode), Serializable]
|
||||
public struct STRING_4096
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4096)]
|
||||
public string Data;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------
|
||||
/*
|
||||
* System Query
|
||||
*/
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode), Serializable]
|
||||
public struct QUERY_STRING
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 2048)]
|
||||
public string Data;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1), Serializable]
|
||||
public struct SYSTEMTIME
|
||||
{
|
||||
public short wYear;
|
||||
public short wMonth;
|
||||
public short wDayOfWeek;
|
||||
public short wDay;
|
||||
public short wHour;
|
||||
public short wMinute;
|
||||
public short wSecond;
|
||||
public short wMilliseconds;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------
|
||||
/*
|
||||
* Initialize Comm Body
|
||||
*/
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1), Serializable]
|
||||
public struct COMM_INFO_PACKET
|
||||
{
|
||||
//Use Port Distribution
|
||||
[MarshalAs(UnmanagedType.Bool)]
|
||||
public bool bPortDistribution;
|
||||
|
||||
//COMMAND 포트 번호
|
||||
[MarshalAs(UnmanagedType.U2)]
|
||||
public ushort usPortCommandNumber;
|
||||
|
||||
//STREAM 포트 번호
|
||||
[MarshalAs(UnmanagedType.U2)]
|
||||
public ushort usPortStreamNumber;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_32[] objConnLocalAddress;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_32[] objConnLocalPort;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------
|
||||
/*
|
||||
* Initialize Comm Body
|
||||
*/
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1), Serializable]
|
||||
public struct PING_PACKET
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_8[] objCheckMsg;
|
||||
}
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1), Serializable]
|
||||
public struct TIME_PACKET
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_32[] objMsg;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public SYSTEMTIME[] objTime;
|
||||
}
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1), Serializable]
|
||||
public struct MESSAGE_PACKET
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_512[] objMessage;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1), Serializable]
|
||||
public struct TRANSFER_PACKET
|
||||
{
|
||||
//수신 결과
|
||||
[MarshalAs(UnmanagedType.Bool)]
|
||||
public bool bRecvResult;
|
||||
|
||||
//처리 결과
|
||||
[MarshalAs(UnmanagedType.Bool)]
|
||||
public bool bProcessResult;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
/*
|
||||
* Packet Header
|
||||
*/
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1), Serializable]
|
||||
public struct HEADER_PACKET
|
||||
{
|
||||
[MarshalAs(UnmanagedType.U2)]
|
||||
public ushort usHeader;
|
||||
|
||||
//응답 결과
|
||||
[MarshalAs(UnmanagedType.Bool)]
|
||||
public bool bResponsState;
|
||||
|
||||
//네트워크 번호
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public byte ucNetworkNo;
|
||||
|
||||
//데이터베이스 ID
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public byte ucDatabaseID;
|
||||
|
||||
//테이블 ID
|
||||
[MarshalAs(UnmanagedType.U2)]
|
||||
public ushort usTableID;
|
||||
|
||||
//Pallet Number
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public byte ucPalletNumber;
|
||||
|
||||
//Pallet Index
|
||||
[MarshalAs(UnmanagedType.U2)]
|
||||
public ushort usPalletIndex;
|
||||
|
||||
//해당 헤더 크기
|
||||
[MarshalAs(UnmanagedType.U4)]
|
||||
public uint uiHeaderLength;
|
||||
|
||||
//선택된 바디 패킷 길이
|
||||
[MarshalAs(UnmanagedType.U4)]
|
||||
public uint uiBodyLength;
|
||||
|
||||
//전체 패킷 크기
|
||||
[MarshalAs(UnmanagedType.U4)]
|
||||
public uint uiPacketLength;
|
||||
|
||||
//실제 데이터 크기
|
||||
[MarshalAs(UnmanagedType.U4)]
|
||||
public uint uiDataLength;
|
||||
|
||||
//로그 파일 전송시 이름
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_128[] objOptionName;
|
||||
|
||||
//최종 변환 확장자 명
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_8[] objOptionExtension;
|
||||
|
||||
//연속 패킷(대용량) 현재 번호 Default 0 Else 1 ~
|
||||
[MarshalAs(UnmanagedType.U4)]
|
||||
public uint uiSourDataNum;
|
||||
|
||||
//연속 패킷(대용량) 최종 번호 Default 0 Else 1 ~
|
||||
[MarshalAs(UnmanagedType.U4)]
|
||||
public uint uiDestDataNum;
|
||||
|
||||
//주 명령
|
||||
[MarshalAs(UnmanagedType.U2)]
|
||||
public ushort usCommand;
|
||||
|
||||
//서브 명령
|
||||
[MarshalAs(UnmanagedType.U2)]
|
||||
public ushort usSubCommand;
|
||||
|
||||
//옵션 명령
|
||||
[MarshalAs(UnmanagedType.U4)]
|
||||
public uint uiOptionCommand;
|
||||
|
||||
//다목적 사용 파라미터1
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_64[] objVarParam1;
|
||||
|
||||
//다목적 사용 파라미터2
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_128[] objVarParam2;
|
||||
|
||||
//다목적 사용 파라미터3
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_256[] objVarParam3;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public CP_PACKET[] objCP_Packet;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* CP Info Header
|
||||
*/
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1), Serializable]
|
||||
public struct CP_PACKET
|
||||
{
|
||||
//CP ALIS StationName
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_64[] objStationName;
|
||||
|
||||
//CP ALIS ProdP
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_16[] objProdNo_P;
|
||||
|
||||
//CP ALIS ProdC
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_16[] objProdNo_C;
|
||||
|
||||
//CP ALIS TestType
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_8[] objTestType;
|
||||
|
||||
//CP ALIS TestCode
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_16[] objTestCode;
|
||||
|
||||
//CP ALIS Version
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_4[] objVersion;
|
||||
|
||||
//CP ALIS ProdCode
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_4[] objProdCode;
|
||||
|
||||
//CP ALIS TestListNo
|
||||
[MarshalAs(UnmanagedType.U4)]
|
||||
public uint uiTestListNo;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* PLC Adaptor 지원
|
||||
*/
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1), Serializable]
|
||||
public struct USER_PACKET
|
||||
{
|
||||
//파레트 정보 및 제품 아이디 및 품번
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public PROCESS_PACKET[] objProcessInfo;
|
||||
|
||||
//명령 INSERT, UPDATE, DELETE SELECT 등 현재는 INSERT 만.
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_16[] objTableCommand;
|
||||
|
||||
//테이블 명칭
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_64[] objTableName;
|
||||
|
||||
//컬럼 길이
|
||||
[MarshalAs(UnmanagedType.U4)]
|
||||
public uint uiSubLength;
|
||||
|
||||
//0 부터 해당 컬럼 명
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_512[] objNames;
|
||||
|
||||
//0 부터 해당 컬럼 데이터
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_512[] objDatas;
|
||||
|
||||
//처리 결과
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_16[] objCommandResult;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------
|
||||
/*
|
||||
* SYSTEM 지원
|
||||
*/
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1), Serializable]
|
||||
public struct QUERY_PACKET
|
||||
{
|
||||
//QUERY 문
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public QUERY_STRING[] objQueryText;
|
||||
//다목적 파라미터1
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_64[] objVarParam1;
|
||||
//다목적 파라미터2
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_128[] objVarParam2;
|
||||
//다목적 파라미터3
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_256[] objVarParam3;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------
|
||||
/*
|
||||
* HOST LOGIN
|
||||
*/
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1), Serializable]
|
||||
public struct SYSTEM_HOST_PACKET
|
||||
{
|
||||
//UIM Use
|
||||
[MarshalAs(UnmanagedType.Bool)]
|
||||
public bool bUseUIM;
|
||||
//UIM Use
|
||||
[MarshalAs(UnmanagedType.Bool)]
|
||||
public bool bUseSimpleLookupOption;
|
||||
//HOST ID
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_64[] objHostID;
|
||||
//SECTION
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_64[] objSection;
|
||||
//TEST CODE
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_64[] objTestCode;
|
||||
//MESSAGE
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_512[] objMessage;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------
|
||||
/*
|
||||
* PROCESS QUERY(PC, PLC Adaptor) 지원
|
||||
*/
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1), Serializable]
|
||||
public struct PROCESS_PACKET
|
||||
{
|
||||
//Station ID
|
||||
[MarshalAs(UnmanagedType.U4)]
|
||||
public uint nStationID;
|
||||
|
||||
//ProdC
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_16[] objProdNo_C;
|
||||
|
||||
//TestType
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_8[] objTestType;
|
||||
|
||||
//TestCode
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_16[] objTestCode;
|
||||
|
||||
//FileVersion
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_4[] objTestListFileVersion;
|
||||
|
||||
//ProductionCode
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_4[] objProductionCode;
|
||||
|
||||
//Product ID
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||
public STRING_64[] objProductID;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------
|
||||
public class BASE_PROTOCOL
|
||||
{
|
||||
//BASE PROTOCOL Main Command 0 - Private
|
||||
public enum PROTOCOL_CODE
|
||||
{
|
||||
NONE = -1,
|
||||
//PC Adaptor File Save
|
||||
FILE_TRANSFER = 0,
|
||||
DATASET_TRANSEFER = 1,
|
||||
//Just reply
|
||||
SIMPLE_RESPONSE = 2,
|
||||
//PLC Adaptor
|
||||
ETC = 3,
|
||||
RAW_SIZE = 4,
|
||||
RAW_END = 5,
|
||||
//System Program
|
||||
SYSTEM_QUERY = 6,
|
||||
INITILALIZE_INFO = 7,
|
||||
PROCESS_QUERY = 8,
|
||||
USER_QUERY = 9,
|
||||
TRANSFER_RESULT = 10,
|
||||
|
||||
//Time Server Sync Request
|
||||
SYNC_TIME_SERVER = 128,
|
||||
//Host Info Check
|
||||
HOST_INFO_CHECK = 256,
|
||||
//Middleware send message
|
||||
MIDDLEWARE_MESSAGE = 512,
|
||||
//Ping
|
||||
CONNECT_STATE = 1024
|
||||
}
|
||||
[Flags]
|
||||
public enum OPTION_CODE
|
||||
{
|
||||
NONE = 0x00000000,
|
||||
QUERY_TESTLIST = 0x00000001,
|
||||
GET_ISSUANCE_MACADDRESS = 0x00000002,
|
||||
CHECK_VAILD_TESTLIST = 0x00000004,
|
||||
}
|
||||
public OPTION_CODE GetOptionCode()
|
||||
{
|
||||
return (OPTION_CODE)uiOptionCommand;
|
||||
}
|
||||
public void SetOptionCode(OPTION_CODE SET_OPTION)
|
||||
{
|
||||
uiOptionCommand = (uint)SET_OPTION;
|
||||
}
|
||||
//
|
||||
private ushort usCommand;
|
||||
private ushort usSubCommand;
|
||||
private uint uiOptionCommand;
|
||||
|
||||
public PROTOCOL_CODE GET_CURRENT_PROTOCOL
|
||||
{
|
||||
get { return ProtocolDecoder(); }
|
||||
}
|
||||
public ushort COMMAND
|
||||
{
|
||||
get { return usCommand; }
|
||||
}
|
||||
public ushort SUB_COMMAND
|
||||
{
|
||||
get { return usSubCommand; }
|
||||
}
|
||||
public uint OPTION_COMMAND
|
||||
{
|
||||
get { return uiOptionCommand; }
|
||||
}
|
||||
|
||||
public PROTOCOL_CODE ProtocolDecoder()
|
||||
{
|
||||
PROTOCOL_CODE SET_CODE = new PROTOCOL_CODE();
|
||||
SET_CODE = PROTOCOL_CODE.NONE;
|
||||
|
||||
string TextCode = usCommand.ToString("D3") + "_" + usSubCommand.ToString("D3");
|
||||
|
||||
if (TextCode.CompareTo("000_001") == 0)
|
||||
SET_CODE = PROTOCOL_CODE.FILE_TRANSFER;
|
||||
else if (TextCode.CompareTo("000_002") == 0)
|
||||
SET_CODE = PROTOCOL_CODE.DATASET_TRANSEFER;
|
||||
else if (TextCode.CompareTo("000_003") == 0)
|
||||
SET_CODE = PROTOCOL_CODE.SIMPLE_RESPONSE;
|
||||
else if (TextCode.CompareTo("000_004") == 0)
|
||||
SET_CODE = PROTOCOL_CODE.RAW_SIZE;
|
||||
else if (TextCode.CompareTo("000_005") == 0)
|
||||
SET_CODE = PROTOCOL_CODE.RAW_END;
|
||||
else if (TextCode.CompareTo("000_006") == 0)
|
||||
SET_CODE = PROTOCOL_CODE.SYSTEM_QUERY;
|
||||
else if (TextCode.CompareTo("000_007") == 0)
|
||||
SET_CODE = PROTOCOL_CODE.INITILALIZE_INFO;
|
||||
else if (TextCode.CompareTo("000_009") == 0)
|
||||
SET_CODE = PROTOCOL_CODE.USER_QUERY;
|
||||
else if (TextCode.CompareTo("000_010") == 0)
|
||||
SET_CODE = PROTOCOL_CODE.TRANSFER_RESULT;
|
||||
|
||||
else if (TextCode.CompareTo("001_000") == 0)
|
||||
SET_CODE = PROTOCOL_CODE.ETC;
|
||||
|
||||
else if (TextCode.CompareTo("002_001") == 0)
|
||||
SET_CODE = PROTOCOL_CODE.PROCESS_QUERY;
|
||||
|
||||
else if (TextCode.CompareTo("999_004") == 0)
|
||||
SET_CODE = PROTOCOL_CODE.SYNC_TIME_SERVER;
|
||||
|
||||
else if (TextCode.CompareTo("999_003") == 0)
|
||||
SET_CODE = PROTOCOL_CODE.HOST_INFO_CHECK;
|
||||
|
||||
else if (TextCode.CompareTo("999_002") == 0)
|
||||
SET_CODE = PROTOCOL_CODE.MIDDLEWARE_MESSAGE;
|
||||
|
||||
else if (TextCode.CompareTo("999_001") == 0)
|
||||
SET_CODE = PROTOCOL_CODE.CONNECT_STATE;
|
||||
|
||||
else
|
||||
SET_CODE = PROTOCOL_CODE.NONE;
|
||||
|
||||
return SET_CODE;
|
||||
}
|
||||
public BASE_PROTOCOL()
|
||||
{
|
||||
}
|
||||
public BASE_PROTOCOL(ushort usGetCommnad, ushort usGetSubCommand, uint uiGetOptionCommand = 0)
|
||||
{
|
||||
usCommand = usGetCommnad;
|
||||
usSubCommand = usGetSubCommand;
|
||||
//
|
||||
uiOptionCommand = uiGetOptionCommand;
|
||||
}
|
||||
/*
|
||||
public void PROTOCOL_CHANGE(PROTOCOL_CODE SET_CODE, OPTION_CODE SET_OPTION = OPTION_CODE.NONE)
|
||||
{
|
||||
new BASE_PROTOCOL(SET_CODE, SET_OPTION);
|
||||
}
|
||||
*/
|
||||
public BASE_PROTOCOL(PROTOCOL_CODE SET_CODE, OPTION_CODE SET_OPTION = OPTION_CODE.NONE)
|
||||
{
|
||||
uiOptionCommand = (uint)SET_OPTION;
|
||||
|
||||
if (SET_CODE == PROTOCOL_CODE.NONE)
|
||||
{
|
||||
usCommand = 0;
|
||||
usSubCommand = 0;
|
||||
}
|
||||
else if (SET_CODE == PROTOCOL_CODE.FILE_TRANSFER)
|
||||
{
|
||||
usCommand = 0;
|
||||
usSubCommand = 1;
|
||||
}
|
||||
else if (SET_CODE == PROTOCOL_CODE.DATASET_TRANSEFER)
|
||||
{
|
||||
usCommand = 0;
|
||||
usSubCommand = 2;
|
||||
}
|
||||
else if (SET_CODE == PROTOCOL_CODE.SIMPLE_RESPONSE)
|
||||
{
|
||||
usCommand = 0;
|
||||
usSubCommand = 3;
|
||||
}
|
||||
else if (SET_CODE == PROTOCOL_CODE.RAW_SIZE)
|
||||
{
|
||||
usCommand = 0;
|
||||
usSubCommand = 4;
|
||||
}
|
||||
else if (SET_CODE == PROTOCOL_CODE.RAW_END)
|
||||
{
|
||||
usCommand = 0;
|
||||
usSubCommand = 5;
|
||||
}
|
||||
else if (SET_CODE == PROTOCOL_CODE.SYSTEM_QUERY)
|
||||
{
|
||||
usCommand = 0;
|
||||
usSubCommand = 6;
|
||||
}
|
||||
else if (SET_CODE == PROTOCOL_CODE.INITILALIZE_INFO)
|
||||
{
|
||||
usCommand = 0;
|
||||
usSubCommand = 7;
|
||||
}
|
||||
else if (SET_CODE == PROTOCOL_CODE.USER_QUERY)
|
||||
{
|
||||
usCommand = 0;
|
||||
usSubCommand = 9;
|
||||
}
|
||||
else if (SET_CODE == PROTOCOL_CODE.TRANSFER_RESULT)
|
||||
{
|
||||
usCommand = 0;
|
||||
usSubCommand = 10;
|
||||
}
|
||||
//
|
||||
else if (SET_CODE == PROTOCOL_CODE.ETC)
|
||||
{
|
||||
usCommand = 1;
|
||||
usSubCommand = 0;
|
||||
}
|
||||
|
||||
else if (SET_CODE == PROTOCOL_CODE.PROCESS_QUERY)
|
||||
{
|
||||
usCommand = 2;
|
||||
usSubCommand = 1;
|
||||
}
|
||||
|
||||
else if (SET_CODE == PROTOCOL_CODE.SYNC_TIME_SERVER)
|
||||
{
|
||||
usCommand = 999;
|
||||
usSubCommand = 4;
|
||||
}
|
||||
|
||||
else if (SET_CODE == PROTOCOL_CODE.HOST_INFO_CHECK)
|
||||
{
|
||||
usCommand = 999;
|
||||
usSubCommand = 3;
|
||||
}
|
||||
|
||||
else if (SET_CODE == PROTOCOL_CODE.MIDDLEWARE_MESSAGE)
|
||||
{
|
||||
usCommand = 999;
|
||||
usSubCommand = 2;
|
||||
}
|
||||
|
||||
else if (SET_CODE == PROTOCOL_CODE.CONNECT_STATE)
|
||||
{
|
||||
usCommand = 999;
|
||||
usSubCommand = 1;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
usCommand = 0;
|
||||
usSubCommand = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user