initial commit
This commit is contained in:
37
Cs_HMI/StateMachine/DisplayTextHandler.cs
Normal file
37
Cs_HMI/StateMachine/DisplayTextHandler.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Project
|
||||
{
|
||||
public partial class fMain
|
||||
{
|
||||
delegate void ShowLotTextHandler(string value);
|
||||
|
||||
delegate void UpdateDMTextHandler(string value1);
|
||||
|
||||
void UpdateResultText(string value1)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
delegate void UpdateLabelTextHandler(Control ctl, string value);
|
||||
void UpdateLabelText(Control ctl, string value)
|
||||
{
|
||||
if (ctl.InvokeRequired)
|
||||
{
|
||||
ctl.BeginInvoke(new UpdateLabelTextHandler(UpdateLabelText), new object[] { ctl, value });
|
||||
}
|
||||
else
|
||||
{
|
||||
ctl.Text = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
92
Cs_HMI/StateMachine/EnumStruct.cs
Normal file
92
Cs_HMI/StateMachine/EnumStruct.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Project
|
||||
{
|
||||
public partial class StateMachine
|
||||
{
|
||||
public enum eGoDir
|
||||
{
|
||||
Up,
|
||||
Down,
|
||||
}
|
||||
public enum EMsgOpt : byte
|
||||
{
|
||||
NORMAL,
|
||||
STEPCHANGE,
|
||||
ERROR,
|
||||
}
|
||||
/// <summary>
|
||||
/// 000~020 : System Define
|
||||
/// 020~255 : User Define
|
||||
/// </summary>
|
||||
public enum eSMStep : byte
|
||||
{
|
||||
NOTSET = 0,
|
||||
INIT,
|
||||
SYNC,
|
||||
IDLE,
|
||||
RUN,
|
||||
FINISH,
|
||||
PAUSE,
|
||||
ERROR,
|
||||
RESET,
|
||||
EMERGENCY,
|
||||
CLEAR,
|
||||
CLOSING,
|
||||
CLOSEWAIT,
|
||||
CLOSED,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// RUN중일 때 사용되는 세부 시퀀스
|
||||
/// </summary>
|
||||
public enum ERunStep : byte
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 자동모드 대기상태
|
||||
/// </summary>
|
||||
READY=0,
|
||||
|
||||
/// <summary>
|
||||
/// 홈(QC)로 이동합니다
|
||||
/// </summary>
|
||||
GOHOME,
|
||||
|
||||
/// <summary>
|
||||
/// 충전을 해제 함
|
||||
/// </summary>
|
||||
CHARGEOFF,
|
||||
|
||||
/// <summary>
|
||||
/// 충전이동
|
||||
/// </summary>
|
||||
GOCHARGE,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 충전중
|
||||
/// </summary>
|
||||
CHARGECHECK =50,
|
||||
|
||||
/// <summary>
|
||||
/// 상차이동
|
||||
/// </summary>
|
||||
GOUP,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 하차이동
|
||||
/// </summary>
|
||||
GODOWN,
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
55
Cs_HMI/StateMachine/EventArgs.cs
Normal file
55
Cs_HMI/StateMachine/EventArgs.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Project
|
||||
{
|
||||
public partial class StateMachine
|
||||
{
|
||||
public class StateMachineMessageEventArgs : EventArgs
|
||||
{
|
||||
public string Header { get; set; }
|
||||
public string Message { get; set; }
|
||||
public StateMachineMessageEventArgs(string header_, string message_)
|
||||
{
|
||||
this.Message = message_;
|
||||
this.Header = header_;
|
||||
}
|
||||
}
|
||||
public event EventHandler<StateMachineMessageEventArgs> Message;
|
||||
void RaiseMessage(string header, string msg)
|
||||
{
|
||||
if (Message != null) Message(this, new StateMachineMessageEventArgs(header, msg));
|
||||
}
|
||||
|
||||
public class StepChangeEventArgs : EventArgs
|
||||
{
|
||||
public eSMStep Old { get; set; }
|
||||
public eSMStep New { get; set; }
|
||||
public StepChangeEventArgs(eSMStep old_,eSMStep new_)
|
||||
{
|
||||
this.Old = old_;
|
||||
this.New = new_;
|
||||
}
|
||||
}
|
||||
public class RunningEventArgs : EventArgs {
|
||||
public Boolean isFirst { get; set; }
|
||||
public eSMStep Step { get; set; }
|
||||
public TimeSpan StepTime { get; set; }
|
||||
public object Data { get; set; }
|
||||
public RunningEventArgs( eSMStep step_, Boolean isfirst_,TimeSpan steptime_,object data = null)
|
||||
{
|
||||
this.isFirst = isfirst_;
|
||||
this.Step = step_;
|
||||
StepTime = steptime_;
|
||||
this.Data = data;
|
||||
}
|
||||
}
|
||||
public event EventHandler<StepChangeEventArgs> StepChanged;
|
||||
public event EventHandler SPS;
|
||||
public event EventHandler<RunningEventArgs> Running;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
36
Cs_HMI/StateMachine/Properties/AssemblyInfo.cs
Normal file
36
Cs_HMI/StateMachine/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해
|
||||
// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면
|
||||
// 이러한 특성 값을 변경하세요.
|
||||
[assembly: AssemblyTitle("StateMachine")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("StateMachine")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2020")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에
|
||||
// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면
|
||||
// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다.
|
||||
[assembly: Guid("bbc9bccf-6262-4355-9cc2-37ff678ac499")]
|
||||
|
||||
// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다.
|
||||
//
|
||||
// 주 버전
|
||||
// 부 버전
|
||||
// 빌드 번호
|
||||
// 수정 버전
|
||||
//
|
||||
// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호를
|
||||
// 기본값으로 할 수 있습니다.
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
334
Cs_HMI/StateMachine/StateMachine.cs
Normal file
334
Cs_HMI/StateMachine/StateMachine.cs
Normal file
@@ -0,0 +1,334 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Project
|
||||
{
|
||||
public partial class StateMachine : IDisposable
|
||||
{
|
||||
public DateTime UpdateTime;
|
||||
public TimeSpan RunSpeed = new TimeSpan(0);
|
||||
private Boolean bLoop = true;
|
||||
private DateTime StepStartTime;
|
||||
private byte _messageOption;
|
||||
|
||||
private System.Threading.Thread worker;
|
||||
private Boolean firstRun = false;
|
||||
|
||||
public Boolean WaitFirstRun = false;
|
||||
|
||||
|
||||
|
||||
public StateMachine()
|
||||
{
|
||||
WaitFirstRun = false;
|
||||
UpdateTime = DateTime.Now;
|
||||
_messageOption = 0xFF; //모든메세지가 오도록 한다.
|
||||
worker = new System.Threading.Thread(new System.Threading.ThreadStart(Loop))
|
||||
{
|
||||
IsBackground = false
|
||||
};
|
||||
StepStartTime = DateTime.Parse("1982-11-23");
|
||||
}
|
||||
|
||||
~StateMachine()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
#region "Dispose"
|
||||
|
||||
private bool disposed = false;
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
// Check to see if Dispose has already been called.
|
||||
if (!this.disposed)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// Dispose managed resources.
|
||||
}
|
||||
|
||||
Stop();
|
||||
// unmanaged resources here.
|
||||
// If disposing is false,
|
||||
// only the following code is executed.
|
||||
disposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
bLoop = false;
|
||||
//if (worker.IsAlive)
|
||||
// if (worker.Join(1000) == false)
|
||||
// worker.Abort();
|
||||
}
|
||||
public void Start()
|
||||
{
|
||||
if (worker.ThreadState == System.Threading.ThreadState.Stopped)
|
||||
{
|
||||
worker = new System.Threading.Thread(new System.Threading.ThreadStart(Loop))
|
||||
{
|
||||
IsBackground = false
|
||||
};
|
||||
}
|
||||
bLoop = true;
|
||||
worker.Start();
|
||||
}
|
||||
|
||||
private Boolean _isthreadrun;
|
||||
public Boolean IsThreadRun { get { return _isthreadrun; } }
|
||||
|
||||
void Loop()
|
||||
{
|
||||
_isthreadrun = true;
|
||||
if (GetMsgOpt(EMsgOpt.NORMAL)) RaiseMessage("SM", "Start");
|
||||
while (bLoop)
|
||||
{
|
||||
RunSpeed = DateTime.Now - UpdateTime; //이전업데이트에서 현재 시간의 오차 한바퀴 시간이 표시됨
|
||||
UpdateTime = DateTime.Now;
|
||||
|
||||
//항상 작동하는 경우
|
||||
SPS?.Invoke(this, new EventArgs());
|
||||
|
||||
//작동스텝이 변경되었다면 그것을 알림 처리한다.
|
||||
if (GetNewStep != Step)
|
||||
{
|
||||
if (GetMsgOpt(EMsgOpt.STEPCHANGE))
|
||||
RaiseMessage("SM-STEP", string.Format("Step Changed {0} >> {1}", Step, GetNewStep));
|
||||
|
||||
StepApply();
|
||||
firstRun = true;
|
||||
StepStartTime = DateTime.Now;
|
||||
}
|
||||
else
|
||||
{
|
||||
//팝업메세지의 종료를 기다리는 식에서 문제가 생긴다
|
||||
firstRun = WaitFirstRun;
|
||||
}
|
||||
|
||||
|
||||
//동작중에 발생하는 이벤트
|
||||
if (Running != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
Running(this, new RunningEventArgs(Step, firstRun, StepRunTime));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
RaiseMessage("SM-ERROR", ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
System.Threading.Thread.Sleep(1);
|
||||
}
|
||||
_isthreadrun = false;
|
||||
if (GetMsgOpt(EMsgOpt.NORMAL)) RaiseMessage("SM", "Stop");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 상태머신의 작동상태
|
||||
/// </summary>
|
||||
public eSMStep Step { get { return _step; } }
|
||||
|
||||
/// <summary>
|
||||
/// 상태머신값을 숫자로 반환 합니다. (20이하는 시스템상태이고 그 이상은 사용자 상태)
|
||||
/// </summary>
|
||||
public byte StepValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return (byte)this._step;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 현재 진행 스텝을 강제로 변경합니다.
|
||||
/// 일반적인 상태변화는 setNewStep 을 사용하세요.
|
||||
/// </summary>
|
||||
/// <param name="step"></param>
|
||||
public void SetCurrentStep(ERunStep step)
|
||||
{
|
||||
RaiseMessage("SM-STEP", string.Format("강제 스텝 변경 {0}->{1}", _runstepo, step));
|
||||
_runstepo = step;
|
||||
_runstepn = step;
|
||||
}
|
||||
|
||||
public void SetNewStep(eSMStep newstep_, bool force = false)
|
||||
{
|
||||
if (Step != newstep_)
|
||||
{
|
||||
if(force)
|
||||
{
|
||||
RaiseMessage("SM-STEP", string.Format("강제스텝전환 {0} -> {1}", Step, _newstep));
|
||||
OldStep = _step;
|
||||
_step = newstep_;
|
||||
_newstep = newstep_;
|
||||
StepChanged?.Invoke(this, new StepChangeEventArgs(OldStep, newstep_));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_newstep != newstep_)
|
||||
{
|
||||
//바뀌도록 예약을 한다.
|
||||
_newstep = newstep_;
|
||||
if (GetMsgOpt(EMsgOpt.STEPCHANGE))
|
||||
RaiseMessage("SM-STEP", string.Format("Step Reserve {0} -> {1}", Step, _newstep));
|
||||
}
|
||||
else
|
||||
{
|
||||
//예약은 되어있는데 아직 바뀐것은 아니다.
|
||||
if (GetMsgOpt(EMsgOpt.STEPCHANGE))
|
||||
RaiseMessage("SM-STEP", string.Format("Step Already Reserve {0} -> {1}", Step, _newstep));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#region "runstep"
|
||||
private int _runStepSeq = 0;
|
||||
public int RunStepSeq { get { return _runStepSeq; } }
|
||||
|
||||
private DateTime runStepStartTime = DateTime.Parse("1982-11-23");
|
||||
private ERunStep _runstepn = ERunStep.READY;
|
||||
private ERunStep _runstepo = ERunStep.READY;
|
||||
public ERunStep RunStep { get { return _runstepo; } }
|
||||
public ERunStep RunStepNew { get { return _runstepn; } }
|
||||
public void SetNewRunStep(ERunStep newStep)
|
||||
{
|
||||
if (_runstepn != newStep)
|
||||
{
|
||||
// Pub.log.Add(string.Format("set new run step {0}->{1}", _runstepn, newStep));
|
||||
_runstepn = newStep;
|
||||
}
|
||||
}
|
||||
public void ApplyRunStep()
|
||||
{
|
||||
if (_runstepn != _runstepo)
|
||||
{
|
||||
//Pub.log.Add(string.Format("apply new run step {0}->{1}", _runstepo, _runstepn));
|
||||
_runStepSeq = 0;
|
||||
_runstepo = _runstepn;
|
||||
UpdateRunStepSeq();// runStepStartTime = DateTime.Now;
|
||||
}
|
||||
}
|
||||
public TimeSpan GetRunSteptime { get { return DateTime.Now - runStepStartTime; } }
|
||||
public void SetStepSeq(byte value)
|
||||
{
|
||||
_runStepSeq = value;
|
||||
if (GetMsgOpt(EMsgOpt.NORMAL))
|
||||
{
|
||||
if (_runStepSeq != value) //변화가잇는겨웅에만 처리 220628
|
||||
RaiseMessage("STEPSEQ", string.Format("Step Sequence Jump {0} to {1}", _runStepSeq, value));
|
||||
}
|
||||
|
||||
}
|
||||
public void UpdateRunStepStartTime()
|
||||
{
|
||||
runStepStartTime = DateTime.Now;
|
||||
// Pub.log.Add("Update RunStep Start Time");
|
||||
}
|
||||
public void UpdateRunStepSeq(int incvalue = 1)
|
||||
{
|
||||
_runStepSeq += incvalue;
|
||||
UpdateRunStepStartTime();
|
||||
// Pub.log.Add(string.Format("스텝({0}) 시퀀스증가 신규값={1}", runStep, _runStepSeq));
|
||||
}
|
||||
public void ResetRunStepSeq()
|
||||
{
|
||||
_runStepSeq = 1;
|
||||
UpdateRunStepStartTime();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// runstep 시퀀스값을 1로 설정하고 시작시간도 업데이트 합니다
|
||||
/// 기본 스텝상태를 READY로 변경 합니다
|
||||
/// </summary>
|
||||
public void ClearRunStep()
|
||||
{
|
||||
_runStepSeq = 1;
|
||||
runStepStartTime = DateTime.Now;
|
||||
_runstepn = ERunStep.READY;
|
||||
_runstepo = ERunStep.READY;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
public eSMStep GetNewStep
|
||||
{
|
||||
get
|
||||
{
|
||||
return _newstep;
|
||||
}
|
||||
}
|
||||
private eSMStep _newstep = eSMStep.NOTSET;
|
||||
public eSMStep OldStep = eSMStep.NOTSET; //171214
|
||||
private eSMStep _step;
|
||||
|
||||
/// <summary>
|
||||
/// newstep 의 값을 step 에 적용합니다.
|
||||
/// </summary>
|
||||
private void StepApply()
|
||||
{
|
||||
var ostep = _step;
|
||||
OldStep = _step; _step = _newstep;
|
||||
StepChanged?.Invoke(this, new StepChangeEventArgs(ostep, _step));
|
||||
} //171214
|
||||
|
||||
/// <summary>
|
||||
/// 메세지 출력옵션을 변경 합니다.
|
||||
/// </summary>
|
||||
/// <param name="opt"></param>
|
||||
/// <param name="value"></param>
|
||||
public void SetMsgOpt(EMsgOpt opt, Boolean value)
|
||||
{
|
||||
byte pos = (byte)opt;
|
||||
if (value)
|
||||
_messageOption = (byte)(_messageOption | (1 << pos));
|
||||
else
|
||||
_messageOption = (byte)(_messageOption & ~(1 << pos));
|
||||
}
|
||||
public void SetMegOptOn() { _messageOption = 0xFF; }
|
||||
public void SetMsgOptOff() { _messageOption = 0; }
|
||||
public Boolean GetMsgOpt(EMsgOpt opt)
|
||||
{
|
||||
byte pos = (byte)opt;
|
||||
return (_messageOption & (1 << pos)) > 0;
|
||||
}
|
||||
public TimeSpan StepRunTime
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsThreadRun == false || bLoop == false || StepStartTime.Year == 1982) return new TimeSpan(0);
|
||||
else return DateTime.Now - StepStartTime;
|
||||
}
|
||||
}
|
||||
|
||||
public Boolean bPause = false;
|
||||
|
||||
/// <summary>
|
||||
/// 상태머신이 실제 동작중인지 확인합니다.
|
||||
/// 검사상태 : Step = Run, IsThreadRun, bPause = false
|
||||
/// </summary>
|
||||
public Boolean IsRun
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Step == eSMStep.RUN && _isthreadrun && bPause == false) return true;
|
||||
else return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
52
Cs_HMI/StateMachine/StateMachine.csproj
Normal file
52
Cs_HMI/StateMachine/StateMachine.csproj
Normal file
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{BBC9BCCF-6262-4355-9CC2-37FF678AC499}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>StateMachine</RootNamespace>
|
||||
<AssemblyName>StateMachine</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="EnumStruct.cs" />
|
||||
<Compile Include="EventArgs.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="StateMachine.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
36
Cs_HMI/StateMachine/_Close.cs
Normal file
36
Cs_HMI/StateMachine/_Close.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Project
|
||||
{
|
||||
public partial class fMain
|
||||
{
|
||||
/// <summary>
|
||||
/// 프로그램을 닫을때 1회 실행되는 함수
|
||||
/// </summary>
|
||||
private void _Close_Start()
|
||||
{
|
||||
if (Pub.plc1 != null) Pub.plc1.Dispose();
|
||||
|
||||
Pub.log.Add("Program Close");
|
||||
Pub.log.Flush();
|
||||
Pub.sm.Stop();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 프로그램종료시 특정상황에 따른 무기한 대기 루틴 이 작업은 close_start 이후에 반복됩니다.
|
||||
/// 모든 조건이 일치하게되면 closed 상태로 호출되어 프로그램이 종료됩니다.
|
||||
/// </summary>
|
||||
//private void _Close_Wait()
|
||||
//{
|
||||
// if (!Pub.dio.isRunIOMonitor && !Pub.mot.isRunIOMonitor)
|
||||
// Pub.sm.setNewStep(eSystemStep.CLOSED);
|
||||
// else if (!Pub.dio.isDisposed) Pub.dio.Dispose();
|
||||
// else if (!Pub.mot.isDisposed) Pub.mot.Dispose(); //181206
|
||||
//}
|
||||
}
|
||||
}
|
||||
106
Cs_HMI/StateMachine/_Flag.cs
Normal file
106
Cs_HMI/StateMachine/_Flag.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Project
|
||||
{
|
||||
public partial class fMain
|
||||
{
|
||||
void gridView2_ItemClick(object sender, arFrame.Control.GridView.ItemClickEventArgs e)
|
||||
{
|
||||
//메인화면 하단의 플래그 상태창에서 클릭된 경우
|
||||
var gv = sender as arFrame.Control.GridView;
|
||||
//var flagIndex = gv.getNameItem(e.idx);
|
||||
//if(flagIndex != "")
|
||||
//{
|
||||
// var fidx = int.Parse(flagIndex);
|
||||
// var flag = (eFlag)fidx;
|
||||
// var curValue = Pub.flag.get(flag);
|
||||
// Pub.flag.set(flag, !curValue);
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
void flag_ValueChanged(object sender, Device.Flag.ValueEventArgs e)
|
||||
{
|
||||
var flag = (eFlag)e.ArrIDX;
|
||||
if (e.ArrIDX >= FlagMapValue.Length) return;
|
||||
var gridItemIndex = FlagMapValue[e.ArrIDX];
|
||||
Pub.log.Add(string.Format("Flag:{0}({2}) Changed = {1}", flag, e.NewValue,e.ArrIDX));
|
||||
if(gridItemIndex != -1)
|
||||
{
|
||||
this.IOState.setValue(gridItemIndex, e.NewValue);
|
||||
this.IOState.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
void dio_Message(object sender, arDev.ProPLC.MemoryAccess.MessageEventArgs e)
|
||||
{
|
||||
if(e.IsError)
|
||||
{
|
||||
Pub.log.Add("ERROR-DIO", e.Message);
|
||||
}
|
||||
else Pub.log.Add("DIO", e.Message);
|
||||
}
|
||||
|
||||
private void Dio_ValueChanged(object sender, arDev.ProPLC.MemoryAccess.IOValueEventArgs e)
|
||||
{
|
||||
var diName = (eDIName)e.ArrIDX;
|
||||
|
||||
if(diName == eDIName.MC_START)
|
||||
{
|
||||
if(e.NewValue ==true)
|
||||
{
|
||||
func_sw_start();
|
||||
}
|
||||
}
|
||||
else if(diName == eDIName.MC_LOTEND)
|
||||
{
|
||||
//lot가 활성화된 경우
|
||||
if(e.NewValue == true)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//throw new NotImplementedException();
|
||||
Console.WriteLine(string.Format("[{1}]{0}=>{2}", diName,e.ArrIDX,e.NewValue));
|
||||
}
|
||||
|
||||
void dio_Message2(object sender, arDev.ProPLC.MemoryAccess.MessageEventArgs e)
|
||||
{
|
||||
if (e.IsError)
|
||||
{
|
||||
Pub.log.Add("ERROR-DIO", e.Message);
|
||||
}
|
||||
else Pub.log.Add("DIO", e.Message);
|
||||
}
|
||||
|
||||
private void Dio_ValueChanged2(object sender, arDev.ProPLC.MemoryAccess.IOValueEventArgs e)
|
||||
{
|
||||
var diName = (eDIName)e.ArrIDX;
|
||||
|
||||
if (diName == eDIName.MC_START)
|
||||
{
|
||||
if (e.NewValue == true)
|
||||
{
|
||||
func_sw_start();
|
||||
}
|
||||
}
|
||||
else if (diName == eDIName.MC_LOTEND)
|
||||
{
|
||||
//lot가 활성화된 경우
|
||||
if (e.NewValue == true)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//throw new NotImplementedException();
|
||||
Console.WriteLine(string.Format("[{1}]{0}=>{2}", diName, e.ArrIDX, e.NewValue));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
323
Cs_HMI/StateMachine/_Loop.cs
Normal file
323
Cs_HMI/StateMachine/_Loop.cs
Normal file
@@ -0,0 +1,323 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using arCtl;
|
||||
using Euresys.Open_eVision_2_11;
|
||||
using static Project.StateMachine;
|
||||
|
||||
namespace Project
|
||||
{
|
||||
|
||||
public partial class fMain
|
||||
{
|
||||
void sm_SPS(object sender, EventArgs e)
|
||||
{
|
||||
//always run
|
||||
_SPS();
|
||||
}
|
||||
|
||||
DateTime lastDeleteTime = DateTime.Now;
|
||||
|
||||
enum EScreen
|
||||
{
|
||||
Auto=0,
|
||||
Manual,
|
||||
IO,
|
||||
Flag
|
||||
}
|
||||
void SetScreen( System.Windows.Forms.Form newscreen)
|
||||
{
|
||||
if(this.InvokeRequired)
|
||||
{
|
||||
this.BeginInvoke(new Action(() => {
|
||||
SetScreen(newscreen);
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(panDlg.Controls.Count > 0)
|
||||
{
|
||||
var f = panDlg.Controls[0] as System.Windows.Forms.Form;
|
||||
if (f.GetType() == newscreen.GetType()) return;
|
||||
}
|
||||
panDlg.Controls.Clear();
|
||||
panDlg.Controls.Add(newscreen);
|
||||
newscreen.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
||||
newscreen.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
||||
newscreen.Show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void sm_Running(object sender, StateMachine.RunningEventArgs e)
|
||||
{
|
||||
|
||||
//main loop
|
||||
switch (e.Step)
|
||||
{
|
||||
case eSMStep.NOTSET:
|
||||
Pub.log.Add("S/M Initialize Start");
|
||||
Pub.sm.setNewStep(eSMStep.INIT);
|
||||
break;
|
||||
|
||||
case eSMStep.INIT: //최초실행이다.
|
||||
if (_SM_RUN_INIT(e.isFirst, Pub.sm.StepRunTime))
|
||||
{
|
||||
//메인화면을 설정한다
|
||||
form_auto = new ViewForm.fAuto();
|
||||
form_manu = new ViewForm.fManual();
|
||||
form_io = new ViewForm.fIO();
|
||||
form_flag = new ViewForm.fFlag();
|
||||
|
||||
form_auto.TopLevel = false;
|
||||
form_manu.TopLevel = false;
|
||||
form_io.TopLevel = false;
|
||||
form_flag.TopLevel = false;
|
||||
form_auto.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
form_manu.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
form_io.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
form_flag.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
|
||||
SetScreen(form_auto);
|
||||
Pub.sm.setNewStep(eSMStep.IDLE);
|
||||
}
|
||||
break;
|
||||
|
||||
case eSMStep.IDLE:
|
||||
|
||||
//창을 닫아야하는 상황에는 처리하지 않는다.
|
||||
if (Pub.popup.needClose)
|
||||
{
|
||||
System.Threading.Thread.Sleep(10); //팝업이 닫힐때까지 기다린다.
|
||||
Pub.sm.WaitFirstRun = true;
|
||||
return;
|
||||
}
|
||||
else Pub.sm.WaitFirstRun = false;
|
||||
|
||||
|
||||
if(e.isFirst)
|
||||
{
|
||||
Pub.sm.bPause = false;
|
||||
Pub.flag.set(eFlag.UserStepCheck, false);
|
||||
Pub.sm.ClearRunStep();
|
||||
// Util_DO.SetMGZMotor(false);
|
||||
lbMsg.ProgressEnable = false;
|
||||
// Pub.popup.needClose = true;
|
||||
}
|
||||
|
||||
//자동소거기능
|
||||
if(Pub.setting.AutoDeleteDay > 0)
|
||||
{
|
||||
if(Pub.flag.get(eFlag.MINSPACE)==true)
|
||||
{
|
||||
var ts = DateTime.Now - lastDeleteTime;
|
||||
if(ts.TotalSeconds > 1)
|
||||
{
|
||||
//파일을 찾아서 소거한다.
|
||||
if (System.IO.Directory.Exists(Pub.path.FullName))
|
||||
DeleteFile(Pub.path.FullName);
|
||||
|
||||
|
||||
lastDeleteTime = DateTime.Now;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case eSMStep.RUN:
|
||||
|
||||
//창을 닫아야하는 상황에는 처리하지 않는다.
|
||||
if (Pub.popup.needClose)
|
||||
{
|
||||
System.Threading.Thread.Sleep(10); //팝업이 닫힐때까지 기다린다.
|
||||
Pub.sm.WaitFirstRun = true;
|
||||
return;
|
||||
}
|
||||
else Pub.sm.WaitFirstRun = false;
|
||||
|
||||
_SM_RUN(e.isFirst, e.StepTime);
|
||||
break;
|
||||
|
||||
case eSMStep.PAUSE:
|
||||
case eSMStep.EMERGENCY:
|
||||
case eSMStep.ERROR:
|
||||
|
||||
|
||||
//창을 닫아야하는 상황에는 처리하지 않는다.
|
||||
if (Pub.popup.needClose)
|
||||
{
|
||||
System.Threading.Thread.Sleep(10); //팝업이 닫힐때까지 기다린다.
|
||||
Pub.sm.WaitFirstRun = true;
|
||||
return;
|
||||
}
|
||||
else Pub.sm.WaitFirstRun = false;
|
||||
|
||||
if (e.isFirst)
|
||||
{
|
||||
|
||||
if (Pub.Result.ResultCode != eResult.NoError)
|
||||
{
|
||||
//에러메세지가 있는 경우에만 표시함
|
||||
if (Pub.Result.ResultMessage != "")
|
||||
Pub.popup.setMessage(Pub.Result.ResultMessage);
|
||||
}
|
||||
if (e.Step == eSMStep.EMERGENCY) Pub.log.AddE("Enter Emergency Step");
|
||||
else if (e.Step == eSMStep.PAUSE) Pub.log.AddE("Enter Pause Step : " + Pub.Result.ResultMessage);
|
||||
else Pub.log.AddE(string.Format("Enter Error Step : {0}", Pub.Result.ResultMessage));
|
||||
Pub.sm.bPause = false;
|
||||
Pub.sm.setNewStep(eSMStep.IDLE);
|
||||
}
|
||||
break;
|
||||
|
||||
case eSMStep.RESET:
|
||||
|
||||
//창을 닫아야하는 상황에는 처리하지 않는다.
|
||||
if (Pub.popup.needClose)
|
||||
{
|
||||
System.Threading.Thread.Sleep(10); //팝업이 닫힐때까지 기다린다.
|
||||
Pub.sm.WaitFirstRun = true;
|
||||
return;
|
||||
}
|
||||
else Pub.sm.WaitFirstRun = false;
|
||||
|
||||
if (e.isFirst)
|
||||
{
|
||||
ClearBarcode();
|
||||
Pub.sm.bPause = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void DeleteFile(string path)
|
||||
{
|
||||
var basetime = DateTime.Now.AddDays(-1 * Pub.setting.AutoDeleteDay);
|
||||
var di = new System.IO.DirectoryInfo(path);
|
||||
if (di.Exists)
|
||||
{
|
||||
var dirYear = di.GetDirectories().OrderBy(t => t.Name).FirstOrDefault();
|
||||
if (dirYear != null)
|
||||
{
|
||||
var dirMon = dirYear.GetDirectories().OrderBy(t => t.Name).FirstOrDefault();
|
||||
if (dirMon != null)
|
||||
{
|
||||
var dirDay = dirMon.GetDirectories().OrderBy(t => t.Name).FirstOrDefault();
|
||||
if (dirDay != null)
|
||||
{
|
||||
var curDay = DateTime.Parse(string.Format("{0}-{1}-{2} 00:00:00", dirYear.ToString(), dirMon.ToString(), dirDay.ToString()));
|
||||
if (curDay < basetime)
|
||||
{
|
||||
var dirLot = dirDay.GetDirectories().OrderBy(t => t.Name).FirstOrDefault();
|
||||
if (dirLot != null)
|
||||
{
|
||||
var delfile = dirLot.GetFiles().FirstOrDefault();
|
||||
if (delfile != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
Pub.log.AddI("Remove Fle : " + delfile.FullName + ",time=" + delfile.LastWriteTime.ToString());
|
||||
delfile.Delete();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Pub.log.AddE("deleete error : " + ex.Message);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string delpath = dirLot.FullName;
|
||||
try
|
||||
{
|
||||
dirLot.Delete(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Pub.log.AddE("remove dir" + ex.Message + "," + delpath);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//이 폴더아래에 다른 폴더가 하나도 없다 즉 비어 있따.
|
||||
string delpath = dirDay.FullName;
|
||||
try
|
||||
{
|
||||
dirDay.Delete(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Pub.log.AddE("remove dir" + ex.Message + "," + delpath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//날짜에 해당하는 폴더가 하나도 없다. 월 폴더를 제거한다.
|
||||
string delpath = dirMon.FullName;
|
||||
try
|
||||
{
|
||||
dirMon.Delete(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Pub.log.AddE("remove dir" + ex.Message + "," + delpath);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//이 달에 해당하는 데이터가 없다. 이 년도를 삭제한다.
|
||||
string delpath = dirYear.FullName;
|
||||
try
|
||||
{
|
||||
dirYear.Delete(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Pub.log.AddE("remove dir" + ex.Message + "," + delpath);
|
||||
}
|
||||
}
|
||||
}
|
||||
//년도별폴더목록을 정리함
|
||||
//가장작은 년도를 기준으로 파일을 검색해서 1개씩 삭제함
|
||||
}
|
||||
}
|
||||
|
||||
void sm_Message(object sender, StateMachine.StateMachineMessageEventArgs e)
|
||||
{
|
||||
//상태머신에서 발생한 메세지
|
||||
Pub.log.Add(e.Header, e.Message);
|
||||
}
|
||||
|
||||
|
||||
void sm_StepChanged(object sender, StateMachine.StepChangeEventArgs e)
|
||||
{
|
||||
//상태머신의 스텝이 변경될때 발생함
|
||||
//Pub.log.Add(string.Format("SM:Step Changed {0} to {1}",e.Old,e.New));
|
||||
}
|
||||
|
||||
//void uploadForm_FormClosed(object sender, System.Windows.Forms.FormClosedEventArgs e)
|
||||
//{
|
||||
// //이벤트 해제
|
||||
// if (uploadForm != null)
|
||||
// uploadForm.FormClosed -= uploadForm_FormClosed;
|
||||
|
||||
// //업로드 창이 닫히면 그 결과를 화면에 표시 해준다.
|
||||
// //foreach (System.Windows.Forms.ListViewItem lv in uploadForm.listView1.Items)
|
||||
// //{
|
||||
// // string slot = lv.SubItems[0].Text;
|
||||
// // string wafer = lv.SubItems[2].Text;
|
||||
// // string state = lv.SubItems[3].Text;
|
||||
|
||||
// //}
|
||||
//}
|
||||
}
|
||||
}
|
||||
353
Cs_HMI/StateMachine/_TMDisplay.cs
Normal file
353
Cs_HMI/StateMachine/_TMDisplay.cs
Normal file
@@ -0,0 +1,353 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using static Project.StateMachine;
|
||||
|
||||
namespace Project
|
||||
{
|
||||
public partial class fMain
|
||||
{
|
||||
private void ColorChangeMotionST(arCtl.arLabel ctl, Color c, Boolean isvalue)
|
||||
{
|
||||
if (isvalue)
|
||||
{
|
||||
int r = c.R + 100;
|
||||
int g = c.G + 100;
|
||||
int b = c.B + 100;
|
||||
if (r > 255) r = 255;
|
||||
if (g > 255) g = 255;
|
||||
if (b > 255) b = 255;
|
||||
if (r < 0) r = 0;
|
||||
if (g < 0) g = 0;
|
||||
if (b < 0) b = 0;
|
||||
ctl.BackColor = Color.FromArgb(r, g, b);
|
||||
ctl.BackColor2 = c;
|
||||
}
|
||||
else
|
||||
{
|
||||
ctl.BackColor = Color.FromArgb(100, 100, 100);
|
||||
ctl.BackColor2 = Color.FromArgb(90, 90, 90);
|
||||
}
|
||||
}
|
||||
|
||||
private void BCDHWStatus(Boolean enable, arCtl.arLabel ctl, bool isReady)
|
||||
{
|
||||
if (enable == false)
|
||||
{
|
||||
ctl.BackColor2 = Color.Gray;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isReady)
|
||||
{
|
||||
ctl.BackColor2 = Color.SeaGreen;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ctl.BackColor2 == Color.Tomato)
|
||||
{
|
||||
ctl.BackColor2 = Color.Gray;
|
||||
}
|
||||
else
|
||||
{
|
||||
ctl.BackColor2 = Color.Tomato;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BlinkHwstatus(int row, int col, int value1, int value2)
|
||||
{
|
||||
var curValue = HWState.getValue(row, col);
|
||||
HWState.setValue(row, col, (byte)(curValue == value1 ? value2 : value1)); //
|
||||
}
|
||||
|
||||
Boolean displayOn = false;
|
||||
private void tmDisplay_Tick(object sender, EventArgs e)
|
||||
{
|
||||
if (displayOn == false) displayOn = true;
|
||||
else
|
||||
{
|
||||
Pub.log.AddAT("Display Timer Overlab");// Console.WriteLine("display overlab");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Pub.sm.Step > eSMStep.INIT &&
|
||||
panTopMenu.Enabled == false) panTopMenu.Enabled = true;
|
||||
|
||||
|
||||
//쓰레드로인해서 메인에서 진행하게한다. SPS는 메인쓰레드에서 진행 됨
|
||||
//팝을 제거 혹은 표시하는 기능
|
||||
if (Pub.popup.needShow) Pub.popup.showMessage();
|
||||
else if (Pub.popup.needClose) Pub.popup.Visible = false; // .setVision(false)();
|
||||
|
||||
lbTime.Text = Pub.sm.UpdateTime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
//상태 표시
|
||||
Update_SSStatus();
|
||||
|
||||
//H/W 상태표시
|
||||
Update_HWStatus();
|
||||
|
||||
//IO상태(상단줄) 표시
|
||||
Update_IOStatus();
|
||||
|
||||
//display mesasge
|
||||
UpdateResultMessage();
|
||||
|
||||
|
||||
//메세지창이 깜박거려야하는 상황 체크
|
||||
if (lbMsg.Tag != null)
|
||||
{
|
||||
var bg1 = lbMsg.BackColor;
|
||||
var bg2 = lbMsg.BackColor2;
|
||||
lbMsg.BackColor = bg2;
|
||||
lbMsg.BackColor2 = bg1;
|
||||
lbMsg.Invalidate();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
HWState.Invalidate();
|
||||
SSInfo.Invalidate();
|
||||
IOState.Invalidate();
|
||||
|
||||
#region retgion"1분 time 루틴"
|
||||
var ts = DateTime.Now - tm1minute;
|
||||
if (ts.TotalMinutes >= 1)
|
||||
{
|
||||
//리셋카운트
|
||||
_AutoResetCount();
|
||||
tm1minute = DateTime.Now;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region retgion"5분 time 루틴"
|
||||
ts = DateTime.Now - tm5minute;
|
||||
if (ts.TotalMinutes >= 5)
|
||||
{
|
||||
//남은디스크확인
|
||||
CheckFreeSpace();
|
||||
tm5minute = DateTime.Now;
|
||||
}
|
||||
#endregion
|
||||
|
||||
//wat.Stop();
|
||||
//Console.WriteLine("disp time : " + wat.ElapsedMilliseconds.ToString() + "ms");
|
||||
displayOn = false;
|
||||
}
|
||||
|
||||
void Update_IOStatus()
|
||||
{
|
||||
int inputrow = 1;
|
||||
int inputcol = 0;
|
||||
IOState.setTitle(inputrow, inputcol, "--"); IOState.setValue(inputrow, inputcol++, (ushort)(Pub.plc1.getValue(7900, (int)eDIName.VS_READY) ? 1 : 0));
|
||||
IOState.setTitle(inputrow, inputcol, "--"); IOState.setValue(inputrow, inputcol++, (ushort)(Pub.plc1.getValue(7900, (int)eDIName.VS_OK) ? 1 : 0));
|
||||
IOState.setTitle(inputrow, inputcol, "--"); IOState.setValue(inputrow, inputcol++, (ushort)(Pub.plc1.getValue(7900, (int)eDIName.VS_ERR) ? 1 : 0));
|
||||
IOState.setTitle(inputrow, inputcol, "--"); IOState.setValue(inputrow, inputcol++, (ushort)(Pub.plc1.getValue(7900, (int)eDIName.VS_COMPLETE) ? 1 : 0));
|
||||
IOState.setTitle(inputrow, inputcol, "--"); IOState.setValue(inputrow, inputcol++, (ushort)(Pub.plc1.getValue(7900, (int)eDIName.VS_LOTEND) ? 1 : 0));
|
||||
IOState.setTitle(inputrow, inputcol, "--"); IOState.setValue(inputrow, inputcol++, 0);
|
||||
|
||||
var numver_mz = Pub.plc1.getValue<UInt16>(7902);
|
||||
var numver_sn = Pub.plc1.getValue<UInt16>(7903);
|
||||
var bin_mz = Convert.ToString(numver_mz, 2).PadLeft(16,'0');
|
||||
var bin_sn = Convert.ToString(numver_sn, 2).PadLeft(16, '0');
|
||||
IOState.setTitle(inputrow, inputcol, "--"); IOState.setValue(inputrow, inputcol++, 0);
|
||||
IOState.setTitle(inputrow, inputcol, "--"); IOState.setValue(inputrow, inputcol++, 0);
|
||||
|
||||
inputrow = 0;
|
||||
inputcol = 0;
|
||||
IOState.setTitle(inputrow, inputcol, "--"); IOState.setValue(inputrow, inputcol++, (ushort)(Pub.plc1.getValue(7900, (int)eDIName.MC_START) ? 1 : 0));
|
||||
IOState.setTitle(inputrow, inputcol, "--"); IOState.setValue(inputrow, inputcol++, 0);
|
||||
IOState.setTitle(inputrow, inputcol, "--"); IOState.setValue(inputrow, inputcol++, 0);
|
||||
IOState.setTitle(inputrow, inputcol, "--"); IOState.setValue(inputrow, inputcol++, (ushort)(Pub.plc1.getValue(7900, (int)eDIName.MC_CONFIRM) ? 1 : 0));
|
||||
IOState.setTitle(inputrow, inputcol, "--"); IOState.setValue(inputrow, inputcol++, (ushort)(Pub.plc1.getValue(7900, (int)eDIName.MC_LOTEND) ? 1 : 0));
|
||||
IOState.setTitle(inputrow, inputcol, "--"); IOState.setValue(inputrow, inputcol++, 0);
|
||||
IOState.setTitle(inputrow, inputcol, "--"); IOState.setValue(inputrow, inputcol++, 0);
|
||||
IOState.setTitle(inputrow, inputcol, "--"); IOState.setValue(inputrow, inputcol++, 0);
|
||||
|
||||
//IOState.setTitle(0, inputcol, "DOOR"); IOState.setValue(0, inputcol++, (ushort)(Util_DO.CheckDoorSafty() ? 1 : 2));
|
||||
//IOState.setTitle(0, inputcol, "SAFTY"); IOState.setValue(0, inputcol++, (ushort)(Pub.flag.get(eFlag.MGZSafty1) && Pub.flag.get(eFlag.MGZSafty2) ? 1 : 2));
|
||||
//IOState.setTitle(0, inputcol, "FULL"); IOState.setValue(0, inputcol++, (ushort)(Util_DO.GetIOInput(eDIName.UD_FULL) ? 2 : 0));
|
||||
|
||||
//IOState.setTitle(0, inputcol, "A/B\nDETECT"); IOState.setValue(0, inputcol++, (ushort)(Util_DO.GetIOInput(eDIName.AB_DETECT) ? 1 : 0));
|
||||
|
||||
}
|
||||
void Update_SSStatus()
|
||||
{
|
||||
SSInfo.setTitle(0, 0, Pub.sm.Step.ToString());
|
||||
SSInfo.setTitle(1, 0, Pub.sm.runStep.ToString());
|
||||
if (Pub.sm.Step == eSMStep.RUN)
|
||||
SSInfo.setTitle(1, 1, string.Format("{0:N1} sec", Pub.sm.getRunSteptime.TotalSeconds));
|
||||
else
|
||||
SSInfo.setTitle(1, 1, "--");
|
||||
|
||||
}
|
||||
void Update_HWStatus()
|
||||
{
|
||||
var rownum = 1;
|
||||
var colIdx = 0;
|
||||
//if (Pub.light.IsInit == false) BlinkHwstatus(rownum, colIdx++, 3, 4);
|
||||
//else HWState.setValue(rownum, colIdx++, (byte)(Pub.light.IsInit ? 2 : 3)); //
|
||||
|
||||
if (Pub.plc1.IsValid == false) BlinkHwstatus(rownum, colIdx++, 3, 4);
|
||||
else HWState.setValue(rownum, colIdx++, (byte)(Pub.plc1.IsValid ? 2 : 3)); //PLC
|
||||
|
||||
if (Pub.Xbee.IsInit == false) BlinkHwstatus(rownum, colIdx++, 3, 4);
|
||||
else HWState.setValue(rownum, colIdx++, (byte)(Pub.Xbee.IsInit ? 2 : 3)); //
|
||||
|
||||
//if (Pub.camera.IsInit == false) BlinkHwstatus(rownum, colIdx++, 3, 4);
|
||||
//else HWState.setValue(rownum, colIdx++, (byte)(Pub.camera.IsInit ? 2 : 3)); //
|
||||
|
||||
//if (Pub.bVisionLicense == false) BlinkHwstatus(rownum, colIdx++, 3, 4);
|
||||
//else HWState.setValue(rownum, colIdx++, (byte)(Pub.bVisionLicense ? 2 : 3)); //
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 환경설정에따른 카운트를 리셋처리한다. 171128
|
||||
/// </summary>
|
||||
void _AutoResetCount()
|
||||
{
|
||||
if (Pub.setting.datetime_Check_1 && Pub.setting.datetime_Reset_1 != "") //오전
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime SetTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " " + Pub.setting.datetime_Reset_1 + ":00");
|
||||
DateTime LastClearTime = Pub.counter.CountReset;
|
||||
|
||||
//현재 시간이 클리어대상 시간보다 크고, 마지막으로 클리어한 시간이 지정시간보다 작아야함
|
||||
if (DateTime.Now > SetTime && LastClearTime < SetTime)
|
||||
{
|
||||
Pub.log.AddI("Count Reset #1");
|
||||
Pub.counter.CountClear();
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
if (Pub.setting.datetime_Check_2 && Pub.setting.datetime_Reset_2 != "") //오후
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime SetTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " " + Pub.setting.datetime_Reset_2 + ":00");
|
||||
DateTime LastClearTime = Pub.counter.CountReset;
|
||||
|
||||
//현재 시간이 클리어대상 시간보다 크고, 마지막으로 클리어한 시간이 지정시간보다 작아야함
|
||||
if (DateTime.Now > SetTime && LastClearTime < SetTime)
|
||||
{
|
||||
Pub.log.AddI("Count Reset #2");
|
||||
Pub.counter.CountClear();
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
|
||||
DateTime tm1minute = DateTime.Now.AddDays(-1);
|
||||
DateTime tm5minute = DateTime.Now;
|
||||
|
||||
void UpdateProgressStatus(string title, double value, double max)
|
||||
{
|
||||
UpdateProgressStatus((float)value, (float)max, title);
|
||||
}
|
||||
|
||||
void UpdateProgressStatus(float value, float max, string title)
|
||||
{
|
||||
if (lbMsg.ProgressEnable == false) lbMsg.ProgressEnable = true;
|
||||
if (lbMsg.ProgressMax != max) lbMsg.ProgressMax = max;
|
||||
if (lbMsg.ProgressValue != value) lbMsg.ProgressValue = value;
|
||||
if (lbMsg.ProgressForeColor != Color.FromArgb(40, 40, 40))
|
||||
lbMsg.ProgressForeColor = Color.FromArgb(40, 40, 40);
|
||||
if (lbMsg.Text != title) lbMsg.Text = title;
|
||||
}
|
||||
|
||||
void UpdateStatusMessage(string dispmsg, Color fcolor, Color shadow)
|
||||
{
|
||||
UpdateStatusMessage(dispmsg, Color.DimGray, Color.Gray, fcolor, shadow);
|
||||
}
|
||||
|
||||
void UpdateStatusMessage(string dispmsg, Color bColor, Color bColor2, Color fcolor, Color shadow, Boolean blank = false)
|
||||
{
|
||||
|
||||
//if (lbMsg.ProgressEnable == true) lbMsg.ProgressEnable = false;
|
||||
if (dispmsg != lbMsg.Text || lbMsg.ForeColor != fcolor || lbMsg.ShadowColor != shadow || (lbMsg.BackColor != bColor && lbMsg.BackColor2 != bColor))
|
||||
{
|
||||
lbMsg.BackColor = bColor;
|
||||
lbMsg.BackColor2 = bColor2;
|
||||
lbMsg.ForeColor = fcolor;
|
||||
lbMsg.ShadowColor = shadow;
|
||||
lbMsg.Text = dispmsg;
|
||||
if (blank) lbMsg.Tag = "BLANK";
|
||||
else lbMsg.Tag = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void UpdateResultMessage()
|
||||
{
|
||||
//모션을 사용한다면 홈 검색여부를 확인한다.
|
||||
|
||||
//var inspresult = "";
|
||||
//if (Pub.Result == null || Pub.Result.Result == CResult.eInspectResult.NOTSET)
|
||||
// inspresult = "--";
|
||||
//else if (Pub.Result.Result == CResult.eInspectResult.OK)
|
||||
// inspresult = "MATCH";
|
||||
//else if (Pub.Result.Result == CResult.eInspectResult.NG)
|
||||
// inspresult = "MISMATCH";
|
||||
|
||||
|
||||
//최우선 점검 사항 표시
|
||||
if (Pub.sm.Step > eSMStep.INIT)
|
||||
{
|
||||
if (Pub.flag.get(eFlag.DemoRun))
|
||||
{
|
||||
UpdateStatusMessage("DEMO RUN", Color.Gold, Color.Yellow, Color.Black, Color.WhiteSmoke, true);
|
||||
}
|
||||
|
||||
|
||||
else if (Pub.flag.get(eFlag.START) == true)
|
||||
{
|
||||
UpdateStatusMessage("매거진투입구 안전센서 감지", Color.Tomato, Color.Black);
|
||||
}
|
||||
else if (Pub.Result.Model.Title == "")
|
||||
{
|
||||
UpdateStatusMessage("비젼모델 선택이 필요함", Color.Tomato, Color.Black);
|
||||
}
|
||||
|
||||
if (Pub.sm.Step == eSMStep.IDLE)
|
||||
{
|
||||
UpdateStatusMessage("준비완료", Color.Lime, Color.Black);
|
||||
}
|
||||
else if (Pub.sm.Step == eSMStep.ERROR)
|
||||
{
|
||||
UpdateStatusMessage("오류 발생", Color.Red, Color.Black);
|
||||
}
|
||||
else if (Pub.sm.Step == eSMStep.PAUSE)
|
||||
{
|
||||
UpdateStatusMessage("정지 됨", Color.Tomato, Color.Black);
|
||||
}
|
||||
else if (Pub.sm.Step == eSMStep.FINISH)
|
||||
UpdateStatusMessage("작업 완료", Color.Lime, Color.Black);
|
||||
else if (Pub.sm.bPause == true)
|
||||
{
|
||||
UpdateStatusMessage("[START]를 누르면 시작 됩니다", Color.Yellow, Color.Black);
|
||||
}
|
||||
else if (Pub.flag.get(eFlag.TestRun))
|
||||
{
|
||||
UpdateStatusMessage("TEST RUN", Color.DeepSkyBlue, Color.LightSkyBlue, Color.Blue, Color.WhiteSmoke, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
string msg = "진행중";
|
||||
UpdateStatusMessage(msg, Color.Lime, Color.Black);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user