96 lines
3.0 KiB
C#
96 lines
3.0 KiB
C#
using Aurora;
|
|
using Aurora.View;
|
|
using Hermes.Functional.Option;
|
|
using ILSOS_PrismaticGun.Device;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using WeldingCommon.Data;
|
|
using WeldingCommon.Utils;
|
|
using static ILSOS_PrismaticGun.Device.PLCControllerPrismaticGun;
|
|
|
|
namespace ILSOS_PrismaticGun.Process
|
|
{
|
|
// UI에서도 쓸 곳이 많을 것 같긴한데.. 일단 추가
|
|
public enum eStage
|
|
{
|
|
A,
|
|
B,
|
|
}
|
|
public enum eCellState
|
|
{
|
|
NotEntered,
|
|
// 실물 CELL 있음
|
|
LoadingComp,
|
|
Welding, // 저장이 필요한 상태는 아니고, 그냥 UI용으로 사용하면 될듯함
|
|
WeldingComp,
|
|
// 실물 CELL 없음
|
|
UnloadingComp,
|
|
}
|
|
public class CellInfo : NotifyPropertyChangedBase ,ICloneable
|
|
{
|
|
public WeldingData weldingData { get; set; } = new WeldingData();
|
|
public eStage WeldingStage { get => _WeldingStage; set => SetProperty(ref _WeldingStage, value); }
|
|
private eStage _WeldingStage;
|
|
public eCellState cellState { get => _cellState; set => SetProperty(ref _cellState, value); }
|
|
private eCellState _cellState;
|
|
public event EventHandler<eCellState> CellStateChanged;
|
|
|
|
#region PLC Cell Data
|
|
public bool IsCellExist { get; private set; }
|
|
public bool LaserWorkComplete { get; set; } = false;
|
|
public bool LaserProcessJudgeNG { get; set; } = true;
|
|
#endregion
|
|
private PLCControllerPrismaticGun _plc;
|
|
public CellInfo()
|
|
{
|
|
_plc = Application.Current.AuroraEnv().DeviceManager[DeviceIds.PLCDevice] as PLCControllerPrismaticGun;
|
|
WeldingStage = eStage.A;
|
|
cellState = eCellState.NotEntered;
|
|
}
|
|
|
|
public void SetState(eCellState cellState)
|
|
{
|
|
if (this.cellState == cellState)
|
|
return;
|
|
|
|
this.cellState = cellState;
|
|
|
|
CellStateChanged?.Invoke(this, cellState);
|
|
}
|
|
public bool CellInfoLoadToPLC()
|
|
{
|
|
IsCellExist = _plc.ExistCell(WeldingStage);
|
|
|
|
return true;
|
|
}
|
|
|
|
public bool CellInfoSendToPLC()
|
|
{
|
|
_plc.WriteExistCell(WeldingStage, IsCellExist);
|
|
_plc.WriteLaserWorkComplete(WeldingStage, LaserWorkComplete);
|
|
_plc.WriteLaserNG(WeldingStage, LaserProcessJudgeNG);
|
|
|
|
return true;
|
|
}
|
|
|
|
public object Clone()
|
|
{
|
|
var cellInfo = new CellInfo();
|
|
cellInfo.weldingData = this.weldingData;
|
|
cellInfo.WeldingStage = this.WeldingStage;
|
|
return cellInfo;
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return $"Stage {Enum.GetName(typeof(eStage), WeldingStage)} >> Cell State : {Enum.GetName(typeof(eCellState), cellState)} >> Cell ID : {weldingData.CellId} >> Cell Exist {IsCellExist} ##";
|
|
}
|
|
}
|
|
}
|