492 lines
15 KiB
C#
492 lines
15 KiB
C#
using Aurora.Api;
|
|
using AuroraOCT.IPG;
|
|
using Hermes;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Media.Animation;
|
|
using System.Xml;
|
|
|
|
namespace AuroraOCT
|
|
{
|
|
// OCT : Optical coherence tomography, 광간섭단층촬영장비
|
|
public class OCT : Device
|
|
{
|
|
Logger Log = new Logger("OCT");
|
|
|
|
|
|
#region Constructor
|
|
public OCT(string deviceId, bool isSimul)
|
|
{
|
|
_IsSimulBySetting = isSimul;
|
|
DeviceId = deviceId;
|
|
}
|
|
#endregion
|
|
private IOCT _OCT;
|
|
private bool _IsSimulBySetting;
|
|
|
|
public OCTConfig Config { get; set; }
|
|
|
|
|
|
protected override int DoActivate(IDeviceConfig config)
|
|
{
|
|
Config = config as OCTConfig;
|
|
IsSimul = Config.IsSimul || _IsSimulBySetting;
|
|
if (IsSimul) {
|
|
return E1.OK;
|
|
}
|
|
|
|
switch (Config.Type) {
|
|
case eOCTType.IPG_LDD700:
|
|
_OCT = new LDD700(DeviceId, IsSimul);
|
|
break;
|
|
case eOCTType.ETC:
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
if (_OCT == null) {
|
|
return -1;
|
|
}
|
|
|
|
return _OCT.Open(Config);
|
|
}
|
|
|
|
protected override int DoDeactivate()
|
|
{
|
|
if (_OCT != null) {
|
|
_OCT.DisConnect();
|
|
}
|
|
|
|
return E1.OK;
|
|
}
|
|
|
|
public void SaveMetaData(List<string> MetaDataWeldName, List<string> MetaDataWeldType, List<int> MetaDataWeldCoordinateID)
|
|
{
|
|
try {
|
|
var DefaultPath = ConfigurationManager.AppSettings.Get("DATA_PATH");
|
|
string fullPath = Path.Combine(DefaultPath, "_device", "_scanner", "Record", "Metadata");
|
|
string fileName = fullPath + string.Format("\\Metadata_{0}.xml", DateTime.Now.ToString("yyyyMMdd_HHmmss")); ;
|
|
|
|
XmlDocument doc = new XmlDocument();
|
|
|
|
// XML 선언 추가
|
|
XmlDeclaration xmlDeclaration = doc.CreateXmlDeclaration("1.0", "utf-8", null);
|
|
XmlElement root = doc.DocumentElement;
|
|
doc.InsertBefore(xmlDeclaration, root);
|
|
|
|
// 루트 요소 추가
|
|
XmlElement metaData = doc.CreateElement(string.Empty, "MetaData", string.Empty);
|
|
doc.AppendChild(metaData);
|
|
|
|
// FileVersion 요소 추가
|
|
XmlElement fileVersion = doc.CreateElement(string.Empty, "FileVersion", string.Empty);
|
|
fileVersion.InnerText = "1.0";
|
|
metaData.AppendChild(fileVersion);
|
|
|
|
// FileType 요소 추가
|
|
XmlElement fileType = doc.CreateElement(string.Empty, "FileType", string.Empty);
|
|
fileType.InnerText = "Path Metadata";
|
|
metaData.AppendChild(fileType);
|
|
|
|
// ScannerProperties 요소 추가
|
|
XmlElement scannerProperties = doc.CreateElement(string.Empty, "ScannerProperties", string.Empty);
|
|
metaData.AppendChild(scannerProperties);
|
|
|
|
// SN 요소 추가
|
|
XmlElement sn = doc.CreateElement(string.Empty, "SN", string.Empty);
|
|
sn.InnerText = "00000000";
|
|
scannerProperties.AppendChild(sn);
|
|
|
|
// Model 요소 추가
|
|
XmlElement model = doc.CreateElement(string.Empty, "Model", string.Empty);
|
|
model.InnerText = "YLPN-1-200";
|
|
scannerProperties.AppendChild(model);
|
|
|
|
// FocalLength-mm 요소 추가
|
|
XmlElement focalLength = doc.CreateElement(string.Empty, "FocalLength-mm", string.Empty);
|
|
focalLength.InnerText = "254";
|
|
scannerProperties.AppendChild(focalLength);
|
|
|
|
// XFOV-mm 요소 추가
|
|
XmlElement xFov = doc.CreateElement(string.Empty, "XFOV-mm", string.Empty);
|
|
xFov.InnerText = "110";
|
|
scannerProperties.AppendChild(xFov);
|
|
|
|
// YFOV-mm 요소 추가
|
|
XmlElement yFov = doc.CreateElement(string.Empty, "YFOV-mm", string.Empty);
|
|
yFov.InnerText = "110";
|
|
scannerProperties.AppendChild(yFov);
|
|
|
|
// WorkspaceInfo 요소 추가
|
|
XmlElement workspaceInfo = doc.CreateElement(string.Empty, "WorkspaceInfo", string.Empty);
|
|
metaData.AppendChild(workspaceInfo);
|
|
|
|
// WorkspaceName 요소 추가
|
|
XmlElement workspaceName = doc.CreateElement(string.Empty, "WorkspaceName", string.Empty);
|
|
workspaceName.InnerText = "Untitled Job 1";
|
|
workspaceInfo.AppendChild(workspaceName);
|
|
|
|
// Sequences 요소 추가
|
|
XmlElement sequences = doc.CreateElement(string.Empty, "Sequences", string.Empty);
|
|
metaData.AppendChild(sequences);
|
|
|
|
// Sequence 요소 추가
|
|
XmlElement sequence = doc.CreateElement(string.Empty, "Sequence", string.Empty);
|
|
sequences.AppendChild(sequence);
|
|
|
|
// SequenceName 요소 추가
|
|
XmlElement sequenceName = doc.CreateElement(string.Empty, "SequenceName", string.Empty);
|
|
sequenceName.InnerText = "Sequence 20240830_112708";
|
|
sequence.AppendChild(sequenceName);
|
|
|
|
// SequenceNumber 요소 추가
|
|
XmlElement sequenceNumber = doc.CreateElement(string.Empty, "SequenceNumber", string.Empty);
|
|
sequenceNumber.InnerText = "1"; // iCoordinateID.ToString();
|
|
sequence.AppendChild(sequenceNumber);
|
|
|
|
// SequenceGUID 요소 추가
|
|
XmlElement sequenceGuid = doc.CreateElement(string.Empty, "SequenceGUID", string.Empty);
|
|
sequenceGuid.InnerText = "D9796637E693E79CF68A24B683E4128A";
|
|
sequence.AppendChild(sequenceGuid);
|
|
|
|
// SequenceCoordinateID 요소 추가
|
|
XmlElement sequenceCoordinateId = doc.CreateElement(string.Empty, "SequenceCoordinateID", string.Empty);
|
|
sequenceCoordinateId.InnerText = "1";
|
|
sequence.AppendChild(sequenceCoordinateId);
|
|
|
|
// Welds 요소 추가
|
|
XmlElement welds = doc.CreateElement(string.Empty, "Welds", string.Empty);
|
|
sequence.AppendChild(welds);
|
|
|
|
int iWeldNameNumber = 1;
|
|
|
|
for (int i = 0; i < MetaDataWeldName.Count; i++) {
|
|
if (MetaDataWeldType[i] == "Dot")
|
|
continue; //Dot 의 경우에는 MetaData를 추가하지 않는다.
|
|
|
|
// Weld 요소 추가
|
|
XmlElement weld = doc.CreateElement(string.Empty, "Weld", string.Empty);
|
|
welds.AppendChild(weld);
|
|
|
|
// WeldName 요소 추가
|
|
XmlElement weldName = doc.CreateElement(string.Empty, "WeldName", string.Empty);
|
|
weldName.InnerText = MetaDataWeldType[i] + iWeldNameNumber.ToString();
|
|
weld.AppendChild(weldName);
|
|
|
|
// WeldType 요소 추가
|
|
XmlElement weldType = doc.CreateElement(string.Empty, "WeldType", string.Empty);
|
|
weldType.InnerText = MetaDataWeldType[i];
|
|
weld.AppendChild(weldType);
|
|
|
|
// WeldGUID 요소 추가
|
|
XmlElement weldGuid = doc.CreateElement(string.Empty, "WeldGUID", string.Empty);
|
|
if (MetaDataWeldType[i] == "Line")
|
|
//weldGuid.InnerText = "9E21B74F037FF2D2F49EDFF074C4D957";
|
|
weldGuid.InnerText = "9E21B74F037FF2D2F49EDFF074C4" + string.Format("{0:0000}", i);
|
|
else if (MetaDataWeldType[i] == "Arc")
|
|
weldGuid.InnerText = "1025F018081490012874FB1D63D5" + string.Format("{0:0000}", i);
|
|
weld.AppendChild(weldGuid);
|
|
|
|
// WeldCoordinateID 요소 추가
|
|
XmlElement weldCoordinateId = doc.CreateElement(string.Empty, "WeldCoordinateID", string.Empty);
|
|
weldCoordinateId.InnerText = iWeldNameNumber++.ToString();
|
|
weld.AppendChild(weldCoordinateId);
|
|
|
|
// WeldIndeterminateStartTime 요소 추가
|
|
XmlElement weldIndeterminateStartTime = doc.CreateElement(string.Empty, "WeldIndeterminateStartTime", string.Empty);
|
|
weldIndeterminateStartTime.InnerText = "True";
|
|
weld.AppendChild(weldIndeterminateStartTime);
|
|
}
|
|
|
|
// XML 파일 저장
|
|
doc.Save(fileName);
|
|
} catch (Exception e) {
|
|
Log.E(e.Message);
|
|
}
|
|
}
|
|
|
|
public int AddWorkPieceID(string strID)
|
|
{
|
|
if (!IsActivated || _OCT == null) {
|
|
return -1;
|
|
}
|
|
|
|
return _OCT.AddWorkPieceID(strID);
|
|
}
|
|
|
|
public int CheckWorkPieceID(string strID)
|
|
{
|
|
if (!IsActivated || _OCT == null) {
|
|
return -1;
|
|
}
|
|
|
|
return _OCT.CheckWorkPieceID(strID);
|
|
}
|
|
|
|
public int Open(OCTConfig Config)
|
|
{
|
|
if (_OCT == null) {
|
|
return -1;
|
|
}
|
|
|
|
return _OCT.Open(Config);
|
|
}
|
|
|
|
public bool GetConnected()
|
|
{
|
|
if (!IsActivated || _OCT == null) {
|
|
return false;
|
|
}
|
|
|
|
return _OCT.GetConnected();
|
|
}
|
|
|
|
public string GetResult()
|
|
{
|
|
if (!IsActivated || _OCT == null) {
|
|
return "";
|
|
}
|
|
|
|
return _OCT.GetResult();
|
|
}
|
|
|
|
public void DisConnect()
|
|
{
|
|
if (!IsActivated || _OCT == null) {
|
|
return;
|
|
}
|
|
|
|
_OCT.DisConnect();
|
|
}
|
|
|
|
public int EnterRemoteMode(int Timeout)
|
|
{
|
|
if (!IsActivated || _OCT == null) {
|
|
return -1;
|
|
}
|
|
|
|
return _OCT.EnterRemoteMode(Timeout);
|
|
}
|
|
|
|
public int GetStatus()
|
|
{
|
|
if (!IsActivated || _OCT == null) {
|
|
return -1;
|
|
}
|
|
|
|
return _OCT.GetStatus();
|
|
}
|
|
|
|
public int SetRemoteControl(int RemoteMode)
|
|
{
|
|
if (!IsActivated || _OCT == null) {
|
|
return -1;
|
|
}
|
|
|
|
return _OCT.SetRemoteControl(RemoteMode);
|
|
}
|
|
|
|
public int SetProgram(int nProgram)
|
|
{
|
|
if (!IsActivated || _OCT == null) {
|
|
return -1;
|
|
}
|
|
|
|
return _OCT.SetProgram(nProgram);
|
|
}
|
|
|
|
public int GetRemoteControl()
|
|
{
|
|
if (!IsActivated || _OCT == null) {
|
|
return -1;
|
|
}
|
|
|
|
return _OCT.GetRemoteControl();
|
|
}
|
|
|
|
public string GetKHD_AVG()
|
|
{
|
|
if (!IsActivated || _OCT == null) {
|
|
return "0";
|
|
}
|
|
|
|
return _OCT.GetKHD_AVG();
|
|
}
|
|
|
|
public string GetKHD_MIN()
|
|
{
|
|
if (!IsActivated || _OCT == null) {
|
|
return "0";
|
|
}
|
|
|
|
return _OCT.GetKHD_MIN();
|
|
}
|
|
|
|
public string GetKHD_MAX()
|
|
{
|
|
if (!IsActivated || _OCT == null) {
|
|
return "0";
|
|
}
|
|
|
|
return _OCT.GetKHD_MAX();
|
|
}
|
|
|
|
public string GetKHD_LowSum()
|
|
{
|
|
if (!IsActivated || _OCT == null) {
|
|
return "0";
|
|
}
|
|
|
|
return _OCT.GetKHD_LowSum();
|
|
}
|
|
|
|
public string GetKHD_HighSum()
|
|
{
|
|
if (!IsActivated || _OCT == null) {
|
|
return "0";
|
|
}
|
|
|
|
return _OCT.GetKHD_HighSum();
|
|
}
|
|
|
|
public List<string> GetKHD_Total()
|
|
{
|
|
if (!IsActivated || _OCT == null) {
|
|
return null;
|
|
}
|
|
|
|
return _OCT.GetKHD_Total();
|
|
}
|
|
|
|
public int get_serial_number(in string strCheckSerialNumber, out string strSerialNumber)
|
|
{
|
|
if (!IsActivated || _OCT == null) {
|
|
strSerialNumber = "";
|
|
return E2.NOT_CONNECTED;
|
|
}
|
|
|
|
return _OCT.get_serial_number(strCheckSerialNumber, out strSerialNumber);
|
|
}
|
|
|
|
public int start_software()
|
|
{
|
|
if (!IsActivated || _OCT == null) {
|
|
return -1;
|
|
}
|
|
|
|
return _OCT.start_software();
|
|
}
|
|
|
|
public int set_sequence_file(string SeqFileName)
|
|
{
|
|
if (!IsActivated || _OCT == null) {
|
|
return -1;
|
|
}
|
|
|
|
return _OCT.set_sequence_file(SeqFileName);
|
|
}
|
|
|
|
public int start(string strFileName)
|
|
{
|
|
if (!IsActivated || _OCT == null) {
|
|
return -1;
|
|
}
|
|
|
|
return _OCT.start(strFileName);
|
|
}
|
|
|
|
public int stop()
|
|
{
|
|
if (!IsActivated || _OCT == null) {
|
|
return -1;
|
|
}
|
|
|
|
return _OCT.stop();
|
|
}
|
|
|
|
public int get_last_seqeunce_result(out string strResult)
|
|
{
|
|
if (!IsActivated || _OCT == null) {
|
|
strResult = "";
|
|
return -1;
|
|
}
|
|
|
|
return _OCT.get_last_seqeunce_result(out strResult);
|
|
}
|
|
|
|
public int get_last_job_result(out List<string> lsResult)
|
|
{
|
|
if (!IsActivated || _OCT == null) {
|
|
lsResult = null;
|
|
return (int)eLDDErr.NAV;
|
|
}
|
|
|
|
return _OCT.get_last_job_result(out lsResult);
|
|
}
|
|
|
|
public int get_last_job_fail_codes(out List<string> lsResult)
|
|
{
|
|
if (!IsActivated || _OCT == null) {
|
|
lsResult = null;
|
|
return (int)eLDDErr.NAV;
|
|
}
|
|
|
|
return _OCT.get_last_job_fail_codes(out lsResult);
|
|
}
|
|
|
|
public int get_system_state(out string strResult)
|
|
{
|
|
if (!IsActivated || _OCT == null) {
|
|
strResult = "";
|
|
return -1;
|
|
}
|
|
|
|
return _OCT.get_system_state(out strResult);
|
|
}
|
|
|
|
}
|
|
|
|
public interface IOCT
|
|
{
|
|
int Open(OCTConfig Config);
|
|
void DisConnect();
|
|
bool GetConnected();
|
|
string GetResult();
|
|
int GetAlarm();
|
|
int GetEnable();
|
|
int GetRemoteControl();
|
|
int GetJobComplete();
|
|
int SetProgram(int nProgram); // Set Job Program Number
|
|
int AddWorkPieceID(string strID);
|
|
int SetRemoteControl(int RemoteMode);
|
|
int EnterRemoteMode(int Timeout);
|
|
int GetStatus();
|
|
|
|
int CheckWorkPieceID(string strID);
|
|
string GetKHD_AVG();
|
|
string GetKHD_MIN();
|
|
string GetKHD_MAX();
|
|
string GetKHD_LowSum();
|
|
string GetKHD_HighSum();
|
|
List<string> GetKHD_Total();
|
|
|
|
int get_serial_number(in string strCheckSerialNumber, out string strSerialNumber);
|
|
int start_software();
|
|
int set_sequence_file(string SeqFileName);
|
|
int start(string strFileName);
|
|
int stop();
|
|
int get_last_seqeunce_result(out string strResult);
|
|
int get_last_job_result(out List<string> lsResult);
|
|
int get_last_job_fail_codes(out List<string> lsResult);
|
|
int get_system_state(out string strResult);
|
|
}
|
|
|
|
}
|