677 lines
27 KiB
C#
677 lines
27 KiB
C#
using Aurora;
|
|
using Aurora.Api;
|
|
using Aurora.Api.Control;
|
|
using Aurora.Api.Devices;
|
|
using Aurora.Api.Manager;
|
|
using Aurora.View;
|
|
using AuroraIO;
|
|
using AuroraLBAD;
|
|
using AuroraLBAD.Device;
|
|
using AuroraLBAD.Service;
|
|
using DB.Recipe;
|
|
using Hermes;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Runtime.Remoting.Contexts;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Windows;
|
|
using System.Windows.Input;
|
|
using System.Windows.Threading;
|
|
using static AuroraLBAD.Device.LBAD_PILOT;
|
|
using static AuroraLBAD.Service.StreamLightLBAD;
|
|
|
|
namespace WeldingCommon.Views
|
|
{
|
|
public class LBADDIValue : NotifyPropertyChangedBase
|
|
{
|
|
public string Address { get; set; }
|
|
public string ID { get; set; }
|
|
private string _description;
|
|
public string Description { get => _description; set => SetProperty(ref _description, value); }
|
|
private bool _dIStatus;
|
|
public bool DIStatus { get => _dIStatus; set => SetProperty(ref _dIStatus, value); }
|
|
}
|
|
public class LBADDOValue : NotifyPropertyChangedBase
|
|
{
|
|
public string Address { get; set; }
|
|
public string ID { get; set; }
|
|
private string _description;
|
|
public string Description { get => _description; set => SetProperty(ref _description, value); }
|
|
private bool _dOStatus;
|
|
public bool DOStatus { get => _dOStatus; set => SetProperty(ref _dOStatus, value); }
|
|
}
|
|
public class UCLBADDeviceViewModel : NotifyPropertyChangedBase
|
|
{
|
|
Logger Log = new Logger("LBAD");
|
|
|
|
private readonly IDeviceManager _deviceManger;
|
|
private readonly LBAD _LBAD;
|
|
private readonly IODevice _IO;
|
|
private readonly LBADConfig _config;
|
|
private StreamLightLBAD _StreamLightLBAD;
|
|
|
|
#region Binding Properties
|
|
private int _RecipeNo;
|
|
public int RecipeNo { get => _RecipeNo; set => SetProperty(ref _RecipeNo, value); }
|
|
private int _ModelNo;
|
|
public int ModelNo { get => _ModelNo; set => SetProperty(ref _ModelNo, value); }
|
|
|
|
private string _strLotID;
|
|
public string strLotID { get => _strLotID; set => SetProperty(ref _strLotID, value); }
|
|
private string _strCellID;
|
|
public string strCellID { get => _strCellID; set => SetProperty(ref _strCellID, value); }
|
|
|
|
// Get Data Binding
|
|
private int _LBAD_RecipeNo;
|
|
public int LBAD_RecipeNo { get => _LBAD_RecipeNo; set => SetProperty(ref _LBAD_RecipeNo, value); }
|
|
|
|
private string _strLBAD_LotID;
|
|
public string strLBAD_LotID { get => _strLBAD_LotID; set => SetProperty(ref _strLBAD_LotID, value); }
|
|
private string _strLBAD_CellID;
|
|
public string strLBAD_CellID { get => _strLBAD_CellID; set => SetProperty(ref _strLBAD_CellID, value); }
|
|
private string _strResult;
|
|
public string strResult { get => _strResult; set => SetProperty(ref _strResult, value); }
|
|
private double _dRateDifference;
|
|
public double dRateDifference { get => _dRateDifference; set => SetProperty(ref _dRateDifference, value); }
|
|
private double _dCenterX;
|
|
public double dCenterX { get => _dCenterX; set => SetProperty(ref _dCenterX, value); }
|
|
private double _dCenterY;
|
|
public double dCenterY { get => _dCenterY; set => SetProperty(ref _dCenterY, value); }
|
|
private double _dCircularity;
|
|
public double dCircularity { get => _dCircularity; set => SetProperty(ref _dCircularity, value); }
|
|
private double _dOuterDiameter;
|
|
public double dOuterDiameter { get => _dOuterDiameter; set => SetProperty(ref _dOuterDiameter, value); }
|
|
|
|
private double _dAvrCh1;
|
|
public double dAvrCh1 { get => _dAvrCh1; set => SetProperty(ref _dAvrCh1, value); }
|
|
private double _dAvrCh2;
|
|
public double dAvrCh2 { get => _dAvrCh2; set => SetProperty(ref _dAvrCh2, value); }
|
|
private double _dAvrCh3;
|
|
public double dAvrCh3 { get => _dAvrCh3; set => SetProperty(ref _dAvrCh3, value); }
|
|
private double _dAvrCh4;
|
|
public double dAvrCh4 { get => _dAvrCh4; set => SetProperty(ref _dAvrCh4, value); }
|
|
|
|
private double _dMinCh1;
|
|
public double dMinCh1 { get => _dMinCh1; set => SetProperty(ref _dMinCh1, value); }
|
|
private double _dMinCh2;
|
|
public double dMinCh2 { get => _dMinCh2; set => SetProperty(ref _dMinCh2, value); }
|
|
private double _dMinCh3;
|
|
public double dMinCh3 { get => _dMinCh3; set => SetProperty(ref _dMinCh3, value); }
|
|
private double _dMinCh4;
|
|
public double dMinCh4 { get => _dMinCh4; set => SetProperty(ref _dMinCh4, value); }
|
|
|
|
private double _dMaxCh1;
|
|
public double dMaxCh1 { get => _dMaxCh1; set => SetProperty(ref _dMaxCh1, value); }
|
|
private double _dMaxCh2;
|
|
public double dMaxCh2 { get => _dMaxCh2; set => SetProperty(ref _dMaxCh2, value); }
|
|
private double _dMaxCh3;
|
|
public double dMaxCh3 { get => _dMaxCh3; set => SetProperty(ref _dMaxCh3, value); }
|
|
private double _dMaxCh4;
|
|
public double dMaxCh4 { get => _dMaxCh4; set => SetProperty(ref _dMaxCh4, value); }
|
|
private double _dStdevCh1;
|
|
public double dStdevCh1 { get => _dStdevCh1; set => SetProperty(ref _dStdevCh1, value); }
|
|
private double _dStdevCh2;
|
|
public double dStdevCh2 { get => _dStdevCh2; set => SetProperty(ref _dStdevCh2, value); }
|
|
private double _dStdevCh3;
|
|
public double dStdevCh3 { get => _dStdevCh3; set => SetProperty(ref _dStdevCh3, value); }
|
|
private double _dStdevCh4;
|
|
public double dStdevCh4 { get => _dStdevCh4; set => SetProperty(ref _dStdevCh4, value); }
|
|
|
|
private ObservableCollection<LBAD_Result_List> _LBAD_ReceivedList = new ObservableCollection<LBAD_Result_List>();
|
|
public ObservableCollection<LBAD_Result_List> LBAD_ReceivedList { get => _LBAD_ReceivedList; set => SetProperty(ref _LBAD_ReceivedList, value); }
|
|
private ObservableCollection<LBADDIValue> _LBADDigitalInputsView = new ObservableCollection<LBADDIValue>();
|
|
public ObservableCollection<LBADDIValue> LBADDigitalInputsView { get => _LBADDigitalInputsView; set => SetProperty(ref _LBADDigitalInputsView, value); }
|
|
private ObservableCollection<LBADDOValue> _LBADDigitalOutputsView = new ObservableCollection<LBADDOValue>();
|
|
public ObservableCollection<LBADDOValue> LBADDigitalOutputsView { get => _LBADDigitalOutputsView; set => SetProperty(ref _LBADDigitalOutputsView, value); }
|
|
private int _SelectedDOutputIndex;
|
|
public int SelectedDOutputIndex { get => _SelectedDOutputIndex; set => SetProperty(ref _SelectedDOutputIndex, value); }
|
|
|
|
private List<stLBAD_Result> lsLBAD_Result;
|
|
#endregion
|
|
|
|
public ICommand CMD_Connect { get; }
|
|
public ICommand CMD_DisConnect { get; }
|
|
public ICommand CMD_SendData { get; }
|
|
public ICommand CMD_TestAdd { get; }
|
|
public ICommand CMD_VisibleChanged { get; }
|
|
public ICommand CMD_TestClear { get; }
|
|
public ICommand CMD_TestStreamPub { get; }
|
|
public ICommand CMD_TestStreamSub { get; }
|
|
|
|
private readonly DispatcherTimer _CurrentStatusUpdateTimer;
|
|
private readonly bool _UseStream;
|
|
|
|
|
|
public UCLBADDeviceViewModel(IAuroraEnvironment aurora, string deviceId1, string deviceId2)
|
|
{
|
|
_deviceManger = aurora.DeviceManager;
|
|
var equipSetting = aurora.SettingEntry[AuroraSettings.Equipment] as EquipmentInfo;
|
|
_UseStream = equipSetting.UseStream;
|
|
|
|
_LBAD = _deviceManger[deviceId1] as LBAD;
|
|
_IO = _deviceManger[deviceId2] as IODevice;
|
|
_StreamLightLBAD = new StreamLightLBAD();
|
|
_StreamLightLBAD._Client = _deviceManger[CommonServiceIds.StreamLightLBADClient] as StreamLightClient;
|
|
_StreamLightLBAD._Sub = _deviceManger[CommonServiceIds.StreamLightLBADSub] as StreamLightSub;
|
|
|
|
|
|
#region Delegate Functions
|
|
CMD_Connect = new DelegateCommand(Connect);
|
|
CMD_DisConnect = new DelegateCommand(DisConnect);
|
|
CMD_SendData = new DelegateCommand(SendData);
|
|
CMD_TestAdd = new DelegateCommand(SendReadyStatus);
|
|
CMD_VisibleChanged = new DelegateCommand(VisibleChanged);
|
|
//CMD_TestClear = new DelegateCommand(TestClear);
|
|
CMD_TestClear = new DelegateCommand(SendCellInfo);
|
|
|
|
CMD_TestStreamPub = new DelegateCommand(TestStreamPublish);
|
|
CMD_TestStreamSub = new DelegateCommand(TestStreamSubscribe);
|
|
#endregion
|
|
|
|
//_CurrentStatusUpdateTimer = new DispatcherTimer();
|
|
//_CurrentStatusUpdateTimer.Tick += OnMonitoring;
|
|
//_CurrentStatusUpdateTimer.Interval = TimeSpan.FromMilliseconds(200);
|
|
|
|
|
|
|
|
#region Initialize Binding Properties
|
|
RecipeNo = 1;
|
|
ModelNo = 4680;
|
|
strLotID = "TEST_LOT_01";
|
|
strCellID = "TEST_CELL_01";
|
|
lsLBAD_Result = new List<stLBAD_Result>();
|
|
#endregion
|
|
}
|
|
|
|
private void TestStreamPublish(object obj)
|
|
{
|
|
//_StreamLightLBAD = new StreamLightLBAD();
|
|
//_StreamLightLBAD.Initialize();
|
|
if (_StreamLightLBAD.SendReadyStatus(eRequestData.Ready_Off) == false) {
|
|
Log.I(string.Format($"[LBAD Interface]CheckReadyStatus null"));
|
|
}
|
|
return;
|
|
object pubData = 1234;
|
|
//EquipDef에 클래스 를 만들면 가져올 방법이 없네..
|
|
var topic = "TOPIC1";
|
|
var _streamPub = new StreamPub("PubSubTest");
|
|
|
|
var res = _streamPub.Publish(pubData, topic);
|
|
if(!res)
|
|
{
|
|
Log.E($"Publish Error : {topic}");
|
|
}
|
|
}
|
|
|
|
private void TestStreamSubscribe(object obj)
|
|
{
|
|
var topic = "LBADResult";
|
|
var _streamSub = new StreamSub("LBADSubTest");
|
|
|
|
_streamSub.AddParser(topic, new StreamJsonParser<LBAD_Result_List>());
|
|
|
|
_streamSub.SetListener(OnSubscribeLBADResult);
|
|
}
|
|
|
|
//private void OnSubscribeLBADResult(string topic, object data, string contentEncoding)
|
|
private void OnSubscribeLBADResult(string from, string topic, object data)
|
|
{
|
|
//StreamPaser에 대한 Data를 받아야 함..
|
|
LBAD_Result_List item = new LBAD_Result_List();
|
|
|
|
//DataGrid에 Update
|
|
LBAD_ReceivedList.Add(item);
|
|
|
|
}
|
|
|
|
private void VisibleChanged(object o)
|
|
{
|
|
bool visible = (bool)o;
|
|
if (visible)
|
|
{
|
|
_CurrentStatusUpdateTimer?.Start();
|
|
InitializeView(_IO._iOUnit.ListDI, InfoIO.IoType.DI);
|
|
InitializeView(_IO._iOUnit.ListDO, InfoIO.IoType.DO);
|
|
}
|
|
else
|
|
{
|
|
_CurrentStatusUpdateTimer?.Stop();
|
|
LBADDigitalInputsView.Clear();
|
|
LBADDigitalOutputsView.Clear();
|
|
}
|
|
}
|
|
private void OnMonitoring(object sender, EventArgs e)
|
|
{
|
|
// UpdateLBADResult();
|
|
//UpdateIOViewMonitoring();
|
|
}
|
|
private void UpdateIOViewMonitoring()
|
|
{
|
|
if (!_IO.IsActivated)
|
|
return;
|
|
|
|
try
|
|
{
|
|
//Read Digital Inputs
|
|
bool[] arrDI = new bool[_IO._iOUnit.GetDICount()];
|
|
_IO._iOUnit.GetDiArray(ref arrDI);
|
|
bool[] arrDO = new bool[_IO._iOUnit.GetDOCount()];
|
|
_IO._iOUnit.GetDoArray(ref arrDO);
|
|
foreach (var ioValue in LBADDigitalInputsView)
|
|
{
|
|
ioValue.DIStatus = Convert.ToBoolean(arrDI[Convert.ToInt32(ioValue.Address)]);
|
|
}
|
|
//Read Digital Outputs
|
|
foreach (var ioValue in LBADDigitalOutputsView)
|
|
{
|
|
ioValue.DOStatus = Convert.ToBoolean(arrDO[Convert.ToInt32(ioValue.Address)]);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Log.E(ex.Message);
|
|
}
|
|
|
|
}
|
|
private void UpdateLBADResult()
|
|
{
|
|
if (_LBAD.IsSimul) {
|
|
return;
|
|
}
|
|
|
|
//if (_LBAD != null && _LBAD._ILBAD != null) {
|
|
if (_LBAD != null) {
|
|
//var LBAD = _LBAD._ILBAD as LBAD_PILOT;
|
|
List<stReceiveData> result;
|
|
//LBAD.GetResultDataList(out result);
|
|
_LBAD.GetResultDataList(out result);
|
|
if (LBAD_ReceivedList.Count != result.Count) {
|
|
LBAD_ReceivedList.Clear();
|
|
lsLBAD_Result.Clear();
|
|
foreach (stReceiveData data in result) {
|
|
lsLBAD_Result.Add(ConvertStructResultData(data));
|
|
}
|
|
foreach (stLBAD_Result data in lsLBAD_Result) {
|
|
LBAD_Result_List item = new LBAD_Result_List();
|
|
item.nRecipeID = data.nRecipeID;
|
|
item.LotID = data.LotID; // 40byte
|
|
item.CellID = data.CellID; // 40byte
|
|
switch (data.nResultFlag) {
|
|
// (OK = 0, NG = 1, NA = 2, FAILED = 3, ERROR = 4)
|
|
case 0:
|
|
item.nResultFlag = "OK";
|
|
break;
|
|
case 1:
|
|
item.nResultFlag = "WANNING";
|
|
break;
|
|
case 2:
|
|
item.nResultFlag = "NA";
|
|
break;
|
|
case 3:
|
|
item.nResultFlag = "NG";
|
|
break;
|
|
case 4:
|
|
item.nResultFlag = "ERROR";
|
|
break;
|
|
default:
|
|
item.nResultFlag = "NG";
|
|
break;
|
|
}
|
|
item.dRateDifference = data.dRateDifference;
|
|
item.dCenterX = data.dCenterX;
|
|
item.dCenterY = data.dCenterY;
|
|
item.dCircularity = data.dCircularity;
|
|
item.dOuterDiameter = data.dOuterDiameter;
|
|
|
|
LBAD_ReceivedList.Add(item);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
public void UpdateLBADResultDetailData(int listindex)
|
|
{
|
|
if (listindex < 0 || listindex >= lsLBAD_Result.Count)
|
|
{
|
|
// UI 들 초기화
|
|
LBAD_RecipeNo = 0;
|
|
strLBAD_LotID = "";
|
|
strLBAD_CellID = "";
|
|
strResult = "";
|
|
dRateDifference = 0.0;
|
|
dCenterX = 0.0;
|
|
dCenterY = 0.0;
|
|
dCircularity = 0.0;
|
|
dOuterDiameter = 0.0;
|
|
|
|
dAvrCh1 = 0; dMinCh1 = 0; dMaxCh1 = 0; dStdevCh1 = 0;
|
|
dAvrCh2 = 0; dMinCh2 = 0; dMaxCh2 = 0; dStdevCh2 = 0;
|
|
dAvrCh3 = 0; dMinCh3 = 0; dMaxCh3 = 0; dStdevCh3 = 0;
|
|
dAvrCh4 = 0; dMinCh4 = 0; dMaxCh4 = 0; dStdevCh4 = 0;
|
|
}
|
|
else
|
|
{
|
|
stLBAD_Result item = lsLBAD_Result[listindex];
|
|
LBAD_RecipeNo = item.nRecipeID;
|
|
strLBAD_LotID = item.LotID;
|
|
strLBAD_CellID = item.CellID;
|
|
switch (item.nResultFlag)
|
|
{
|
|
// (OK = 0, NG = 1, NA = 2, FAILED = 3, ERROR = 4)
|
|
case 0:
|
|
strResult = "OK";
|
|
break;
|
|
case 1:
|
|
strResult = "WANNING";
|
|
break;
|
|
case 2:
|
|
strResult = "NA";
|
|
break;
|
|
case 3:
|
|
strResult = "NG";
|
|
break;
|
|
case 4:
|
|
strResult = "ERROR";
|
|
break;
|
|
default:
|
|
strResult = "NG";
|
|
break;
|
|
}
|
|
dRateDifference = item.dRateDifference;
|
|
dCenterX = item.dCenterX;
|
|
dCenterY = item.dCenterY;
|
|
dCircularity = item.dCircularity;
|
|
dOuterDiameter = item.dOuterDiameter;
|
|
|
|
dAvrCh1 = item.arrAverage[0]; dMinCh1 = item.arrMin[0]; dMaxCh1 = item.arrMax[0]; dStdevCh1 = item.arrStdev[0];
|
|
dAvrCh2 = item.arrAverage[1]; dMinCh2 = item.arrMin[1]; dMaxCh2 = item.arrMax[1]; dStdevCh2 = item.arrStdev[1];
|
|
dAvrCh3 = item.arrAverage[2]; dMinCh3 = item.arrMin[2]; dMaxCh3 = item.arrMax[2]; dStdevCh3 = item.arrStdev[2];
|
|
dAvrCh4 = item.arrAverage[3]; dMinCh4 = item.arrMin[3]; dMaxCh4 = item.arrMax[3]; dStdevCh4 = item.arrStdev[3];
|
|
}
|
|
}
|
|
private void Connect(object obj)
|
|
{
|
|
if(_UseStream) {
|
|
if (!_StreamLightLBAD._Client.IsActivated) {
|
|
int ret = _StreamLightLBAD._Client.Activate();
|
|
Thread.Sleep(500);
|
|
if (ret != E1.OK) {
|
|
Log.E($"StreamLightClient activate failed");
|
|
}
|
|
}
|
|
if (!_StreamLightLBAD._Sub.IsActivated) {
|
|
int ret = _StreamLightLBAD._Sub.Activate();
|
|
Thread.Sleep(500);
|
|
if (ret != E1.OK) {
|
|
Log.E($"StreamLightClient activate failed");
|
|
}
|
|
}
|
|
_StreamLightLBAD.Initialize();
|
|
return;
|
|
}
|
|
if (_LBAD.IsSimul) {
|
|
return;
|
|
}
|
|
|
|
//if (_LBAD != null && _LBAD._ILBAD != null) {
|
|
if (_LBAD != null) {
|
|
//var LBAD = _LBAD._ILBAD as LBAD_PILOT;
|
|
_LBAD.Open(_LBAD.Config);
|
|
//LBAD.Open(_LBAD.Config);
|
|
if (_LBAD.GetConnected()) {
|
|
MessageUtil.CreateAndShowMessageDialog("Success", "LBAD is Connected.");
|
|
} else {
|
|
MessageUtil.CreateAndShowMessageDialog("Fail", "LBAD is not Connected.");
|
|
}
|
|
}
|
|
}
|
|
|
|
private void InitializeStream(object obj)
|
|
{
|
|
if (!_StreamLightLBAD._Client.IsActivated) {
|
|
int ret = _StreamLightLBAD._Client.Activate();
|
|
Thread.Sleep(500);
|
|
if (ret != E1.OK) {
|
|
Log.E($"StreamLightClient activate failed");
|
|
}
|
|
}
|
|
if (!_StreamLightLBAD._Sub.IsActivated) {
|
|
int ret = _StreamLightLBAD._Sub.Activate();
|
|
Thread.Sleep(500);
|
|
if (ret != E1.OK) {
|
|
Log.E($"StreamLightClient activate failed");
|
|
}
|
|
}
|
|
_StreamLightLBAD.Initialize();
|
|
|
|
}
|
|
|
|
public void SendReadyStatus(object obj)
|
|
{
|
|
//_StreamLightLBAD = new StreamLightLBAD();
|
|
//_StreamLightLBAD.Initialize();
|
|
if (_StreamLightLBAD.SendReadyStatus(eRequestData.Ready_On) == false) {
|
|
Log.I(string.Format($"[LBAD Interface]CheckReadyStatus null"));
|
|
}
|
|
}
|
|
|
|
public void SendCellInfo(object obj)
|
|
{
|
|
if (_UseStream) {
|
|
if (_StreamLightLBAD.SendCellInfo("2170testid", "2170cellid", 0, 1, 16) == false) {
|
|
Log.I(string.Format($"[LBAD Interface]SetWeldTriggerOn null"));
|
|
}
|
|
}
|
|
}
|
|
|
|
private void DisConnect(object obj)
|
|
{
|
|
if (_LBAD.IsSimul) {
|
|
return;
|
|
}
|
|
|
|
//if (_LBAD != null && _LBAD._ILBAD != null) {
|
|
if (_LBAD != null) {
|
|
//var LBAD = _LBAD._ILBAD as LBAD_PILOT;
|
|
//LBAD.DisConnect();
|
|
_LBAD.DisConnect();
|
|
}
|
|
}
|
|
private void SendData(object obj)
|
|
{
|
|
if (_UseStream) {
|
|
if (_StreamLightLBAD.SendWeldingStop() == false) {
|
|
Log.I(string.Format($"[LBAD Interface]SetWeldTriggerOn null"));
|
|
}
|
|
return;
|
|
}
|
|
if (_LBAD.IsSimul) {
|
|
return;
|
|
}
|
|
|
|
//if (_LBAD != null && _LBAD._ILBAD != null) {
|
|
if (_LBAD != null) {
|
|
//var LBAD = _LBAD._ILBAD as LBAD_PILOT;
|
|
//LBAD.SendInfoData(strLotID, strCellID, RecipeNo, ModelNo);
|
|
_LBAD.SendInfoData(strLotID, strCellID, RecipeNo, ModelNo);
|
|
}
|
|
}
|
|
private unsafe void TestAdd(object obj)
|
|
{
|
|
if (_LBAD.IsSimul) {
|
|
return;
|
|
}
|
|
|
|
//if (_LBAD != null && _LBAD._ILBAD != null) {
|
|
if (_LBAD != null) {
|
|
//var LBAD = _LBAD._ILBAD as LBAD_PILOT;
|
|
|
|
List<stReceiveData> ResultList;
|
|
//LBAD.GetResultDataList(out ResultList);
|
|
_LBAD.GetResultDataList(out ResultList);
|
|
stReceiveData item = new stReceiveData();
|
|
|
|
|
|
byte* PtrLotID = item.chLotID;
|
|
{
|
|
for (int i = 0; i < strLotID.Length; i++) {
|
|
item.chLotID[i] = Convert.ToByte(strLotID[i]);
|
|
}
|
|
item.chLotID[strLotID.Length] = Convert.ToByte('\0');
|
|
}
|
|
|
|
byte* PtrCellID = item.chCellID;
|
|
{
|
|
for (int i = 0; i < strCellID.Length; i++) {
|
|
item.chCellID[i] = Convert.ToByte(strCellID[i]);
|
|
}
|
|
item.chCellID[strCellID.Length] = Convert.ToByte('\0');
|
|
}
|
|
|
|
Random random = new Random();
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
item.arrAverage[i] = random.NextDouble();
|
|
item.arrMin[i] = random.NextDouble();
|
|
item.arrMax[i] = random.NextDouble();
|
|
item.arrStdev[i] = random.NextDouble();
|
|
}
|
|
|
|
ResultList.Add(item);
|
|
}
|
|
}
|
|
|
|
public struct stLBAD_Result
|
|
{
|
|
public Int32 nBodySize; // sizeof(body) = 252byte
|
|
public Int16 nCmd; // cmdJobResultReport = 20;
|
|
public string LotID; // 40byte
|
|
public string CellID; // 40byte
|
|
public Int16 nRecipeID;
|
|
public Int16 nResultFlag; // (OK = 0, NG = 1, NA = 2, FAILED = 3, ERROR = 4)
|
|
public double[] arrAverage; // 8byte * 4ch = 32byte
|
|
public double[] arrMin; // 8byte * 4ch = 32byte
|
|
public double[] arrMax; // 8byte * 4ch = 32byte
|
|
public double[] arrStdev; // 8byte * 4ch = 32byte
|
|
public double dRateDifference;
|
|
public double dCenterX;
|
|
public double dCenterY;
|
|
public double dCircularity;
|
|
public double dOuterDiameter;
|
|
}
|
|
public class LBAD_Result_List : NotifyPropertyChangedBase
|
|
{
|
|
public Int16 nRecipeID { get; set; }
|
|
public string LotID { get; set; }
|
|
public string CellID { get; set; }
|
|
public string nResultFlag { get; set; }
|
|
public double dRateDifference { get; set; }
|
|
public double dCenterX { get; set; }
|
|
public double dCenterY { get; set; }
|
|
public double dCircularity { get; set; }
|
|
public double dOuterDiameter { get; set; }
|
|
|
|
}
|
|
|
|
|
|
private unsafe stLBAD_Result ConvertStructResultData(stReceiveData stInput)
|
|
{
|
|
stLBAD_Result stResult = new stLBAD_Result();
|
|
stResult.nBodySize = stInput.nBodySize;
|
|
stResult.nCmd = stInput.nCmd;
|
|
stResult.nRecipeID = stInput.nRecipeID;
|
|
stResult.nResultFlag = stInput.nResultFlag;
|
|
stResult.dRateDifference = stInput.dRateDifference;
|
|
stResult.dCenterX = stInput.dCenterX;
|
|
stResult.dCenterY = stInput.dCenterY;
|
|
stResult.dCircularity = stInput.dCircularity;
|
|
stResult.dOuterDiameter = stInput.dOuterDiameter;
|
|
|
|
|
|
stResult.LotID = Encoding.UTF8.GetString(stInput.chLotID, byteCount: 40);
|
|
stResult.CellID = Encoding.UTF8.GetString(stInput.chCellID, byteCount: 40);
|
|
|
|
stResult.arrAverage = new double[4];
|
|
stResult.arrMin = new double[4];
|
|
stResult.arrMax = new double[4];
|
|
stResult.arrStdev = new double[4];
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
{
|
|
stResult.arrAverage[i] = stInput.arrAverage[i];
|
|
stResult.arrMin[i] = stInput.arrMin[i];
|
|
stResult.arrMax[i] = stInput.arrMax[i];
|
|
stResult.arrStdev[i] = stInput.arrStdev[i];
|
|
}
|
|
return stResult;
|
|
}
|
|
private void InitializeView(List<InfoIO> listIO, InfoIO.IoType type)
|
|
{
|
|
try
|
|
{
|
|
foreach (InfoIO item in listIO)
|
|
{
|
|
if(item.ID.Contains("LBAD"))
|
|
{
|
|
switch (type)
|
|
{
|
|
case InfoIO.IoType.DI:
|
|
LBADDIValue dIItem = new LBADDIValue();
|
|
dIItem.Address = item.Address;
|
|
dIItem.Description = item.Description;
|
|
dIItem.ID = item.ID;
|
|
LBADDigitalInputsView.Add(dIItem);
|
|
break;
|
|
case InfoIO.IoType.DO:
|
|
LBADDOValue dOItem = new LBADDOValue();
|
|
dOItem.Address = item.Address;
|
|
dOItem.Description = item.Description;
|
|
dOItem.ID = item.ID;
|
|
LBADDigitalOutputsView.Add(dOItem);
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//Log.I(string.Format("IO ID does not contain LBAD!"));
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Log.E(ex.Message);
|
|
}
|
|
}
|
|
public void SetBit()
|
|
{
|
|
if (LBADDigitalOutputsView.Count > 0)
|
|
{
|
|
bool targetDOStatus = (LBADDigitalOutputsView[SelectedDOutputIndex].DOStatus == true) ? false : true;
|
|
string selectedDOAddr = LBADDigitalOutputsView[SelectedDOutputIndex].Address;
|
|
string selectedDODescripiton = LBADDigitalOutputsView[SelectedDOutputIndex].Description;
|
|
|
|
var result = MessageDialog.Show(Application.Current.MainWindow, "IO Board Interface", $"Do you want to change DO of {selectedDODescripiton}?",
|
|
MessageDialog.Type.AffirmativeAndNegative);
|
|
if (result == MessageDialog.Result.Negative)
|
|
{
|
|
return;
|
|
}
|
|
try
|
|
{
|
|
_IO._iOUnit.WriteDoBit(Convert.ToInt32(selectedDOAddr), targetDOStatus);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Log.E(ex.Message);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Log.E(string.Format("DigitalOutputsView is null"));
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|