IT Story/C# & WPF
SECS S1F15 and S1F17 processing example source
Hoyami7
2022. 7. 3. 17:34
반응형
/// <summary>
/// Host로부터 Offline 요청을 받는다.
/// </summary>
/// <remarks>2006/11/01 [Ver 00]</remarks>
private void PSecsDrv_S1F15()
{
try
{
this.m_Info.Set_ReceiveHostSF("S1F15");
}
catch (Exception ex)
{
this.m_Info.Set_Log(Common.EnuCommon.LogType.CIM, "", ex.ToString());
}
}
private void S1F15()
{
int dintACK = 0;
try
{
//subReplyTrue(); //Reply가 들어왔음을 저장
if (this.m_Info.All.HostConnect == false) return;
if (this.m_Info.All.ControlState == Structure.classStructure.ControlState.OFFLINE)
{
dintACK = 2; //2 = Equipment Already Offline
}
else
{
dintACK = 0; //0 = Offline Accepted
m_Info.All.ControlStateChangeBYWHO = Structure.classStructure.BYWHO.ByHost; //By HOST
m_Info.All.ControlStateOLD = m_Info.All.ControlState; //현재의 ControlState를 백업
m_Info.All.ControlState = Structure.classStructure.ControlState.OFFLINE;
m_Info.All.WantControlState = Structure.classStructure.ControlState.OFFLINE; //초기화
this.m_Info.Set_PLCCommand(Structure.classStructure.PLCCommand.ControlState, (int)this.m_Info.All.ControlState); //PLC로 현재 ControlState 를 써준다.
//HOST로 Online 변경 보고를 한다.(S6F11, CEID=72(Local), CEID=73(Remote))
this.m_Info.Set_SendSF(Structure.classStructure.SFName.S6F11EQPEventRequest, 71, 0, 0); //뒤에 0은 전체장비를 의미
}
//HOST로 S1F16응답
this.PSecsDrv.S1F16.OFLACK = dintACK;
this.PSecsDrv.S1F16.Reply(this.PSecsDrv.S1F15.Header);
}
catch (Exception ex)
{
this.m_Info.Set_Log(Common.EnuCommon.LogType.CIM, "", ex.ToString());
}
}
/// <summary>
/// Host로부터 On line 확인 Stream Function을 수신시
/// On line Data를 송신 한다.(S1F1수신 후 S1F2 송신)
/// </summary>
/// <remarks>2006/11/01 [Ver 00]</remarks>
private void PSecsDrv_S1F17()
{
try
{
this.m_Info.Set_ReceiveHostSF("S1F17");
}
catch (Exception ex)
{
this.m_Info.Set_Log(Common.EnuCommon.LogType.CIM, "", ex.ToString());
}
}
private void S1F17()
{
int dintCEID = 0;
string dstrMCMD = string.Empty;
int dintACK = 0;
try
{
//subReplyTrue(); //Reply가 들어왔음을 저장
if (this.m_Info.All.HostConnect == false) return;
dstrMCMD = this.PSecsDrv.S1F17.MCMD.ToString();
if (dstrMCMD == "1" && this.m_Info.All.ControlState == Structure.classStructure.ControlState.ONLINEREMOTE)
{
this.PSecsDrv.S1F18.ONLACK = 2; //2 = Equipment Already ON_LINE REMOTE
this.PSecsDrv.S1F18.Reply(this.PSecsDrv.S1F17.Header);
return;
}
if (dstrMCMD == "2" && this.m_Info.All.ControlState == Structure.classStructure.ControlState.ONLINELOCAL)
{
this.PSecsDrv.S1F18.ONLACK = 5; //6 = Equipment Already ON_LINE LOCAL
this.PSecsDrv.S1F18.Reply(this.PSecsDrv.S1F17.Header);
return;
}
switch (dstrMCMD)
{
case "1": //Remote
//if (m_Info.All.AutoMode == true)
//{
// dintACK = 0;
// dintCEID = 73;
//}
//else
//{
// dintACK = 1; //1 = ON_LINE REMOTE Not Allowed.
//}
m_Info.All.WantControlState = Structure.classStructure.ControlState.ONLINEREMOTE;
dintACK = 0;
dintCEID = 73;
break;
//case "2": //Local
// //if (m_Info.All.AutoMode == true)
// //{
// // dintACK = 3;
// // dintCEID = 72;
// //}
// //else
// //{
// // dintACK = 5; //5 = ON_LINE LOCAL Not Allowed.
// //}
// m_Info.All.WantControlState = Structure.classStructure.ControlState.ONLINELOCAL;
// dintACK = 3;
// dintCEID = 72;
// break;
default:
dintACK = 8; //틀린 MCMD가 온경우
break;
}
//S1F18보고
this.PSecsDrv.S1F18.ONLACK = dintACK;
this.PSecsDrv.S1F18.Reply(this.PSecsDrv.S1F17.Header);
//Local, Remote로 변환 성공시 PLC에 써주고 HOST로 변경보고를 한다.
if ((dintACK == 0 || dintACK == 3) && (dstrMCMD == "1" || dstrMCMD == "2"))
{
m_Info.All.ControlStateChangeBYWHO = Structure.classStructure.BYWHO.ByHost; //By HOST
m_Info.All.ControlStateOLD = m_Info.All.ControlState; //현재의 ControlState를 백업
m_Info.All.ControlState = m_Info.All.WantControlState;
m_Info.All.WantControlState = Structure.classStructure.ControlState.UNKNOWN; //초기화
this.m_Info.Set_PLCCommand(Structure.classStructure.PLCCommand.ControlState, (int)this.m_Info.All.ControlState); //PLC로 현재 ControlState 를 써준다.
//HOST로 Online 변경 보고를 한다.(S6F11, CEID=72(Local), CEID=73(Remote))
this.m_Info.Set_SendSF(Structure.classStructure.SFName.S6F11EQPEventRequest, dintCEID, 0, 0); //뒤에 0은 전체장비를 의미
}
}
catch (Exception ex)
{
this.m_Info.Set_Log(Common.EnuCommon.LogType.CIM, "", ex.ToString());
}
}
반응형