Files
ENIG/Cs_HMI/Project/Class/CResult.cs
2025-01-07 16:08:02 +09:00

237 lines
6.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using static Project.StateMachine;
namespace Project
{
public class CResult
{
public bool SMSG_ProgressEnable = false;
//public string SMSG_Text = string.Empty;
public float SMSG_ProgressMax = 0;
public int SMSG_ProgressMin = 0;
public Color SMSG_ProgressForeColor = Color.Red;
public Color SMSG_ForeColor = Color.Black;
public Color SMSG_BackColor = Color.White;
public Color SMSG_BackColor2 = Color.White;
public Color SMSG_ShadowColor = Color.Transparent;
public float SMSG_ProgressValue = 0;
public string SMSG_Tag = string.Empty;
//public event EventHandler SMSG_Update;
//public void UpdateStatusMessage()
//{
// SMSG_Update?.Invoke(null, null);
//}
/// <summary>
/// 작업시작시간
/// </summary>
public DateTime JobStartTime;
/// <summary>
/// 작업종료시간
/// </summary>
public DateTime JobEndTime;
//public DateTime IdleStartTime = DateTime.Parse("1982-11-23");
/// <summary>
/// 작업진행시간
/// </summary>
public TimeSpan JobRunTime
{
get
{
if (JobStartTime.Year == 1982) return new TimeSpan(0);
if (JobEndTime.Year == 1982) return DateTime.Now - JobStartTime;
else return JobEndTime - JobStartTime;
}
}
//public DateTime ChargeStartTime = DateTime.Parse("1982-11-23");
#region "AGV Status Value"
public string PLC1_RawData { get; set; }
public string PLC2_RawData { get; set; }
#endregion
/// <summary>
/// 이동대상위치(상차,하차,충전)
/// </summary>
private ePosition _targetPos = ePosition.NONE;
public event EventHandler TargetPosSet;
public string result_message = "";
public double result_progressmax = 0;
public double result_progressvalue = 0;
public DateTime StopMessageTimePLC = DateTime.Parse("1982-11-23");
public DateTime StopMessageTimeSWR = DateTime.Parse("1982-11-23");
public string StopMessagePLC = string.Empty;
public string StopMessageSWR = string.Empty;
//public DateTime LastChar
//geTime = DateTime.Parse("1982-11-23");
public ePosition NextPos = ePosition.NONE;
public ePosition TargetPos
{
get
{
return _targetPos;
}
set
{
_targetPos = value;
TargetPosSet?.Invoke(this, null);
PUB.log.Add(string.Format("대상위치설정:{0}", value));
}
}
private char _comandKit { get; set; }
public char CommandKit
{
get
{
return _comandKit;
}
set
{
_comandKit = value;
PUB.log.Add(string.Format("명령을 내린 KIT 설정 No={0}", value));
}
}
//private ePosition _currentPos = ePosition.NONE;
//public ePosition CurrentPos
//{
// get
// {
// return _currentPos;
// }
// set
// {
// if (_currentPos != value) //값이바뀔떄만 메세지 220628
// PUB.log.Add(string.Format("현재위치 설정:{0}->{1}", _currentPos, value));
// _currentPos = value;
// }
//}
private ePosition _currentpos = ePosition.NONE;
private string _currentposcw = string.Empty;
// public ePosition LastPos = ePosition.NONE;
public string LastTAG { get; set; } = string.Empty;
public ePosition CurrentPos
{
get
{
return _currentpos; }
set
{
if (_currentpos != value) //값이 바뀔때만 메세지 220628
PUB.log.Add(string.Format("TAG위치 설정:{0}->{1}", _currentpos, value));
_currentpos = value;
}
}
public string CurrentPosCW
{
get
{
return _currentposcw;
}
set
{
if (_currentposcw != value) //값이바뀔때만 메세지 220628
PUB.log.Add(string.Format("TAG방향 설정:{0}->{1}", _currentposcw, value));
_currentposcw = value;
}
}
public string Memo;
public eResult ResultCode { get; set; }
public eECode ResultErrorCode;
public string ResultMessage { get; set; }
#region "SetResultMessage"
public void SetResultMessage(eResult code, eECode err, eNextStep systempause, params object[] args)
{
var rltMsg = UTIL.GetResultCodeMessage(code);
var codeMSg = $"[E{(int)err}] ";// + Util.GetResultCodeMessage(code);
if (err == eECode.MESSAGE_ERROR)
{
codeMSg = $"[{rltMsg} ERROR MESSAGE]\n";
}
else if (err == eECode.MESSAGE_INFO)
{
codeMSg = $"[{rltMsg} INFORMATION]\n";
}
var erMsg = UTIL.GetErrorMessage(err, args);
var msg = codeMSg + erMsg;
this.ResultCode = code;
this.ResultErrorCode = err;
this.ResultMessage = msg;
if (systempause == eNextStep.PAUSENOMESAGE) this.ResultMessage = string.Empty; //210129
PUB.log.AddE(msg);
if (systempause == eNextStep.PAUSE) PUB.sm.SetNewStep(eSMStep.PAUSE);
else if (systempause == eNextStep.PAUSENOMESAGE) PUB.sm.SetNewStep(eSMStep.PAUSE);
else if (systempause == eNextStep.ERROR) PUB.sm.SetNewStep(eSMStep.ERROR);
}
#endregion
public Boolean isError { get; set; }
public int retry = 0;
public DateTime retryTime;
public Device.Socket.Message RecvMessage;
public CResult()
{
this.Clear();
}
public void Clear()
{
JobStartTime = DateTime.Parse("1982-11-23");
JobEndTime = DateTime.Parse("1982-11-23");
Memo = string.Empty;
isError = false;
ResultCode = eResult.NoError;
ResultMessage = string.Empty;
}
}
}