This commit is contained in:
chi
2025-04-24 11:51:55 +09:00
parent 0a93a54a6f
commit f71b963851
62 changed files with 1748 additions and 4105 deletions

View File

@@ -41,6 +41,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MSSQLCommand", "SubProject\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "arCommUtil", "SubProject\CommUtil\arCommUtil.csproj", "{14E8C9A5-013E-49BA-B435-FFFFFF7DD623}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ENIGProtocol", "..\..\Protocol\enigprotocol\ENIGProtocol.csproj", "{16BD025D-CB0F-4A4B-A452-8FE629F02F0C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -248,6 +250,18 @@ Global
{14E8C9A5-013E-49BA-B435-FFFFFF7DD623}.Release|x64.Build.0 = Release|Any CPU
{14E8C9A5-013E-49BA-B435-FFFFFF7DD623}.Release|x86.ActiveCfg = Release|x86
{14E8C9A5-013E-49BA-B435-FFFFFF7DD623}.Release|x86.Build.0 = Release|x86
{16BD025D-CB0F-4A4B-A452-8FE629F02F0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{16BD025D-CB0F-4A4B-A452-8FE629F02F0C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{16BD025D-CB0F-4A4B-A452-8FE629F02F0C}.Debug|x64.ActiveCfg = Debug|Any CPU
{16BD025D-CB0F-4A4B-A452-8FE629F02F0C}.Debug|x64.Build.0 = Debug|Any CPU
{16BD025D-CB0F-4A4B-A452-8FE629F02F0C}.Debug|x86.ActiveCfg = Debug|Any CPU
{16BD025D-CB0F-4A4B-A452-8FE629F02F0C}.Debug|x86.Build.0 = Debug|Any CPU
{16BD025D-CB0F-4A4B-A452-8FE629F02F0C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{16BD025D-CB0F-4A4B-A452-8FE629F02F0C}.Release|Any CPU.Build.0 = Release|Any CPU
{16BD025D-CB0F-4A4B-A452-8FE629F02F0C}.Release|x64.ActiveCfg = Release|Any CPU
{16BD025D-CB0F-4A4B-A452-8FE629F02F0C}.Release|x64.Build.0 = Release|Any CPU
{16BD025D-CB0F-4A4B-A452-8FE629F02F0C}.Release|x86.ActiveCfg = Release|Any CPU
{16BD025D-CB0F-4A4B-A452-8FE629F02F0C}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -267,6 +281,7 @@ Global
{EB77976F-4DE4-46A5-8B25-D07226204C32} = {7AF32085-E7A6-4D06-BA6E-C6B1EBAEA99A}
{AAF68D20-4590-4AB0-BB91-E0DD04C91DEC} = {C423C39A-44E7-4F09-B2F7-7943975FF948}
{14E8C9A5-013E-49BA-B435-FFFFFF7DD623} = {C423C39A-44E7-4F09-B2F7-7943975FF948}
{16BD025D-CB0F-4A4B-A452-8FE629F02F0C} = {C423C39A-44E7-4F09-B2F7-7943975FF948}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B5B1FD72-356F-4840-83E8-B070AC21C8D9}

View File

@@ -158,7 +158,10 @@
<DependentUpon>DataSet1.xsd</DependentUpon>
</Compile>
<Compile Include="Device\CFlag.cs" />
<Compile Include="Device\Xbee.cs" />
<Compile Include="Device\Xbee _OLD.cs" />
<Compile Include="Device\Xbee.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Device\Socket.cs" />
<Compile Include="Dialog\fCounter.cs">
<SubType>Form</SubType>
@@ -492,6 +495,10 @@
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Protocol\enigprotocol\ENIGProtocol.csproj">
<Project>{16bd025d-cb0f-4a4b-a452-8fe629f02f0c}</Project>
<Name>ENIGProtocol</Name>
</ProjectReference>
<ProjectReference Include="..\SubProject\AGVControl\agvControl.csproj">
<Project>{8cb883c0-99c3-4dd4-b017-f9b92010a806}</Project>
<Name>agvControl</Name>

View File

@@ -92,8 +92,8 @@ namespace Project
[Category("Commnunication Setting"), DisplayName("RFID PortName"), Editor(typeof(MyUITypeEditor), typeof(UITypeEditor))]
public string Port_AGV { get; set; }
[Category("Commnunication Setting"), DisplayName("PLC #1 PortName"), Editor(typeof(MyUITypeEditor), typeof(UITypeEditor))]
public string Port_PLC { get; set; }
[Category("Commnunication Setting"), DisplayName("Xbee ID"), Editor(typeof(MyUITypeEditor), typeof(UITypeEditor))]
public byte XBE_ID { get; set; }
[Category("Commnunication Setting"), DisplayName("BMS PortName"), Editor(typeof(MyUITypeEditor), typeof(UITypeEditor))]
@@ -103,7 +103,7 @@ namespace Project
public int Baud_AGV { get; set; }
public int Baud_BAT { get; set; }
public int Baud_PLC { get; set; }
//public int Baud_PLC { get; set; }
public int Baud_XBE { get; set; }
//public int QueryInterval_BAT { get; set; }
@@ -284,7 +284,7 @@ namespace Project
//public Single interval_bms { get; set; }
public Single interval_xbe { get; set; }
public int interval_bms { get; set; }
public byte interval_iostate { get; set; }
//public byte interval_iostate { get; set; }
//public Boolean Enable_AutoZDnUp { get; set; }
public int doorSoundTerm { get; set; }
public int musicvol { get; set; }
@@ -378,7 +378,7 @@ namespace Project
if (ChargeSearchTime == 0) ChargeSearchTime = 25;
//최대 충전진행 시간(기본 1시간)
if (ChargeMaxTime == 0) ChargeMaxTime = 3600;
if (interval_iostate == 0 || interval_iostate == 255) interval_iostate = 100;
// if (interval_iostate == 0 || interval_iostate == 255) interval_iostate = 100;
if (ZSpeed == 0) ZSpeed = 20;
if (interval_xbe == 0) interval_xbe = 5.0f;
if (HomePositionValue == 0) HomePositionValue = 4;
@@ -418,12 +418,12 @@ namespace Project
if (string.IsNullOrEmpty(Port_AGV)) Port_AGV = "COM1";
if (string.IsNullOrEmpty(Port_PLC)) Port_PLC = "COM2";
// if (string.IsNullOrEmpty(Port_PLC)) Port_PLC = "COM2";
if (string.IsNullOrEmpty(Port_XBE)) Port_XBE = "COM4";
if (string.IsNullOrEmpty(Port_BAT)) Port_BAT = "COM7";
if (Baud_AGV == 0) Baud_AGV = 57600;
if (Baud_PLC == 0) Baud_PLC = 19200;
//if (Baud_PLC == 0) Baud_PLC = 19200;
if (Baud_XBE == 0) Baud_XBE = 9600;
if (Baud_BAT == 0) Baud_BAT = 9600;

View File

@@ -9,6 +9,7 @@ using System.Text;
using System.Windows.Forms;
using COMM;
using System.Diagnostics;
using AR;
namespace Project
{
@@ -42,7 +43,7 @@ namespace Project
#endregion
public arDev.BMS dev_bms { private get; set; } = null;
public arDev.FakePLC dev_plc { private get; set; } = null;
// public arDev.FakePLC dev_plc { private get; set; } = null;
public arDev.Narumi dev_agv { private get; set; } = null;
public Device.Xbee dev_xbe { private get; set; } = null;
@@ -124,7 +125,6 @@ namespace Project
this.Invalidate();
}
}
public Color BorderColor { get; set; }
private int _itemgap = 0;
public int ItemGap { get { return _itemgap; } set { _itemgap = value; Invalidate(); } }
@@ -138,8 +138,8 @@ namespace Project
{
get
{
if (COMM.VAR.BOOL == null) return true;
else return COMM.VAR.BOOL[eVarBool.FLAG_AUTORUN];
if (VAR.BOOL == null) return true;
else return VAR.BOOL[eVarBool.FLAG_AUTORUN];
}
}
@@ -488,7 +488,7 @@ namespace Project
//상태메세지표시
string stmsg = string.Empty;
if (COMM.VAR.STR != null && COMM.VAR.STR[eVarString.StatusMessage].isEmpty() == false) stmsg = VAR.STR[eVarString.StatusMessage];
if (VAR.STR != null && VAR.STR[eVarString.StatusMessage].isEmpty() == false) stmsg = VAR.STR[eVarString.StatusMessage];
else stmsg = "STATUS MESSAGE DEMO";
if (nextstop) stmsg += "|MARK-STOP";
@@ -665,39 +665,39 @@ namespace Project
}
public bool LimitLU
{
get
{
if (dev_plc == null) return true;
return dev_plc.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_LU);
}
//public bool LimitLU
//{
// get
// {
// if (dev_plc == null) return true;
// return dev_plc.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_LU);
// }
}
public bool LimitLD
{
get
{
if (dev_plc == null) return false;
return dev_plc.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_LD);
}
}
public bool LimitRU
{
get
{
if (dev_plc == null) return false;
return dev_plc.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_RU);
}
}
public bool LimitRD
{
get
{
if (dev_plc == null) return true;
return dev_plc.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_RD);
}
}
//}
//public bool LimitLD
//{
// get
// {
// if (dev_plc == null) return false;
// return dev_plc.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_LD);
// }
//}
//public bool LimitRU
//{
// get
// {
// if (dev_plc == null) return false;
// return dev_plc.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_RU);
// }
//}
//public bool LimitRD
//{
// get
// {
// if (dev_plc == null) return true;
// return dev_plc.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_RD);
// }
//}
void DrawMC(Graphics g)
{
@@ -794,11 +794,11 @@ namespace Project
var coverLYOffset = 0;
var coverRYOffset = 0;
if (LimitRD == true) coverRYOffset = 20;
else if (LimitRU == true) coverRYOffset = coverYOffset;
//if (LimitRD == true) coverRYOffset = 20;
//else if (LimitRU == true) coverRYOffset = coverYOffset;
if (LimitLD == true) coverLYOffset = 20;
else if (LimitLU == true) coverLYOffset = coverYOffset;
//if (LimitLD == true) coverLYOffset = 20;
//else if (LimitLU == true) coverLYOffset = coverYOffset;
var PtsCoverBack = new PointF[] {
new PointF( PtsBack[0].X+coverPadding, PtsBack[0].Y+coverLYOffset ),
@@ -814,17 +814,17 @@ namespace Project
new PointF( PtsFront[3].X+coverPadding, PtsFront[3].Y+coverRYOffset )
};
if (LimitLU == true)
{
g.FillPolygon(new SolidBrush(Color.FromArgb(100, Color.Red)), PtsCoverBack);
g.DrawPolygon(new Pen(Color.DarkRed, 2), PtsCoverBack);
}
else if (LimitLD == true)
{
g.FillPolygon(new SolidBrush(Color.FromArgb(100, Color.Blue)), PtsCoverBack);
g.DrawPolygon(new Pen(Color.DarkBlue, 2), PtsCoverBack);
}
else
//if (LimitLU == true)
//{
// g.FillPolygon(new SolidBrush(Color.FromArgb(100, Color.Red)), PtsCoverBack);
// g.DrawPolygon(new Pen(Color.DarkRed, 2), PtsCoverBack);
//}
//else if (LimitLD == true)
//{
// g.FillPolygon(new SolidBrush(Color.FromArgb(100, Color.Blue)), PtsCoverBack);
// g.DrawPolygon(new Pen(Color.DarkBlue, 2), PtsCoverBack);
//}
//else
{
g.FillPolygon(new SolidBrush(Color.FromArgb(100, Color.Gray)), PtsCoverBack);
g.DrawPolygon(Pens.DimGray, PtsCoverBack);
@@ -835,17 +835,17 @@ namespace Project
g.FillPolygon(new SolidBrush(Color.FromArgb(50, Color.White)), PtsFront);
// g.DrawPolygon(Pens.Black, PtsFront);
if (LimitRU == true)
{
g.FillPolygon(new SolidBrush(Color.FromArgb(150, Color.Red)), PtsCoverFront);
g.DrawPolygon(new Pen(Color.DarkRed, 2), PtsCoverFront);
}
else if (LimitRD == true)
{
g.FillPolygon(new SolidBrush(Color.FromArgb(150, Color.Blue)), PtsCoverFront);
g.DrawPolygon(new Pen(Color.DarkBlue, 2), PtsCoverFront);
}
else
//if (LimitRU == true)
//{
// g.FillPolygon(new SolidBrush(Color.FromArgb(150, Color.Red)), PtsCoverFront);
// g.DrawPolygon(new Pen(Color.DarkRed, 2), PtsCoverFront);
//}
//else if (LimitRD == true)
//{
// g.FillPolygon(new SolidBrush(Color.FromArgb(150, Color.Blue)), PtsCoverFront);
// g.DrawPolygon(new Pen(Color.DarkBlue, 2), PtsCoverFront);
//}
//else
{
g.FillPolygon(new SolidBrush(Color.FromArgb(150, Color.Gray)), PtsCoverFront);
g.DrawPolygon(Pens.DimGray, PtsCoverFront);

View File

@@ -0,0 +1,402 @@
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.ComponentModel;
//using System.Threading;
//using COMM;
//using System.Runtime.Remoting.Messaging;
//using AR;
//namespace Project.Device
//{
// public class Xbee_OLD : arDev.arRS232
// {
// public Xbee_OLD()
// {
// }
// public string buffer = string.Empty;
// public System.Text.StringBuilder newbuffer = new StringBuilder();
// protected override bool CustomParser(byte[] buf, out byte[] remainBuffer)
// {
// //일반 kit 명령은 0x02 kit번호, kit값 0x03
// //상태 명령은 0x04 메세지데이터 0x05
// Console.WriteLine("custom parse len=" + buf.Length.ToString());
// List<byte> sparebuffer = new List<byte>();
// Boolean bComplete = false;
// for (int i = 0; i < buf.Length; i++)
// {
// var incomByte = buf[i];
// if (bComplete == true) sparebuffer.Add(incomByte);
// else
// {
// if (findSTX == false)
// {
// if (incomByte != 0x02)
// {
// //버리는데이터
// }
// else
// {
// findSTX = true;
// tempBuffer.Clear();
// tempBuffer.Add(incomByte);
// }
// }
// else
// {
// tempBuffer.Add(incomByte);
// if (incomByte == 0x03)
// {
// //데이터가 맞게 수신됨
// LastReceiveBuffer = tempBuffer.ToArray();
// bComplete = true;
// findSTX = false;
// }
// else if (tempBuffer.Count > 30)
// {
// tempBuffer.Clear();
// findSTX = false;
// }
// }
// }
// }
// remainBuffer = sparebuffer.ToArray();
// return bComplete;
// }
// public override bool ProcessRecvData(byte[] data)
// {
// var kitno = (char)(data[1]);
// var kitval = (char)(data[2]);
// NewMsgEvent(kitno, kitval);
// return true;
// }
// public void NewMsgEvent(char kitNo, char kitVal)
// {
// //대상위치 확인
// ePosition kitPos = ePosition.NONE;
// if (kitNo == '9') kitPos = ePosition.QC;
// else if (kitNo == '1') kitPos = ePosition.F1;
// else if (kitNo == '2') kitPos = ePosition.F2;
// else if (kitNo == '3') kitPos = ePosition.F3;
// else if (kitNo == '4') kitPos = ePosition.F4;
// else
// {
// if (kitNo == '0') return;
// PUB.log.Add($"비허가 키트번호 무시 번호={kitNo},값={kitVal}");
// return;
// }
// //if (kitNo= 'F')
// //{
// // PUB.Speak("알 수 없는 키트번호 입니다");
// // PUB.logsys.Add($"키트번호별위치확인실패 값={kitNo}");
// // return;
// //}
// //(ePosition)int.Parse(kitNo.ToString());
// PUB.logxbee.Add(string.Format("Xbee:newMsgEvent:{0},{1}=>{2}", kitNo, kitVal, kitPos));
// if (PUB.CheckManualChargeMode() == false)
// {
// PUB.log.Add($"수동 충전 중이라 콜 기능을 취소 합니다");
// return;
// }
// bool FixButton = kitPos == ePosition.NONE;
// if (kitPos == ePosition.NONE)
// {
// if (kitVal == '1') kitPos = ePosition.QC;
// else if (kitVal == '2') kitPos = ePosition.CHARGE;
// else if (kitVal == '4') kitPos = ePosition.QC;
// //else if (kitVal == '3') kitPos = ePosition.QA;
// else
// {
// PUB.log.Add($"AGV버튼 이벤트 실행 값:{kitVal} 취소");
// return;
// }
// kitVal = '1'; //버튼은 무조건 ON상태로 한다
// }
// //자동상태가 아니라면 오류처리
// if (VAR.BOOL[eVarBool.FLAG_AUTORUN] == false || PUB.sm.Step != StateMachine.eSMStep.RUN)
// {
// PUB.log.AddE("'자동실행' 상태가 아니므로 콜/취소 작업을 할 수 없습니다 콜:" + kitPos.ToString() + ",값=" + kitVal.ToString());
// PUB.Speak(Lang.자동운전상태가아닙니다);
// return;
// }
// //충전기를 제외하고 '1'의 값은 호출을 원하는값이다.('0'=취소)
// if (kitVal == '1')
// {
// //qA혹은 Pack 에서 해당 버튼을 눌렀을때의 처리방법
// //if (PUB.Result.CurrentPos == ePosition.QA && kitPos == ePosition.QA)
// //{
// // PUB.logsys.AddE("QA위치에서 QA버튼을 눌렀음 명령 취소함");
// // PUB.Speak("현재 위치는 QA 입니다.");
// // return;
// //}
// //상/하차 작업중이 아니라면 콜을 받는다
// if (PUB.sm.RunStep != StateMachine.ERunStep.GOUP && PUB.sm.RunStep != StateMachine.ERunStep.GODOWN)
// {
// //call을 받으려면 대상위 (2=QC,3,4,5,6,7)
// //콜을 요청하는 곳 (2=QC,3=FVI-1,4,5,6,7==FVI-5)
// //1번은 충전기
// //콜버튼으로 대상위치를 다시 결정한다.
// //대상번호는 콜번호에서 +2을 하면 된다.
// //대상번호 PK=1,QA2=2,QA1=3,QC=4
// //QC의경우 콜Kit번호는 2이므로, 이동대상은 +2인 4가 되어야 함
// //콜번호와 RFID대상번호는 2의 오차가 발생함, 현재 설치된 RFID를 모두 변경할 수 없어서 이렇게 운용함
// RaiseMessage(MessageType.Normal, string.Format("CALL확정 Kit={0},대상위치={1}", kitNo, kitPos));
// PUB.AGV.data.CallNo = int.Parse(kitNo.ToString());
// PUB.AGV.data.CallString = kitNo.ToString();
// PUB.Result.CommandKit = kitNo;
// PUB.Result.TargetPos = kitPos;
// SendToKit(kitNo, '1', (PUB.IsCanCALL() ? '1' : '0')); //콜확정을 클라이언트에 알림
// PUB.Speak(kitPos.ToString() + Lang.위치로이동합니다);
// //상태머신을 변경한다 (충전 OFF상태로 간다, 충전상태가 아니면 바로 이동하게됨)
// //Pub.sm.ResetRunStep();
// //Pub.sm.setNewStep(StateMachine.eSMStep.RUN);
// //qa, pack 은 하차 전용이다
// PUB.sm.ClearRunStep();
// PUB.sm.SetNewRunStep(StateMachine.ERunStep.GOUP);
// PUB.sm.SetNewStep(StateMachine.eSMStep.RUN);
// }
// else if (PUB.sm.RunStep == StateMachine.ERunStep.GODOWN && VAR.BOOL[eVarBool.WAIT_COVER_DOWN] == false && VAR.BOOL[eVarBool.WAIT_COVER_UP] == false)
// {
// //하차중에 받을 수 있게하자 (단 FVi1 이하일때에는 무시하자) 230710 - 김수곤
// if (PUB.Result.TargetPos == ePosition.QC && PUB.Result.CurrentPos < ePosition.F1)
// {
// PUB.log.Add($"하차중이지만 FVI #1 아래에 있으니 콜을 취소 합니다");
// SendToKit(kitNo, '0', '0');
// RaiseMessage(MessageType.Normal, $"QC 추가 콜이지만 위치가 #1번 이하이므로 취소 됩니다. Kit={kitNo},현재={PUB.Result.CurrentPos},대상={PUB.Result.TargetPos}");
// }
// else
// {
// RaiseMessage(MessageType.Normal, string.Format("CALL확정(추가) Kit={0},대상위치={1}", kitNo, kitPos));
// PUB.AGV.data.CallNo = int.Parse(kitNo.ToString());
// PUB.AGV.data.CallString = kitNo.ToString();
// PUB.Result.CommandKit = kitNo;
// PUB.Result.TargetPos = kitPos;
// SendToKit(kitNo, '1', (PUB.IsCanCALL() ? '1' : '0')); //콜확정을 클라이언트에 알림
// PUB.Speak(kitPos.ToString() + Lang.위치로이동합니다);
// //상태머신을 변경한다 (충전 OFF상태로 간다, 충전상태가 아니면 바로 이동하게됨)
// //Pub.sm.ResetRunStep();
// //Pub.sm.setNewStep(StateMachine.eSMStep.RUN);
// //qa, pack 은 하차 전용이다
// PUB.sm.ClearRunStep();
// PUB.sm.SetNewRunStep(StateMachine.ERunStep.GOUP);
// PUB.sm.SetNewStep(StateMachine.eSMStep.RUN);
// }
// }
// //else if (PUB.sm.RunStep == StateMachine.ERunStep.GODOWN && PUB.Result.CurrentPos == ePosition.QA)
// //{
// // RaiseMessage(MessageType.Normal, string.Format("CALL확정 Kit={0},대상위치={1}", kitNo, kitPos));
// // PUB.Result.CommandKit = kitNo;
// // PUB.Result.TargetPos = kitPos;
// // SendToKit(kitNo, '1'); //콜확정을 클라이언트에 알림
// // PUB.Speak(kitPos.ToString() + "위치로 이동 합니다");
// // //상태머신을 변경한다 (충전 OFF상태로 간다, 충전상태가 아니면 바로 이동하게됨)
// // // Pub.sm.ResetRunStep();
// // // Pub.sm.setNewStep(StateMachine.eSMStep.RUN);
// // //qa => pack 은 하차 전용이다
// // //QA에서 PACK이동시에는 바로 N극 멈춤 기능을 사용해도도된다.(자재가 있으며, 커버가 내려가 있으므로 느리게 동작해야함)
// // PUB.sm.ClearRunStep();
// // PUB.sm.SetNewRunStep(StateMachine.ERunStep.GODOWN);
// // PUB.sm.SetNewStep(StateMachine.ESMStep.RUN);
// // PUB.AGV.AGVMoveStop("xbee_newmsgevent", arDev.Narumi.eStopOpt.MarkStop);// (arDev.Narumi.eAgvCmd.MoveStop,.SetNextStop_Mark(true, "xbee godn,qa,pack");
// // PUB.PLC.ZMot(arDev.FakePLC.ZMotDirection.Up);
// //}
// else if (PUB.Result.TargetPos == kitPos) ////현재 지정된 클라이언트가 또 눌렀다
// {
// PUB.Result.TargetPos = kitPos;
// PUB.AGV.data.CallNo = int.Parse(kitNo.ToString());
// PUB.AGV.data.CallString = kitNo.ToString();
// //상차 대기 중이라면 커버를 자동 올려준다
// //이것은 QC만 가능하다
// //QC가 QA혹은 PACK으로 보낼때 사용함
// if (kitPos == ePosition.QC &&
// VAR.BOOL[eVarBool.FLAG_LIMITLOW] == true)
// {
// RaiseMessage(MessageType.Normal, "QC위치에서 자동으로 커버를 올립니다");
// //PUB.PLC.ZMot(arDev.FakePLC.ZMotDirection.Up);
// PUB.AGV.LiftControl(arDev.Narumi.LiftCommand.UP);
// }
// else
// {
// //커버대기상태라면 커버를 자동으로 처리해준다.
// if (PUB.sm.Step == StateMachine.eSMStep.RUN && (PUB.sm.RunStep == StateMachine.ERunStep.GOUP || PUB.sm.RunStep == StateMachine.ERunStep.GODOWN))
// {
// if (VAR.BOOL[eVarBool.WAIT_COVER_DOWN] == true)
// {
// //var ld = PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_LD);
// //var rd = PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_RD);
// //if (ld == false || rd == false)
// //{
// // PUB.log.Add("사용자 콜버튼 추가 동작 - Z내림");
// // PUB.PLC.ZMot(arDev.FakePLC.ZMotDirection.Down);
// // PUB.Speak(Lang.커버를내립니다);
// //}
// }
// else if (VAR.BOOL[eVarBool.WAIT_COVER_UP] == true)
// {
// //var lu = PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_LU);
// //var ru = PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_RU);
// //if (lu == false || ru == false)
// //{
// // PUB.PLC.ZMot(arDev.FakePLC.ZMotDirection.Up);
// // PUB.log.Add("사용자 콜버튼 추가 동작 - Z올림");
// // PUB.Speak(Lang.커버를올립니다);
// //}
// }
// else RaiseMessage(MessageType.Normal, string.Format("이미 CALL이 확정되었습니다 No={0},Pos={1}", kitNo, kitPos));
// }
// else RaiseMessage(MessageType.Normal, string.Format("이미 CALL이 확정되었습니다 No={0},Pos={1}", kitNo, kitPos));
// }
// SendToKit(kitNo, '1', (PUB.IsCanCALL() ? '1' : '0')); //콜확정을 클라이언트에 알림
// }
// else
// {
// //다른대상이 이미 선택된 상태이므로 CANCEL 한다.
// SendToKit(kitNo, '0', (PUB.IsCanCALL() ? '1' : '0'));
// RaiseMessage(MessageType.Normal, string.Format("다른 CALL이 확정된 상태입니다. 요청KIT={2},확정KIT={0},위치={1}", PUB.Result.TargetPos - 2, PUB.Result.TargetPos, kitNo));
// }
// }
// else if (kitVal == '0') //캔슬버튼을 눌렀다
// {
// //목표번호가 캔슬버튼을 눌렀다
// if (PUB.Result.TargetPos == kitPos)
// {
// //상차가 완료되면 TargetPos 가 변경되어 ,더이상 해당 버튼으로는 취소하지 못한다
// PUB.AGV.data.CallNo = 0;
// PUB.AGV.data.CallString = "--";
// SendToKit(kitNo, '0', (PUB.IsCanCALL() ? '1' : '0'));
// RaiseMessage(MessageType.Normal, string.Format("콜 취소 Kit={0}", kitNo));
// if (PUB.sm.RunStep != StateMachine.ERunStep.GOHOME)
// {
// PUB.Result.CommandKit = kitNo;
// PUB.Result.TargetPos = ePosition.QC;
// PUB.sm.ClearRunStep();
// PUB.sm.SetNewRunStep(StateMachine.ERunStep.GOHOME);
// PUB.sm.SetNewStep(StateMachine.eSMStep.RUN);
// RaiseMessage(MessageType.Normal, string.Format("콜 취소로 인해 홈으로 이동합니다 Kit={0}", kitNo));
// }
// }
// else
// {
// //다른놈이 취소 버튼을 눌렀다. ㅋㅋ
// //아무~ 의미 없다.
// SendToKit(kitNo, '0', (PUB.IsCanCALL() ? '1' : '0'));
// RaiseMessage(MessageType.Normal, string.Format("해당 콜취소는 유효하지 않습니다 요청KIT={0},확정KIT={1}", kitNo, PUB.Result.TargetPos - 2));
// }
// }
// else if (kitVal == '2') //BACKWORK시에만 이 값이 전송되게 한다
// {
// //QA 이동 명령
// //발동조건 1. QC 위치에서 GOUP(대기 혹은 상차완료)상태일때 (일반적인경우)
// //발동조건 2. QC 위치에서 IDLE 상태일때 (GOUP상태로 하지 않고 바로 싫어버린경우)
// //발동조건 3. 충전중일때
// //if (kitPos != ePosition.QC)
// //{
// // RaiseMessage(MessageType.Error, $"back 버튼은 QC버튼만 사용 가능 합니다");
// // return;
// //}
// //if (kitPos == ePosition.QC && PUB.Result.CurrentPos != ePosition.QC)
// //{
// // RaiseMessage(MessageType.Error, string.Format("QC의 QA버튼은 홈위치에 있어야 사용이 가능 합니다"));
// // return;
// //}
// ////명령송신은 QC로 고정한다
// //PUB.Result.CommandKit = '2';
// //PUB.Result.TargetPos = ePosition.QA;
// //PUB.sm.ClearRunStep();
// //PUB.sm.SetNewRunStep(StateMachine.ERunStep.GODOWN);
// //PUB.sm.SetNewStep(StateMachine.ESMStep.RUN);
// //RaiseMessage(MessageType.Normal, string.Format("후진하차 모드 대상위치={0}", ePosition.QA));
// //PUB.logsys.AddI("QC의 QA리모콘 버튼 작업 입니다");
// }
// }
// public void SendToKit(char kitNo, char Value, char enbcall)
// {
// List<byte> buffer = new List<byte>
// {
// 0x02,
// (byte)kitNo,
// (byte)Value,
// (byte)enbcall,
// 0x03
// };
// WriteData(buffer.ToArray());
// //RaiseMessage(MessageType.Normal, $"지그비전송 {kitNo}:{Value}:{enbcall}");
// }
// public string GetStatusString()
// {
// return DateTime.Now.ToString();
// }
// public void SendStatus(String StatusString)
// {
// ////IO
// char kitno = '0';
// char kitval = '1';
// if (PUB.Result.TargetPos == ePosition.F1) kitno = '1';
// else if (PUB.Result.TargetPos == ePosition.F2) kitno = '2';
// else if (PUB.Result.TargetPos == ePosition.F3) kitno = '3';
// else if (PUB.Result.TargetPos == ePosition.F4) kitno = '4';
// else if (PUB.Result.TargetPos == ePosition.QC) kitno = '9';
// else
// {
// //충전기 충전하는 것으로한다
// if (VAR.BOOL[eVarBool.FLAG_CHARGEONA] == false && VAR.BOOL[eVarBool.FLAG_CHARGEONM] == false)
// kitval = '0';
// }
// //콜가능여부도 전송한다
// var enbcall = PUB.IsCanCALL() ? '1' : '0';
// SendToKit(kitno, kitval, enbcall);
// }
// }
//}

View File

@@ -6,395 +6,173 @@ using System.ComponentModel;
using System.Threading;
using COMM;
using System.Runtime.Remoting.Messaging;
using ENIG;
using System.Security.Cryptography;
using AR;
using System.Web.Compilation;
namespace Project.Device
{
public class Xbee : arDev.arRS232
public class Xbee : System.IO.Ports.SerialPort
{
public Xbee()
{
}
public string buffer = string.Empty;
public System.Text.StringBuilder newbuffer = new StringBuilder();
protected override bool CustomParser(byte[] buf, out byte[] remainBuffer)
public string errorMessage = string.Empty;
public DateTime LastStatusSendTime = DateTime.Now;
private EEProtocol proto;
public Xbee()
{
//일반 kit 명령은 0x02 kit번호, kit값 0x03
//상태 명령은 0x04 메세지데이터 0x05
this.DataReceived += Xbee_DataReceived;
proto = new EEProtocol();
proto.OnDataReceived += Proto_OnDataReceived;
proto.OnMessage += Proto_OnMessage;
}
~Xbee()
{
this.DataReceived -= Xbee_DataReceived;
proto.OnDataReceived -= Proto_OnDataReceived;
proto.OnMessage -= Proto_OnMessage;
}
Console.WriteLine("custom parse len=" + buf.Length.ToString());
List<byte> sparebuffer = new List<byte>();
Boolean bComplete = false;
for (int i = 0; i < buf.Length; i++)
/// <summary>
/// AGV상태를 Xbee 로 전송한다
/// </summary>
public void SendStatus()
{
/*
Mode[1] : 0=manual, 1=auto
RunSt[1] : 0=stop, 1=run, 2=error
Diection[1] : 0=straight, 1=left, 2=right, 3=markstop
Inposition[1] : 0=off, 1=on : 목적위치에 도달완료 시 설정 이동 이동시 OFF됨
ChargeSt[1] : 0=off, 1=on
CartSt[1] : 0=off, 1=on, 2=unknown
LiftSt[1] : 0=down , 1=up, 2=unknown
LastTag[6] : "000000"
*/
try
{
var incomByte = buf[i];
if (bComplete == true) sparebuffer.Add(incomByte);
byte[] data = new byte[13]; // 총 13바이트 데이터
// Mode
data[0] = (byte)(VAR.BOOL[eVarBool.FLAG_AUTORUN] ? 1 : 0);
// RunSt
if (PUB.AGV.error.Emergency)
data[1] = 2; // error
else if (PUB.AGV.system1.agv_run)
data[1] = 1; // run
else
{
if (findSTX == false)
{
if (incomByte != 0x02)
{
//버리는데이터
}
else
{
findSTX = true;
tempBuffer.Clear();
tempBuffer.Add(incomByte);
}
}
else
{
tempBuffer.Add(incomByte);
data[1] = 0; // stop
if (incomByte == 0x03)
{
//데이터가 맞게 수신됨
LastReceiveBuffer = tempBuffer.ToArray();
bComplete = true;
findSTX = false;
}
else if (tempBuffer.Count > 30)
{
tempBuffer.Clear();
findSTX = false;
}
}
}
}
remainBuffer = sparebuffer.ToArray();
return bComplete;
}
public override bool ProcessRecvData(byte[] data)
{
var kitno = (char)(data[1]);
var kitval = (char)(data[2]);
NewMsgEvent(kitno, kitval);
return true;
}
public void NewMsgEvent(char kitNo, char kitVal)
{
//대상위치 확인
ePosition kitPos = ePosition.NONE;
if (kitNo == '9') kitPos = ePosition.QC;
else if (kitNo == '1') kitPos = ePosition.F1;
else if (kitNo == '2') kitPos = ePosition.F2;
else if (kitNo == '3') kitPos = ePosition.F3;
else if (kitNo == '4') kitPos = ePosition.F4;
else
{
if (kitNo == '0') return;
PUB.log.Add($"비허가 키트번호 무시 번호={kitNo},값={kitVal}");
return;
}
//if (kitNo= 'F')
//{
// PUB.Speak("알 수 없는 키트번호 입니다");
// PUB.logsys.Add($"키트번호별위치확인실패 값={kitNo}");
// return;
//}
//(ePosition)int.Parse(kitNo.ToString());
PUB.logcal.Add(string.Format("Xbee:newMsgEvent:{0},{1}=>{2}", kitNo, kitVal, kitPos));
if (PUB.CheckManualChargeMode() == false)
{
PUB.log.Add($"수동 충전 중이라 콜 기능을 취소 합니다");
return;
}
bool FixButton = kitPos == ePosition.NONE;
if (kitPos == ePosition.NONE)
{
if (kitVal == '1') kitPos = ePosition.QC;
else if (kitVal == '2') kitPos = ePosition.CHARGE;
else if (kitVal == '4') kitPos = ePosition.QC;
//else if (kitVal == '3') kitPos = ePosition.QA;
// Direction
if (PUB.AGV.system1.stop_by_front_detect)
data[2] = 3; // markstop
else if (VAR.BOOL[eVarBool.FLAG_LEFT_RUN])
data[2] = 1; // left
else if (VAR.BOOL[eVarBool.FLAG_RIGHT_RUN])
data[2] = 2; // right
else
{
PUB.log.Add($"AGV버튼 이벤트 실행 값:{kitVal} 취소");
return;
}
kitVal = '1'; //버튼은 무조건 ON상태로 한다
}
data[2] = 0; // straight
//자동상태가 아니라면 오류처리
if (VAR.BOOL[eVarBool.FLAG_AUTORUN] == false || PUB.sm.Step != StateMachine.eSMStep.RUN)
{
PUB.log.AddE("'자동실행' 상태가 아니므로 콜/취소 작업을 할 수 없습니다 콜:" + kitPos.ToString() + ",값=" + kitVal.ToString());
PUB.Speak(Lang.);
return;
}
// Inposition
data[3] = (byte)(PUB.AGV.system1.agv_stop ? 1 : 0);
//충전기를 제외하고 '1'의 값은 호출을 원하는값이다.('0'=취소)
if (kitVal == '1')
{
//qA혹은 Pack 에서 해당 버튼을 눌렀을때의 처리방법
//if (PUB.Result.CurrentPos == ePosition.QA && kitPos == ePosition.QA)
//{
// PUB.logsys.AddE("QA위치에서 QA버튼을 눌렀음 명령 취소함");
// PUB.Speak("현재 위치는 QA 입니다.");
// return;
//}
// ChargeSt
data[4] = (byte)((VAR.BOOL[eVarBool.FLAG_CHARGEONA] || VAR.BOOL[eVarBool.FLAG_CHARGEONM]) ? 1 : 0);
//상/하차 작업중이 아니라면 콜을 받는다
if (PUB.sm.RunStep != StateMachine.ERunStep.GOUP && PUB.sm.RunStep != StateMachine.ERunStep.GODOWN)
{
//call을 받으려면 대상위 (2=QC,3,4,5,6,7)
//콜을 요청하는 곳 (2=QC,3=FVI-1,4,5,6,7==FVI-5)
//1번은 충전기
//콜버튼으로 대상위치를 다시 결정한다.
//대상번호는 콜번호에서 +2을 하면 된다.
//대상번호 PK=1,QA2=2,QA1=3,QC=4
//QC의경우 콜Kit번호는 2이므로, 이동대상은 +2인 4가 되어야 함
//콜번호와 RFID대상번호는 2의 오차가 발생함, 현재 설치된 RFID를 모두 변경할 수 없어서 이렇게 운용함
RaiseMessage(MessageType.Normal, string.Format("CALL확정 Kit={0},대상위치={1}", kitNo, kitPos));
PUB.AGV.data.CallNo = int.Parse(kitNo.ToString());
PUB.AGV.data.CallString = kitNo.ToString();
PUB.Result.CommandKit = kitNo;
PUB.Result.TargetPos = kitPos;
SendToKit(kitNo, '1', (PUB.IsCanCALL() ? '1' : '0')); //콜확정을 클라이언트에 알림
PUB.Speak(kitPos.ToString() + Lang.);
//상태머신을 변경한다 (충전 OFF상태로 간다, 충전상태가 아니면 바로 이동하게됨)
//Pub.sm.ResetRunStep();
//Pub.sm.setNewStep(StateMachine.eSMStep.RUN);
//qa, pack 은 하차 전용이다
PUB.sm.ClearRunStep();
PUB.sm.SetNewRunStep(StateMachine.ERunStep.GOUP);
PUB.sm.SetNewStep(StateMachine.eSMStep.RUN);
}
else if (PUB.sm.RunStep == StateMachine.ERunStep.GODOWN && VAR.BOOL[eVarBool.WAIT_COVER_DOWN] == false && VAR.BOOL[eVarBool.WAIT_COVER_UP] == false)
{
//하차중에 받을 수 있게하자 (단 FVi1 이하일때에는 무시하자) 230710 - 김수곤
if (PUB.Result.TargetPos == ePosition.QC && PUB.Result.CurrentPos < ePosition.F1)
{
PUB.log.Add($"하차중이지만 FVI #1 아래에 있으니 콜을 취소 합니다");
SendToKit(kitNo, '0', '0');
RaiseMessage(MessageType.Normal, $"QC 추가 콜이지만 위치가 #1번 이하이므로 취소 됩니다. Kit={kitNo},현재={PUB.Result.CurrentPos},대상={PUB.Result.TargetPos}");
}
else
{
RaiseMessage(MessageType.Normal, string.Format("CALL확정(추가) Kit={0},대상위치={1}", kitNo, kitPos));
PUB.AGV.data.CallNo = int.Parse(kitNo.ToString());
PUB.AGV.data.CallString = kitNo.ToString();
PUB.Result.CommandKit = kitNo;
PUB.Result.TargetPos = kitPos;
SendToKit(kitNo, '1', (PUB.IsCanCALL() ? '1' : '0')); //콜확정을 클라이언트에 알림
PUB.Speak(kitPos.ToString() + Lang.);
//상태머신을 변경한다 (충전 OFF상태로 간다, 충전상태가 아니면 바로 이동하게됨)
//Pub.sm.ResetRunStep();
//Pub.sm.setNewStep(StateMachine.eSMStep.RUN);
//qa, pack 은 하차 전용이다
PUB.sm.ClearRunStep();
PUB.sm.SetNewRunStep(StateMachine.ERunStep.GOUP);
PUB.sm.SetNewStep(StateMachine.eSMStep.RUN);
}
}
//else if (PUB.sm.RunStep == StateMachine.ERunStep.GODOWN && PUB.Result.CurrentPos == ePosition.QA)
//{
// RaiseMessage(MessageType.Normal, string.Format("CALL확정 Kit={0},대상위치={1}", kitNo, kitPos));
// PUB.Result.CommandKit = kitNo;
// PUB.Result.TargetPos = kitPos;
// SendToKit(kitNo, '1'); //콜확정을 클라이언트에 알림
// PUB.Speak(kitPos.ToString() + "위치로 이동 합니다");
// //상태머신을 변경한다 (충전 OFF상태로 간다, 충전상태가 아니면 바로 이동하게됨)
// // Pub.sm.ResetRunStep();
// // Pub.sm.setNewStep(StateMachine.eSMStep.RUN);
// //qa => pack 은 하차 전용이다
// //QA에서 PACK이동시에는 바로 N극 멈춤 기능을 사용해도도된다.(자재가 있으며, 커버가 내려가 있으므로 느리게 동작해야함)
// PUB.sm.ClearRunStep();
// PUB.sm.SetNewRunStep(StateMachine.ERunStep.GODOWN);
// PUB.sm.SetNewStep(StateMachine.ESMStep.RUN);
// PUB.AGV.AGVMoveStop("xbee_newmsgevent", arDev.Narumi.eStopOpt.MarkStop);// (arDev.Narumi.eAgvCmd.MoveStop,.SetNextStop_Mark(true, "xbee godn,qa,pack");
// PUB.PLC.ZMot(arDev.FakePLC.ZMotDirection.Up);
//}
else if (PUB.Result.TargetPos == kitPos) ////현재 지정된 클라이언트가 또 눌렀다
{
PUB.Result.TargetPos = kitPos;
PUB.AGV.data.CallNo = int.Parse(kitNo.ToString());
PUB.AGV.data.CallString = kitNo.ToString();
//상차 대기 중이라면 커버를 자동 올려준다
//이것은 QC만 가능하다
//QC가 QA혹은 PACK으로 보낼때 사용함
if (kitPos == ePosition.QC &&
VAR.BOOL[eVarBool.FLAG_LIMITLOW] == true)
{
RaiseMessage(MessageType.Normal, "QC위치에서 자동으로 커버를 올립니다");
PUB.PLC.ZMot(arDev.FakePLC.ZMotDirection.Up);
}
else
{
//커버대기상태라면 커버를 자동으로 처리해준다.
if (PUB.sm.Step == StateMachine.eSMStep.RUN && (PUB.sm.RunStep == StateMachine.ERunStep.GOUP || PUB.sm.RunStep == StateMachine.ERunStep.GODOWN))
{
if (VAR.BOOL[eVarBool.WAIT_COVER_DOWN] == true)
{
var ld = PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_LD);
var rd = PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_RD);
if (ld == false || rd == false)
{
PUB.log.Add("사용자 콜버튼 추가 동작 - Z내림");
PUB.PLC.ZMot(arDev.FakePLC.ZMotDirection.Down);
PUB.Speak(Lang.);
}
}
else if (VAR.BOOL[eVarBool.WAIT_COVER_UP] == true)
{
var lu = PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_LU);
var ru = PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_RU);
if (lu == false || ru == false)
{
PUB.PLC.ZMot(arDev.FakePLC.ZMotDirection.Up);
PUB.log.Add("사용자 콜버튼 추가 동작 - Z올림");
PUB.Speak(Lang.);
}
}
else RaiseMessage(MessageType.Normal, string.Format("이미 CALL이 확정되었습니다 No={0},Pos={1}", kitNo, kitPos));
}
else RaiseMessage(MessageType.Normal, string.Format("이미 CALL이 확정되었습니다 No={0},Pos={1}", kitNo, kitPos));
}
SendToKit(kitNo, '1', (PUB.IsCanCALL() ? '1' : '0')); //콜확정을 클라이언트에 알림
}
// CartSt
if(PUB.AGV.signal.cart_detect1 && PUB.AGV.signal.cart_detect2)
data[5] = 1; // 센서두개가 모두 감지되는 경우
else if(PUB.AGV.signal.cart_detect1==false && PUB.AGV.signal.cart_detect2==false)
data[5] = 0; // 센서두개가 모두 감지되지 않는 경우
else
{
//다른대상이 이미 선택된 상태이므로 CANCEL 한다.
SendToKit(kitNo, '0', (PUB.IsCanCALL() ? '1' : '0'));
RaiseMessage(MessageType.Normal, string.Format("다른 CALL이 확정된 상태입니다. 요청KIT={2},확정KIT={0},위치={1}", PUB.Result.TargetPos - 2, PUB.Result.TargetPos, kitNo));
}
}
else if (kitVal == '0') //캔슬버튼을 눌렀다
{
//목표번호가 캔슬버튼을 눌렀다
if (PUB.Result.TargetPos == kitPos)
{
//상차가 완료되면 TargetPos 가 변경되어 ,더이상 해당 버튼으로는 취소하지 못한다
PUB.AGV.data.CallNo = 0;
PUB.AGV.data.CallString = "--";
data[5] = 2; // 센서하나만 감지되는 경우
SendToKit(kitNo, '0', (PUB.IsCanCALL() ? '1' : '0'));
RaiseMessage(MessageType.Normal, string.Format("콜 취소 Kit={0}", kitNo));
if (PUB.sm.RunStep != StateMachine.ERunStep.GOHOME)
{
PUB.Result.CommandKit = kitNo;
PUB.Result.TargetPos = ePosition.QC;
PUB.sm.ClearRunStep();
PUB.sm.SetNewRunStep(StateMachine.ERunStep.GOHOME);
PUB.sm.SetNewStep(StateMachine.eSMStep.RUN);
RaiseMessage(MessageType.Normal, string.Format("콜 취소로 인해 홈으로 이동합니다 Kit={0}", kitNo));
}
}
// LiftSt
if(PUB.AGV.signal.lift_up)
data[6] = 1; // 위로 올라가는 경우
else if(PUB.AGV.signal.lift_down)
data[6] = 0; // 아래로 내려가는 경우
else
{
//다른놈이 취소 버튼을 눌렀다. ㅋㅋ
//아무~ 의미 없다.
SendToKit(kitNo, '0', (PUB.IsCanCALL() ? '1' : '0'));
RaiseMessage(MessageType.Normal, string.Format("해당 콜취소는 유효하지 않습니다 요청KIT={0},확정KIT={1}", kitNo, PUB.Result.TargetPos - 2));
}
data[6] = 2; // unknown (기본값)
// LastTag
string lastTag = PUB.AGV.data.TagNo.ToString("000000") ?? "000000";
byte[] tagBytes = Encoding.ASCII.GetBytes(lastTag.PadRight(6, '0'));
Array.Copy(tagBytes, 0, data, 7, 6);
// 데이터 전송
var packet = proto.CreatePacket(PUB.setting.XBE_ID, 9, data);
Send(packet);
LastStatusSendTime = DateTime.Now;
}
else if (kitVal == '2') //BACKWORK시에만 이 값이 전송되게 한다
catch (Exception ex)
{
//QA 이동 명령
//발동조건 1. QC 위치에서 GOUP(대기 혹은 상차완료)상태일때 (일반적인경우)
//발동조건 2. QC 위치에서 IDLE 상태일때 (GOUP상태로 하지 않고 바로 싫어버린경우)
//발동조건 3. 충전중일때
//if (kitPos != ePosition.QC)
//{
// RaiseMessage(MessageType.Error, $"back 버튼은 QC버튼만 사용 가능 합니다");
// return;
//}
//if (kitPos == ePosition.QC && PUB.Result.CurrentPos != ePosition.QC)
//{
// RaiseMessage(MessageType.Error, string.Format("QC의 QA버튼은 홈위치에 있어야 사용이 가능 합니다"));
// return;
//}
////명령송신은 QC로 고정한다
//PUB.Result.CommandKit = '2';
//PUB.Result.TargetPos = ePosition.QA;
//PUB.sm.ClearRunStep();
//PUB.sm.SetNewRunStep(StateMachine.ERunStep.GODOWN);
//PUB.sm.SetNewStep(StateMachine.ESMStep.RUN);
//RaiseMessage(MessageType.Normal, string.Format("후진하차 모드 대상위치={0}", ePosition.QA));
//PUB.logsys.AddI("QC의 QA리모콘 버튼 작업 입니다");
errorMessage = ex.Message;
PUB.logxbee.AddE(errorMessage);
}
}
public void SendToKit(char kitNo, char Value, char enbcall)
/// <summary>
/// 지그비장치에 데이터를 전송합니다
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public bool Send(byte[] data)
{
List<byte> buffer = new List<byte>
try
{
0x02,
(byte)kitNo,
(byte)Value,
(byte)enbcall,
0x03
};
WriteData(buffer.ToArray());
//RaiseMessage(MessageType.Normal, $"지그비전송 {kitNo}:{Value}:{enbcall}");
}
public string GetStatusString()
{
return DateTime.Now.ToString();
}
public void SendStatus(String StatusString)
{
////IO
char kitno = '0';
char kitval = '1';
if (PUB.Result.TargetPos == ePosition.F1) kitno = '1';
else if (PUB.Result.TargetPos == ePosition.F2) kitno = '2';
else if (PUB.Result.TargetPos == ePosition.F3) kitno = '3';
else if (PUB.Result.TargetPos == ePosition.F4) kitno = '4';
else if (PUB.Result.TargetPos == ePosition.QC) kitno = '9';
else
this.Write(data, 0, data.Length);
return true;
}catch (Exception ex)
{
//충전기 충전하는 것으로한다
if (VAR.BOOL[eVarBool.FLAG_CHARGEONA] == false && VAR.BOOL[eVarBool.FLAG_CHARGEONM] == false)
kitval = '0';
errorMessage = ex.Message;
return false;
}
}
//콜가능여부도 전송한다
var enbcall = PUB.IsCanCALL() ? '1' : '0';
SendToKit(kitno, kitval, enbcall);
public new bool Open()
{
try{
this.Open();
return true;
}catch (Exception ex)
{
errorMessage = ex.Message;
PUB.logxbee.AddE(errorMessage);
return false;
}
}
private void Proto_OnDataReceived(object sender, EEProtocol.DataEventArgs e)
{
var hexstrRaw = e.ReceivedPacket.RawData.HexString();
var hexstr = e.ReceivedPacket.Data.HexString();
var cmd = e.ReceivedPacket.Command.ToString("X2");
var id = e.ReceivedPacket.ID.ToString("X2");
PUB.logxbee.Add("RX", $"{hexstrRaw}\nID:{id},CMD:{cmd},DATA:{hexstr}");
//TODO : 기능 처리필요 (XBee 메세지 데이터처리)
//PUB.CheckManualChargeMode() : 수동충전확인
//VAR.BOOL[eVarBool.FLAG_AUTORUN] : 자동실행
//PUB.Speak("현재 위치는 QA 입니다.") : 음성출력
}
private void Proto_OnMessage(object sender, EEProtocol.MessageEventArgs e)
{
if (e.IsError) PUB.log.AddE(e.Message);
else PUB.log.Add(e.Message);
}
private void Xbee_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
var dev = sender as System.IO.Ports.SerialPort;
var buffer = new byte[dev.BytesToRead];
dev.Read(buffer, 0, buffer.Length);
proto.ProcessReceivedData(buffer);
}
}
}

View File

@@ -24,7 +24,7 @@ namespace Project.Dialog
PUB.logagv.RaiseMsg -= Log_RaiseMsgagv;
PUB.logplc.RaiseMsg -= Log_RaiseMsgplc;
PUB.logbms.RaiseMsg -= Log_RaiseMsgbms;
PUB.logcal.RaiseMsg -= Log_RaiseMsgcal;
PUB.logxbee.RaiseMsg -= Log_RaiseMsgcal;
}
private void fLog_Load(object sender, EventArgs e)
@@ -49,7 +49,7 @@ namespace Project.Dialog
PUB.logagv.RaiseMsg += Log_RaiseMsgagv;
PUB.logplc.RaiseMsg += Log_RaiseMsgplc;
PUB.logbms.RaiseMsg += Log_RaiseMsgbms;
PUB.logcal.RaiseMsg += Log_RaiseMsgcal;
PUB.logxbee.RaiseMsg += Log_RaiseMsgcal;
}
private void Log_RaiseMsg(DateTime LogTime, string TypeStr, string Message)

View File

@@ -12,6 +12,7 @@ using System.Net;
using System.Management;
using System.Data.SqlClient;
using System.Data;
using AR;
namespace Project
{
@@ -28,7 +29,7 @@ namespace Project
/// <summary>
/// 읽기/쓰기용이며 구동모터 와 비상정지가 연결됨(USB-ATMEGA 2560)
/// </summary>
public static arDev.FakePLC PLC;
//public static arDev.FakePLC PLC;
///// <summary>
///// 읽기전용이며 Z축 모터와 외부 버튼이 연결됨(USB-ATMEGA 2560)
@@ -122,7 +123,7 @@ namespace Project
/// <summary>
/// 시스템로그
/// </summary>
public static arUtil.Log log, logagv, logplc, logbms, logcal;
public static arUtil.Log log, logagv, logplc, logbms, logxbee;
public static Boolean bPlayMusic = false;
@@ -158,12 +159,12 @@ namespace Project
logagv = new arUtil.Log();
logplc = new arUtil.Log();
logbms = new arUtil.Log();
logcal = new arUtil.Log();
logxbee = new arUtil.Log();
logagv.FileNameFormat = "{yyyyMMdd}_agv";
logplc.FileNameFormat = "{yyyyMMdd}_plc";
logbms.FileNameFormat = "{yyyyMMdd}_bms";
logcal.FileNameFormat = "{yyyyMMdd}_cal";
logxbee.FileNameFormat = "{yyyyMMdd}_cal";
//popupmessage
popup = new MessageWindow();
@@ -255,7 +256,7 @@ namespace Project
/// <returns></returns>
public static Boolean HasHWError()
{
if (PUB.PLC.IsValid == false) return true;
//if (PUB.PLC.IsValid == false) return true;
if (PUB.AGV.IsOpen == false) return true;
if (PUB.XBE.IsOpen == false) return true;
return false;

View File

@@ -0,0 +1,145 @@
using System;
using System.Collections.Generic;
namespace Project.StateMachine
{
public class AGVPosition
{
public enum PositionType
{
None,
Tops1,
Sstron1,
Sstron2,
Path
}
public class Position
{
public int RFID { get; set; }
public PositionType Type { get; set; }
public string Name { get; set; }
public string Direction { get; set; }
public List<int> ConnectedPositions { get; set; }
public Position(int rfid, PositionType type, string name, string direction)
{
RFID = rfid;
Type = type;
Name = name;
Direction = direction;
ConnectedPositions = new List<int>();
}
}
private Dictionary<int, Position> positionMap;
private static AGVPosition instance;
private AGVPosition()
{
positionMap = new Dictionary<int, Position>();
InitializePositions();
}
public static AGVPosition Instance
{
get
{
if (instance == null)
{
instance = new AGVPosition();
}
return instance;
}
}
private void InitializePositions()
{
// Tops 1 관련 위치
AddPosition(100, PositionType.Tops1, "Tops 1", "0");
AddPosition(101, PositionType.Path, "Tops1-Sstron1 Path 1", "0");
AddPosition(102, PositionType.Path, "Tops1-Sstron1 Path 2", "0");
// Sstron 1 관련 위치
AddPosition(200, PositionType.Sstron1, "Sstron 1", "0");
AddPosition(201, PositionType.Path, "Sstron1-Sstron2 Path 1", "0");
AddPosition(202, PositionType.Path, "Sstron1-Sstron2 Path 2", "0");
// Sstron 2 관련 위치
AddPosition(300, PositionType.Sstron2, "Sstron 2", "0");
// 경로 연결 설정
ConnectPositions(100, 101);
ConnectPositions(101, 102);
ConnectPositions(102, 200);
ConnectPositions(200, 201);
ConnectPositions(201, 202);
ConnectPositions(202, 300);
}
private void AddPosition(int rfid, PositionType type, string name, string direction)
{
positionMap[rfid] = new Position(rfid, type, name, direction);
}
private void ConnectPositions(int pos1, int pos2)
{
if (positionMap.ContainsKey(pos1) && positionMap.ContainsKey(pos2))
{
positionMap[pos1].ConnectedPositions.Add(pos2);
positionMap[pos2].ConnectedPositions.Add(pos1);
}
}
public Position GetPosition(int rfid)
{
if (positionMap.ContainsKey(rfid))
{
return positionMap[rfid];
}
return null;
}
public List<int> FindPath(int startRfid, int endRfid)
{
if (!positionMap.ContainsKey(startRfid) || !positionMap.ContainsKey(endRfid))
{
return null;
}
var visited = new HashSet<int>();
var path = new List<int>();
if (FindPathDFS(startRfid, endRfid, visited, path))
{
return path;
}
return null;
}
private bool FindPathDFS(int current, int end, HashSet<int> visited, List<int> path)
{
if (current == end)
{
path.Add(current);
return true;
}
visited.Add(current);
path.Add(current);
foreach (var next in positionMap[current].ConnectedPositions)
{
if (!visited.Contains(next))
{
if (FindPathDFS(next, end, visited, path))
{
return true;
}
}
}
path.RemoveAt(path.Count - 1);
return false;
}
}
}

View File

@@ -0,0 +1,107 @@
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace Project.StateMachine
{
public class AGVProtocolHandler
{
private static AGVProtocolHandler instance;
private AGVStateManager stateManager;
private AGVProtocolHandler()
{
stateManager = AGVStateManager.Instance;
}
public static AGVProtocolHandler Instance
{
get
{
if (instance == null)
{
instance = new AGVProtocolHandler();
}
return instance;
}
}
public bool ProcessProtocol(string protocol)
{
try
{
// 프로토콜 형식: COMMAND:DESTINATION
var parts = protocol.Split(':');
if (parts.Length != 2)
{
return false;
}
var command = parts[0].ToUpper();
var destination = parts[1].ToUpper();
switch (command)
{
case "MOVE_TO":
return HandleMoveToCommand(destination);
case "PICKUP":
return HandlePickupCommand(destination);
case "DROPOFF":
return HandleDropoffCommand(destination);
case "EMERGENCY_STOP":
return HandleEmergencyStopCommand();
default:
return false;
}
}
catch (Exception)
{
return false;
}
}
private bool HandleMoveToCommand(string destination)
{
switch (destination)
{
case "T1":
return stateManager.ProcessCommand(AGVStateManager.AGVCommand.MoveToTops1);
case "S1":
return stateManager.ProcessCommand(AGVStateManager.AGVCommand.MoveToSstron1);
case "S2":
return stateManager.ProcessCommand(AGVStateManager.AGVCommand.MoveToSstron2);
default:
return false;
}
}
private bool HandlePickupCommand(string destination)
{
if (destination != "T1")
{
return false;
}
return stateManager.ProcessCommand(AGVStateManager.AGVCommand.PickupCart);
}
private bool HandleDropoffCommand(string destination)
{
if (destination != "S1" && destination != "S2")
{
return false;
}
return stateManager.ProcessCommand(AGVStateManager.AGVCommand.DropoffCart);
}
private bool HandleEmergencyStopCommand()
{
return stateManager.ProcessCommand(AGVStateManager.AGVCommand.EmergencyStop);
}
public string GetCurrentStatus()
{
var state = stateManager.CurrentState;
return $"Current State: {state}";
}
}
}

View File

@@ -0,0 +1,159 @@
using System;
using System.Collections.Generic;
namespace Project.StateMachine
{
public class AGVStateManager
{
public enum AGVState
{
Idle,
Moving,
Loading,
Unloading,
Error
}
public enum AGVCommand
{
MoveToTops1,
MoveToSstron1,
MoveToSstron2,
PickupCart,
DropoffCart,
EmergencyStop
}
private AGVState currentState;
private static AGVStateManager instance;
private AGVPosition positionManager;
private AGVStateManager()
{
currentState = AGVState.Idle;
positionManager = AGVPosition.Instance;
}
public static AGVStateManager Instance
{
get
{
if (instance == null)
{
instance = new AGVStateManager();
}
return instance;
}
}
public AGVState CurrentState
{
get { return currentState; }
}
public bool ProcessCommand(AGVCommand command)
{
switch (command)
{
case AGVCommand.MoveToTops1:
return HandleMoveCommand(100); // Tops 1 RFID
case AGVCommand.MoveToSstron1:
return HandleMoveCommand(200); // Sstron 1 RFID
case AGVCommand.MoveToSstron2:
return HandleMoveCommand(300); // Sstron 2 RFID
case AGVCommand.PickupCart:
return HandlePickupCommand();
case AGVCommand.DropoffCart:
return HandleDropoffCommand();
case AGVCommand.EmergencyStop:
return HandleEmergencyStop();
default:
return false;
}
}
private bool HandleMoveCommand(int targetRfid)
{
if (currentState != AGVState.Idle && currentState != AGVState.Moving)
{
return false;
}
// 현재 위치에서 목표 위치까지의 경로를 찾음
var currentRfid = GetCurrentRfid(); // 실제 구현에서는 현재 RFID 값을 가져와야 함
var path = positionManager.FindPath(currentRfid, targetRfid);
if (path == null)
{
return false;
}
currentState = AGVState.Moving;
// 경로를 따라 이동하는 로직 구현
return true;
}
private bool HandlePickupCommand()
{
if (currentState != AGVState.Moving)
{
return false;
}
// 현재 위치가 Tops 1인지 확인
var currentRfid = GetCurrentRfid();
var position = positionManager.GetPosition(currentRfid);
if (position == null || position.Type != AGVPosition.PositionType.Tops1)
{
return false;
}
currentState = AGVState.Loading;
// 카트 적재 로직 구현
return true;
}
private bool HandleDropoffCommand()
{
if (currentState != AGVState.Moving)
{
return false;
}
// 현재 위치가 Sstron 1 또는 Sstron 2인지 확인
var currentRfid = GetCurrentRfid();
var position = positionManager.GetPosition(currentRfid);
if (position == null ||
(position.Type != AGVPosition.PositionType.Sstron1 &&
position.Type != AGVPosition.PositionType.Sstron2))
{
return false;
}
currentState = AGVState.Unloading;
// 카트 하역 로직 구현
return true;
}
private bool HandleEmergencyStop()
{
currentState = AGVState.Error;
// 비상 정지 로직 구현
return true;
}
private int GetCurrentRfid()
{
// 실제 구현에서는 AGV의 현재 RFID 값을 반환해야 함
// 예시로 100(Tops 1)을 반환
return 100;
}
public void UpdateState(AGVState newState)
{
currentState = newState;
}
}
}

View File

@@ -5,6 +5,7 @@ using System.Linq;
using System.Text;
using static Project.StateMachine;
using COMM;
using AR;
namespace Project
{
@@ -15,6 +16,7 @@ namespace Project
DateTime LastCommandTime = DateTime.Now;
DateTime LastCommandTimeNextStop = DateTime.Now;
bool runStepisFirst = false;
private void _SM_RUN(Boolean isFirst, TimeSpan stepTime)
{
//중단기능이 동작이라면 처리하지 않는다.
@@ -62,9 +64,9 @@ namespace Project
if (isFirst)
{
if (PUB.sm.RunStep == ERunStep.READY)
VAR.TIME.Set(eVarTime.ReadyStart);
VAR.TIME.Update(eVarTime.ReadyStart);
else
VAR.TIME.Set(eVarTime.RunStart);
VAR.TIME.Update(eVarTime.RunStart);
}
switch (PUB.sm.RunStep)
@@ -95,7 +97,7 @@ namespace Project
case ERunStep.CHARGECHECK: //충전중
if (runStepisFirst)
{
VAR.TIME.Set(eVarTime.ChargeStart);
VAR.TIME.Update(eVarTime.ChargeStart);
LastCommandTime = DateTime.Now;
}
else if (_SM_RUN_GOCHARGECHECK(runStepisFirst, PUB.sm.GetRunSteptime))
@@ -109,7 +111,7 @@ namespace Project
case ERunStep.CHARGEOFF:
if (runStepisFirst)
{
VAR.TIME.Set(eVarTime.ChargeEnd);
VAR.TIME.Update(eVarTime.ChargeEnd);
LastCommandTime = DateTime.Now;
}
else
@@ -160,8 +162,8 @@ namespace Project
if (_SM_RUN_GODOWN(runStepisFirst, PUB.sm.GetRunSteptime))
{
PUB.Speak(Lang.);
VAR.TIME.Set(eVarTime.ChargeTry);
PUB.PLC.ZMot(arDev.FakePLC.ZMotDirection.Down);// (Device.PLC.ZMotDirection.Down); //하차작업이 완료되면 커버를 내려서 바로 작업할 수 있게 한다.
VAR.TIME.Update(eVarTime.ChargeTry);
PUB.AGV.LiftControl(arDev.Narumi.LiftCommand.DN);// (Device.PLC.ZMotDirection.Down); //하차작업이 완료되면 커버를 내려서 바로 작업할 수 있게 한다.
//230601
//if (PUB.Result != null && PUB.sm != null)
@@ -200,7 +202,7 @@ namespace Project
// EEMStatus.AddEEDBSQL(PUB.sm.Step, PUB.sm.RunStep.ToString(), PUB.Result.TargetPos.ToString());
PUB.Speak(Lang.);
VAR.TIME.Set(eVarTime.ChargeTry);
VAR.TIME.Update(eVarTime.ChargeTry);
PUB.sm.SetNewRunStep(ERunStep.READY); //대기상태로 전환한다
return;
}
@@ -213,6 +215,7 @@ namespace Project
return true;
}
void CheckAGVMoveTo(eGoDir dir)
{
//계속내려간다
@@ -233,15 +236,12 @@ namespace Project
{
PUB.log.Add($"마크정지를 해제하기 위해 장비를 멈춥니다");
}
//이동해야하는데 마크 스탑이 되어있다면 일단 멈춘다
}
else
{
//움직이지 않으므로 전진하도록 한다
PUB.log.Add($"AGV 기동 방향(DOWN):{dir}");
PUB.AGV.AGVMoveRun(arDev.Narumi.eRunOpt.Forward);//PUB.PLC.Move(Device.PLC.Rundirection.Backward, "UpdateMotionPosition(" + sender + ")");
PUB.AGV.AGVMoveRun(arDev.Narumi.eRunOpt.Forward);
}
LastCommandTime = DateTime.Now;
}
@@ -266,8 +266,7 @@ namespace Project
else
{
PUB.log.Add($"AGV 기동 방향(UP):{dir}");
PUB.AGV.AGVMoveRun(arDev.Narumi.eRunOpt.Backward);//PUB.PLC.Move(Device.PLC.Rundirection.Backward, "UpdateMotionPosition(" + sender + ")");
PUB.AGV.AGVMoveRun(arDev.Narumi.eRunOpt.Backward);
}
LastCommandTime = DateTime.Now;
}
@@ -546,5 +545,7 @@ namespace Project
return false;
}
}//cvass
}

View File

@@ -5,6 +5,7 @@ using System.Linq;
using System.Text;
using static Project.StateMachine;
using COMM;
using AR;
namespace Project
{
@@ -18,7 +19,7 @@ namespace Project
{
if (isFirst)
{
VAR.TIME.Set(eVarTime.ChargeEnd);
VAR.TIME.Update(eVarTime.ChargeEnd);
if (VAR.BOOL[eVarBool.FLAG_CHARGEONA])
{
PUB.Speak(Lang.);
@@ -44,7 +45,7 @@ namespace Project
{
PUB.log.Add("충전 해제 전송");
PUB.AGV.AGVCharge(PUB.setting.ChargerID, false);
VAR.TIME.Set(eVarTime.SendChargeOff);
VAR.TIME.Update(eVarTime.SendChargeOff);
}
}

View File

@@ -5,6 +5,7 @@ using System.Linq;
using System.Text;
using static Project.StateMachine;
using COMM;
using AR;
namespace Project
{
@@ -26,11 +27,7 @@ namespace Project
PUB.Result.SetResultMessage(eResult.Hardware, eECode.AGVCONN, eNextStep.ERROR);
return false;
}
else if (PUB.PLC.IsValid == false)
{
PUB.Result.SetResultMessage(eResult.Hardware, eECode.PLCCONN, eNextStep.ERROR);
return false;
}
//충전 상태가 OFF되어야 동작하게한다
if (_SM_RUN_CHGOFF(isFirst, stepTime) == false)
@@ -68,7 +65,7 @@ namespace Project
{
PUB.Speak(Lang.);
PUB.Result.TargetPos = ePosition.QC;
VAR.TIME.Set(eVarTime.ChargeSearch);
VAR.TIME.Update(eVarTime.ChargeSearch);
PUB.sm.UpdateRunStepSeq();
PUB.log.Add($"충전:대상위치 QC 시작");
return false;
@@ -114,7 +111,7 @@ namespace Project
});
PUB.AGV.AGVMoveRun(arDev.Narumi.eRunOpt.Forward);
//PUB.Result.TargetPos = ePosition.CHARGE;
VAR.TIME.Set(eVarTime.ChargeSearch);
VAR.TIME.Update(eVarTime.ChargeSearch);
}
else if (PUB.setting.chargerpos == 2) //up search
{
@@ -129,7 +126,7 @@ namespace Project
});
PUB.AGV.AGVMoveRun(arDev.Narumi.eRunOpt.Backward);
//PUB.Result.TargetPos = ePosition.CHARGE;
VAR.TIME.Set(eVarTime.ChargeSearch);
VAR.TIME.Update(eVarTime.ChargeSearch);
}
else
{
@@ -148,7 +145,7 @@ namespace Project
PUB.log.Add($"충전:AGV기동확인으로 마크정지신호설정");
PUB.Speak(Lang.);
PUB.AGV.AGVMoveStop("SM_RUN_GOCHARGE", arDev.Narumi.eStopOpt.MarkStop);
VAR.TIME.Set(eVarTime.ChargeSearch);
VAR.TIME.Update(eVarTime.ChargeSearch);
PUB.sm.UpdateRunStepSeq();
}
else
@@ -163,7 +160,7 @@ namespace Project
}
else
{
VAR.TIME.Set(eVarTime.ChargeSearch);
VAR.TIME.Update(eVarTime.ChargeSearch);
PUB.sm.UpdateRunStepSeq();
}

View File

@@ -5,6 +5,7 @@ using System.Linq;
using System.Text;
using static Project.StateMachine;
using COMM;
using AR;
namespace Project
{

View File

@@ -5,6 +5,7 @@ using System.Linq;
using System.Text;
using static Project.StateMachine;
using COMM;
using AR;
namespace Project
{
@@ -25,11 +26,7 @@ namespace Project
PUB.Result.SetResultMessage(eResult.Hardware, eECode.AGVCONN, eNextStep.ERROR);
return false;
}
else if (PUB.PLC.IsValid == false)
{
PUB.Result.SetResultMessage(eResult.Hardware, eECode.PLCCONN, eNextStep.ERROR);
return false;
}
//충전 상태가 OFF되어야 동작하게한다
if (_SM_RUN_CHGOFF(isFirst, stepTime) == false)
@@ -124,19 +121,19 @@ namespace Project
CoverControlTime = DateTime.Now;
UpdateProgressStatus(stepTime.TotalSeconds, 5, Lang.);
VAR.BOOL[eVarBool.WAIT_COVER_DOWN] = true;
PUB.PLC.ZMot(arDev.FakePLC.ZMotDirection.Down);//
PUB.AGV.LiftControl(arDev.Narumi.LiftCommand.DN);//
PUB.sm.UpdateRunStepSeq();
return false;
}
else if (PUB.sm.RunStepSeq == 7)
{
//커버 내림이 완료될때까지 기다린다
if (PUB.PLC.IsLimitDn() == true)
{
VAR.BOOL[eVarBool.WAIT_COVER_DOWN] = false;
PUB.sm.UpdateRunStepSeq();
}
else
//if (PUB.PLC.IsLimitDn() == true)
//{
// VAR.BOOL[eVarBool.WAIT_COVER_DOWN] = false;
// PUB.sm.UpdateRunStepSeq();
//}
//else
{
//경과시간이 10초가 지나면 5초마다 음성을 출력한다
var tsCover = DateTime.Now - CoverControlTime;
@@ -177,39 +174,39 @@ namespace Project
PUB.Speak(Lang.);
CoverControlTime = DateTime.Now;
//한쪽이 올라가 있는 상태에..
if (PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_LU) == true)
{
//모터는 올리는 방향일때에...
if (PUB.PLC.GetValueO(arDev.FakePLC.DOName.PINO_GUIDEMOTOR_LDIR) == true)
{
//모터가 멈춰있을때에..
if (PUB.PLC.GetValueO(arDev.FakePLC.DOName.PINO_GUIDEMOTOR_LRUN) == false)
{
//자동으로 올려준다 (센서가 간혹 인식이 안되어서 .대기하는 경우가 잇음)
////한쪽이 올라가 있는 상태에..
//if (PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_LU) == true)
//{
// //모터는 올리는 방향일때에...
// if (PUB.PLC.GetValueO(arDev.FakePLC.DOName.PINO_GUIDEMOTOR_LDIR) == true)
// {
// //모터가 멈춰있을때에..
// if (PUB.PLC.GetValueO(arDev.FakePLC.DOName.PINO_GUIDEMOTOR_LRUN) == false)
// {
// //자동으로 올려준다 (센서가 간혹 인식이 안되어서 .대기하는 경우가 잇음)
//왼쪽이 올라가 있지 않은 경우
if (PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_LU) == false)
PUB.PLC.ZMot_Left(arDev.FakePLC.ZMotDirection.Up);
}
}
}
if (PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_RU) == true)
{
//모터는 올리는 방향일때에...
if (PUB.PLC.GetValueO(arDev.FakePLC.DOName.PINO_GUIDEMOTOR_RDIR) == true)
{
//모터가 멈춰있을때에..
if (PUB.PLC.GetValueO(arDev.FakePLC.DOName.PINO_GUIDEMOTOR_RRUN) == false)
{
//자동으로 올려준다 (센서가 간혹 인식이 안되어서 .대기하는 경우가 잇음)
// //왼쪽이 올라가 있지 않은 경우
// if (PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_LU) == false)
// PUB.PLC.ZMot_Left(arDev.FakePLC.ZMotDirection.Up);
// }
// }
//}
//if (PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_RU) == true)
//{
// //모터는 올리는 방향일때에...
// if (PUB.PLC.GetValueO(arDev.FakePLC.DOName.PINO_GUIDEMOTOR_RDIR) == true)
// {
// //모터가 멈춰있을때에..
// if (PUB.PLC.GetValueO(arDev.FakePLC.DOName.PINO_GUIDEMOTOR_RRUN) == false)
// {
// //자동으로 올려준다 (센서가 간혹 인식이 안되어서 .대기하는 경우가 잇음)
//왼쪽이 올라가 있지 않은 경우
if (PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_RU) == false)
PUB.PLC.ZMot_Right(arDev.FakePLC.ZMotDirection.Up);
}
}
}
// //왼쪽이 올라가 있지 않은 경우
// if (PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_RU) == false)
// PUB.PLC.ZMot_Right(arDev.FakePLC.ZMotDirection.Up);
// }
// }
//}
}

View File

@@ -5,6 +5,7 @@ using System.Linq;
using System.Text;
using static Project.StateMachine;
using COMM;
using AR;
namespace Project
{
@@ -32,11 +33,7 @@ namespace Project
PUB.Result.SetResultMessage(eResult.Hardware, eECode.AGVCONN, eNextStep.ERROR);
return false;
}
else if (PUB.PLC.IsValid == false)
{
PUB.Result.SetResultMessage(eResult.Hardware, eECode.PLCCONN, eNextStep.ERROR);
return false;
}
//충전 상태가 OFF되어야 동작하게한다
if (_SM_RUN_CHGOFF(isFirst, stepTime) == false)

View File

@@ -5,6 +5,7 @@ using System.Linq;
using System.Text;
using static Project.StateMachine;
using COMM;
using AR;
namespace Project
{
@@ -25,12 +26,6 @@ namespace Project
PUB.Result.SetResultMessage(eResult.Hardware, eECode.AGVCONN, eNextStep.ERROR);
return false;
}
else if (PUB.PLC.IsValid == false)
{
PUB.Result.SetResultMessage(eResult.Hardware, eECode.PLCCONN, eNextStep.ERROR);
return false;
}
//충전 상태가 OFF되어야 동작하게한다
if (_SM_RUN_CHGOFF(isFirst, stepTime) == false)
@@ -111,7 +106,7 @@ namespace Project
//커버를 자동으로 내려준다
CoverControlTime = DateTime.Now;
UpdateProgressStatus(stepTime.TotalSeconds, 5, Lang.);
PUB.PLC.ZMot(arDev.FakePLC.ZMotDirection.Down);
PUB.AGV.LiftControl(arDev.Narumi.LiftCommand.DN);
VAR.BOOL[eVarBool.WAIT_COVER_DOWN] = true;
PUB.sm.UpdateRunStepSeq();
return false;
@@ -130,7 +125,7 @@ namespace Project
//커버 내림이 완료될때까지 기다린다
if (PUB.PLC.IsLimitDn() == true)
if (true)
{
VAR.BOOL[eVarBool.WAIT_COVER_DOWN] = false;
PUB.Result.NextPos = ePosition.NONE;
@@ -138,6 +133,8 @@ namespace Project
}
else
{
//경과시간이 10초가 지나면 5초마다 음성을 출력한다
var tsCover = DateTime.Now - CoverControlTime;
if (tsCover.TotalSeconds >= 7)
@@ -179,7 +176,7 @@ namespace Project
}
else if (PUB.sm.RunStepSeq == idx++)
{
//IO업데이트 간격 전송
UpdateProgressStatus(stepTime.TotalSeconds, 5, Lang.);
PUB.Speak(Lang.);
@@ -219,47 +216,47 @@ namespace Project
PUB.Speak(Lang.);
CoverControlTime = DateTime.Now;
//한쪽이 올라가 있는 상태에..
if (PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_LU) == true)
{
//모터는 올리는 방향일때에...
if (PUB.PLC.GetValueO(arDev.FakePLC.DOName.PINO_GUIDEMOTOR_LDIR) == true)
{
//모터가 멈춰있을때에..
if (PUB.PLC.GetValueO(arDev.FakePLC.DOName.PINO_GUIDEMOTOR_LRUN) == false)
{
//자동으로 올려준다 (센서가 간혹 인식이 안되어서 .대기하는 경우가 잇음)
////한쪽이 올라가 있는 상태에..
//if (PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_LU) == true)
//{
// //모터는 올리는 방향일때에...
// if (PUB.PLC.GetValueO(arDev.FakePLC.DOName.PINO_GUIDEMOTOR_LDIR) == true)
// {
// //모터가 멈춰있을때에..
// if (PUB.PLC.GetValueO(arDev.FakePLC.DOName.PINO_GUIDEMOTOR_LRUN) == false)
// {
// //자동으로 올려준다 (센서가 간혹 인식이 안되어서 .대기하는 경우가 잇음)
//왼쪽이 올라가 있지 않은 경우
if (PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_LU) == false)
PUB.PLC.ZMot_Left(arDev.FakePLC.ZMotDirection.Up);
// //왼쪽이 올라가 있지 않은 경우
// if (PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_LU) == false)
// PUB.PLC.ZMot_Left(arDev.FakePLC.ZMotDirection.Up);
//오른쪽이 올라가 있지 않은 경우
if (PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_RU) == false)
PUB.PLC.ZMot_Right(arDev.FakePLC.ZMotDirection.Up);
}
}
}
if (PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_RU) == true)
{
//모터는 올리는 방향일때에...
if (PUB.PLC.GetValueO(arDev.FakePLC.DOName.PINO_GUIDEMOTOR_RDIR) == true)
{
//모터가 멈춰있을때에..
if (PUB.PLC.GetValueO(arDev.FakePLC.DOName.PINO_GUIDEMOTOR_RRUN) == false)
{
//자동으로 올려준다 (센서가 간혹 인식이 안되어서 .대기하는 경우가 잇음)
// //오른쪽이 올라가 있지 않은 경우
// if (PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_RU) == false)
// PUB.PLC.ZMot_Right(arDev.FakePLC.ZMotDirection.Up);
// }
// }
//}
//if (PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_RU) == true)
//{
// //모터는 올리는 방향일때에...
// if (PUB.PLC.GetValueO(arDev.FakePLC.DOName.PINO_GUIDEMOTOR_RDIR) == true)
// {
// //모터가 멈춰있을때에..
// if (PUB.PLC.GetValueO(arDev.FakePLC.DOName.PINO_GUIDEMOTOR_RRUN) == false)
// {
// //자동으로 올려준다 (센서가 간혹 인식이 안되어서 .대기하는 경우가 잇음)
//왼쪽이 올라가 있지 않은 경우
if (PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_LU) == false)
PUB.PLC.ZMot_Left(arDev.FakePLC.ZMotDirection.Up);
// //왼쪽이 올라가 있지 않은 경우
// if (PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_LU) == false)
// PUB.PLC.ZMot_Left(arDev.FakePLC.ZMotDirection.Up);
//오른쪽이 올라가 있지 않은 경우
if (PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_RU) == false)
PUB.PLC.ZMot_Right(arDev.FakePLC.ZMotDirection.Up);
}
}
}
// //오른쪽이 올라가 있지 않은 경우
// if (PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_RU) == false)
// PUB.PLC.ZMot_Right(arDev.FakePLC.ZMotDirection.Up);
// }
// }
//}
}
}
return false;

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AR;
using COMM;
using static Project.StateMachine;
@@ -24,7 +25,7 @@ namespace Project
if (VAR.BOOL[eVarBool.FLAG_CHARGEONA] == true)
{
if (VAR.TIME.IsSet(eVarTime.ChargeStart) == false)
VAR.TIME.Set(eVarTime.ChargeStart);
VAR.TIME.Update(eVarTime.ChargeStart);
//충전중이라면 최대 충전 시간을 체크한다.
var tsChargeRunTime = VAR.TIME.RUN(eVarTime.ChargeStart);
@@ -53,7 +54,7 @@ namespace Project
else if (VAR.BOOL[eVarBool.FLAG_CHARGEONM] == true)
{
if (VAR.TIME.IsSet(eVarTime.ChargeStart) == false)
VAR.TIME.Set(eVarTime.ChargeStart);
VAR.TIME.Update(eVarTime.ChargeStart);
VAR.STR[eVarString.ChargeCheckMsg] = "수동 충전";
}
@@ -133,7 +134,7 @@ namespace Project
{
PUB.log.Add($"대기상태에서는 정차");
PUB.AGV.AGVMoveStop("대기상태에서는 정차");
VAR.TIME.Set(eVarTime.IdleStopTime);
VAR.TIME.Update(eVarTime.IdleStopTime);
}
}

View File

@@ -5,6 +5,7 @@ using System.Linq;
using System.Text;
using static Project.StateMachine;
using COMM;
using AR;
namespace Project
{

View File

@@ -6,6 +6,7 @@ using System.Text;
using static Project.StateMachine;
using COMM;
using System.Diagnostics;
using AR;
namespace Project
{

View File

@@ -15,7 +15,7 @@ namespace Project
private void _STEP_CLOSING_START(eSMStep step)
{
PUB.bShutdown = true;
if (PUB.PLC != null) PUB.PLC.Dispose();
//if (PUB.PLC != null) PUB.PLC.Dispose();
PUB.AddEEDB("프로그램 종료");
PUB.log.Add("Program Close");
@@ -23,7 +23,7 @@ namespace Project
PUB.logagv.Flush();
PUB.logplc.Flush();
PUB.logbms.Flush();
PUB.logcal.Flush();
PUB.logxbee.Flush();
// PUB.sm.Stop();
}

View File

@@ -7,6 +7,7 @@ using System.Text;
using arCtl;
using static Project.StateMachine;
using COMM;
using AR;
namespace Project
{

View File

@@ -7,6 +7,7 @@ using System.Text;
using arCtl;
using static Project.StateMachine;
using COMM;
using AR;
namespace Project
{

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using AR;
using arDev;
using COMM;
@@ -46,7 +47,7 @@ namespace Project
if (VAR.BOOL[eVarBool.WAIT_COVER_UP])
{
PUB.log.Add($"버튼({diName}) 눌림");
PUB.PLC.ZMot(FakePLC.ZMotDirection.Up);
PUB.AGV.LiftControl(arDev.Narumi.LiftCommand.UP);
PUB.Result.NextPos = ePosition.QC;
}
else PUB.Speak(Lang.);
@@ -92,7 +93,7 @@ namespace Project
if (VAR.BOOL[eVarBool.WAIT_COVER_UP])
{
PUB.log.Add($"버튼({diName}) 눌림");
PUB.PLC.ZMot(FakePLC.ZMotDirection.Up);
PUB.AGV.LiftControl(arDev.Narumi.LiftCommand.UP);
PUB.Result.NextPos = ePosition.QA;
}
else PUB.Speak(Lang.);
@@ -120,7 +121,7 @@ namespace Project
{
//Z-up기능으로 업데이트 230119
PUB.log.Add($"버튼({diName}) 눌림");
PUB.PLC.ZMot(FakePLC.ZMotDirection.Up);
PUB.AGV.LiftControl(arDev.Narumi.LiftCommand.UP);
}
}
else if (diName == arDev.FakePLC.DIName.PINI_EMG)
@@ -172,8 +173,8 @@ namespace Project
//}
//PUB.flag.set(EFlag.FLAG_LIMITHIGH, (PUB.flag.get(EFlag.FLAG_LIMITHIGHL) && PUB.flag.get(EFlag.FLAG_LIMITHIGHR)));
//PUB.flag.set(EFlag.FLAG_LIMITLOW, (PUB.flag.get(EFlag.FLAG_LIMITLOWL) && PUB.flag.get(EFlag.FLAG_LIMITLOWR)));
VAR.BOOL[eVarBool.FLAG_LIMITHIGH] = PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_LU) || PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_RU);
VAR.BOOL[eVarBool.FLAG_LIMITLOW] = PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_LD) || PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_RD);
VAR.BOOL[eVarBool.FLAG_LIMITHIGH] = false;// PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_LU) || PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_RU);
VAR.BOOL[eVarBool.FLAG_LIMITLOW] = false;//PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_LD) || PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_LIMIT_RD);
VAR.BOOL[eVarBool.OVERLOAD] = (VAR.BOOL[eVarBool.OVERLOADL] || VAR.BOOL[eVarBool.OVERLOADR]);
}
else
@@ -189,109 +190,7 @@ namespace Project
DateTime lastplclogtime = DateTime.Now;
string logmessage = "";
bool logerror = false;
void PLC_Message(object sender, FakePLC.MessageEventArgs e)
{
if (e.MsgType == arRS232.MessageType.Error)
{
PUB.logplc.Add("ERROR-MAIN", e.Message);
}
else if (e.MsgType == arRS232.MessageType.Normal)
{
//내부클래스에서 발생한 메세지(이 프로그램)
if (e.Message.StartsWith("@STP:") && e.Message.Length > 5)
{
PUB.Result.StopMessageSWR = e.Message.Substring(5);
PUB.Result.StopMessageTimeSWR = DateTime.Now;
}
PUB.logplc.Add("MOT", "[Inner Msg]" + e.Message);
}
else
{
//PLC에서 수신된 메세지
if (e.Message.StartsWith("@STP|") && e.Message.Length > 5)
{
PUB.Result.StopMessagePLC = e.Message.Substring(5);
PUB.Result.StopMessageTimePLC = DateTime.Now;
PUB.logplc.Add("PLC", "[" + e.MsgType.ToString() + "]" + e.Message);
}
else if (e.Message.StartsWith("@FLAG|") && e.Message.Length > 6)
{
var flagData = e.Message.Split('|')[1].Split(',');
var flag = (COMM.eVarBool)(byte.Parse(flagData[0]));
var flagmsg = "[" + flag.ToString() + "] = " + flagData[1];
//플래그값이 바뀌면 로깅한다
var fValueTrue = flagData[1] == "1";
if (PUB.PLC.GetFlag(flag) != fValueTrue)
{
PUB.logplc.Add("MFLAG", flagmsg);
}
}
else if (e.Message.StartsWith("@SET|") && e.Message.Length > 5)
{
//셋팅관련 정보이다
var flagData = e.Message.Split('|')[1];
var splBuf = flagData.Split(':');
if (splBuf[0] == "SAVE") PUB.PLC.SaveTime = DateTime.Now;
PUB.logplc.Add("SETUP", "[SETTING] " + flagData);
}
else
{
if (e.Message.StartsWith("ERR"))
{
logmessage = e.Message;
logerror = true;
}
else if (e.Message.StartsWith("@@") & e.Data.Length == 16)
{
//표시하지 말자
logerror = false;
var hexstr = e.Data.GetHexString();
logmessage = "[" + e.MsgType.ToString() + "]" + hexstr;
}
else
{
logmessage = "[" + e.MsgType.ToString() + "]" + e.Message;
logerror = false;
}
bool addlog = false;
if (lastplclogmessage.StartsWith("[Recv] 40 40"))
{
if (lastplclogmessage.Length > 40)
{
var st = lastplclogmessage.Substring(0, 40);
var cr = logmessage.Substring(0, 40);
addlog = st.Equals(cr) == false;
if (addlog == false)
{
var ts = DateTime.Now - lastplclogtime;
if (ts.TotalSeconds > 5) addlog = true;
}
}
else addlog = true;
}
else if (logmessage.Equals(lastplclogmessage) == false) addlog = true;
else
{
var ts = DateTime.Now - lastplclogtime;
if (ts.TotalSeconds > 30) addlog = true;
}
if (addlog)
{
if (logerror) PUB.logplc.AddE(logmessage);
else PUB.logplc.Add("PLC", logmessage);
lastplclogmessage = logmessage;
lastplclogtime = DateTime.Now;
}
}
}
}
}
}

View File

@@ -1,4 +1,5 @@
using COMM;
using AR;
using COMM;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -62,7 +63,7 @@ namespace Project
{
if (NewValue)
{
VAR.TIME.Set(eVarTime.ChargeStart);
VAR.TIME.Update(eVarTime.ChargeStart);
PUB.counter.CountChargeA += 1;
PUB.counter.Save();
PUB.Speak(Lang.);
@@ -76,7 +77,7 @@ namespace Project
{
if (NewValue)
{
VAR.TIME.Set(eVarTime.ChargeStart);
VAR.TIME.Update(eVarTime.ChargeStart);
PUB.counter.CountChargeM += 1;
PUB.counter.Save();
PUB.Speak(Lang.);

View File

@@ -9,6 +9,7 @@ using static Project.StateMachine;
using COMM;
using System.Windows.Forms;
using Project.ViewForm;
using AR;
namespace Project
{
@@ -179,7 +180,7 @@ namespace Project
{
var b1 = PUB.XBE.IsOpen;
var b2 = PUB.AGV.IsOpen;
var b3 = PUB.PLC.IsOpen;
var b3 = true;// PUB.PLC.IsOpen;
var b4 = PUB.BMS.IsOpen;
if (b1 == false || b2 == false || b3 == false || b4 == false)

View File

@@ -4,6 +4,7 @@ using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using AR;
using arCtl;
using COMM;
using static Project.StateMachine;
@@ -23,10 +24,10 @@ namespace Project
var tsPLC = VAR.TIME.RUN(conntry);
if (tsPLC.TotalSeconds > 5)
{
VAR.TIME.Set(conntry);
VAR.TIME.Update(conntry);
try
{
VAR.TIME.Set(recvtime); //this.LastReceiveTime = DateTime.Now;
VAR.TIME.Update(recvtime); //this.LastReceiveTime = DateTime.Now;
dev.PortName = port;
dev.BaudRate = baud;
if (dev.Open())
@@ -38,8 +39,8 @@ namespace Project
var errmessage = dev.errorMessage;
PUB.log.Add("ERROR-" + port, errmessage);
}
VAR.TIME.Set(conn);
VAR.TIME.Set(conntry);
VAR.TIME.Update(conn);
VAR.TIME.Update(conntry);
}
catch (Exception ex)
{
@@ -51,17 +52,53 @@ namespace Project
{
PUB.log.Add(port, $"포트변경({dev.PortName}->{port})으로 연결 종료");
dev.Close();
VAR.TIME.Set(conntry);
VAR.TIME.Update(conntry);
}
}
void ConnectSerialPort(Device.Xbee dev, string port, int baud, eVarTime conn, eVarTime conntry, eVarTime recvtime)
{
if (dev.IsOpen == false && port.isEmpty() == false)
{
var tsPLC = VAR.TIME.RUN(conntry);
if (tsPLC.TotalSeconds > 5)
{
VAR.TIME.Update(conntry);
try
{
VAR.TIME.Update(recvtime); //this.LastReceiveTime = DateTime.Now;
dev.PortName = port;
dev.BaudRate = baud;
if (dev.Open())
{
PUB.log.Add(port, "연결완료");
}
else
{
var errmessage = dev.errorMessage;
PUB.log.Add("ERROR-" + port, errmessage);
}
VAR.TIME.Update(conn);
VAR.TIME.Update(conntry);
}
catch (Exception ex)
{
PUB.log.AddE(ex.Message);
}
}
}
else if (dev.PortName.Equals(port) == false)
{
PUB.log.Add(port, $"포트변경({dev.PortName}->{port})으로 연결 종료");
dev.Close();
VAR.TIME[(int)conntry] = DateTime.Now; ;
}
}
void sm_SPS(object sender, EventArgs e)
{
if (PUB.sm.Step < eSMStep.IDLE || PUB.sm.Step >= eSMStep.CLOSING) return;
//plc connect
ConnectSerialPort(PUB.PLC, PUB.setting.Port_PLC, PUB.setting.Baud_PLC,
eVarTime.LastConn_PLC, eVarTime.LastConnTry_PLC, eVarTime.LastRecv_PLC);
//agv connect
ConnectSerialPort(PUB.AGV, PUB.setting.Port_AGV, PUB.setting.Baud_AGV,
eVarTime.LastConn_AGV, eVarTime.LastConnTry_AGV, eVarTime.LastRecv_AGV);
@@ -78,14 +115,14 @@ namespace Project
if (PUB.XBE != null && PUB.XBE.IsOpen)
{
//일정간격으로 상태를 전송한다
if (PUB.XBE.lastSendTime.Year == 1982) PUB.XBE.lastSendTime = DateTime.Now.AddSeconds(1);
var ts = DateTime.Now - PUB.XBE.lastSendTime;
if (PUB.XBE.LastStatusSendTime.Year == 1982) PUB.XBE.LastStatusSendTime = DateTime.Now.AddSeconds(1);
var ts = DateTime.Now - PUB.XBE.LastStatusSendTime;
if (ts.TotalSeconds >= PUB.setting.interval_xbe)
{
var statusMsg = PUB.XBE.GetStatusString();
PUB.XBE.SendStatus(statusMsg);
PUB.XBE.SendStatus();
}
}
//배터리쿼리
if (PUB.BMS != null && PUB.BMS.IsOpen)
{

View File

@@ -1,4 +1,5 @@
using COMM;
using AR;
using COMM;
using System;
using System.Drawing;
using static Project.StateMachine;
@@ -231,7 +232,7 @@ namespace Project
//hw접속상태 표시
MenuAGV.BackColor = PUB.AGV.IsValid ? Color.FromArgb(40, 40, 40) : Color.Brown;
MenuBMS.BackColor = PUB.BMS.IsValid ? Color.FromArgb(40, 40, 40) : Color.Brown;
MenuMAN.BackColor = PUB.PLC.IsValid ? Color.FromArgb(40, 40, 40) : Color.Brown;
MenuMAN.BackColor = PUB.AGV.IsValid ? Color.FromArgb(40, 40, 40) : Color.Brown;
btChargeA.Enabled = !VAR.BOOL[eVarBool.FLAG_CHARGEONM];
@@ -296,7 +297,7 @@ namespace Project
_AutoResetCount();
//상태를 DB에 저장한다. 230314
var tsrun = COMM.VAR.TIME.RUN(eVarTime.StatusReporttime);
var tsrun = VAR.TIME.RUN(eVarTime.StatusReporttime);
if (tsrun.TotalSeconds >= PUB.setting.StatusInterval) EEMStatus.UpdateStatusSQL(PUB.sm.Step, _extrun: true);
tm1minute = DateTime.Now;
@@ -410,7 +411,7 @@ namespace Project
}
VAR.TIME.Set(eVarTime.BatWarnTime);
VAR.TIME.Update(eVarTime.BatWarnTime);
}
}
}
@@ -580,14 +581,14 @@ namespace Project
UpdateStatusMessage("비상 정지", Color.Tomato, Color.Black);
}
}
else if (PUB.PLC.IsOpen == false)
{
UpdateStatusMessage(Lang.PLC연결실패, Color.Tomato, Color.Black);
}
else if (PUB.PLC.IsValid == false)
{
UpdateStatusMessage(Lang.PLC통신실패, Color.Tomato, Color.Black);
}
//else if (PUB.PLC.IsOpen == false)
//{
// UpdateStatusMessage(Lang.PLC연결실패, Color.Tomato, Color.Black);
//}
//else if (PUB.PLC.IsValid == false)
//{
// UpdateStatusMessage(Lang.PLC통신실패, Color.Tomato, Color.Black);
//}
else if (VAR.BOOL[eVarBool.FLAG_CHARGEONA] == true)
{
//남은 충전시간 계산
@@ -646,8 +647,8 @@ namespace Project
string stMsg;
if (PUB.AGV.system1.stop_by_front_detect)//.GetValueI(arDev.FakePLC.DIName.PINI_LIDAR_STOP))
stMsg = Lang.;
else if (PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_EMG))
stMsg = Lang.;
//else if (PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_EMG))
// stMsg = Lang.비상정지신호가감지되었습니다;
else if (PUB.AGV.signal.front_gate_out == true)
stMsg = Lang.;
else if (PUB.AGV.error.runerror_by_no_magent_line)

View File

@@ -9,6 +9,7 @@ using System.Threading.Tasks;
using System.Windows.Forms;
using static Project.StateMachine;
using COMM;
using AR;
namespace Project.ViewForm
{
@@ -28,7 +29,7 @@ namespace Project.ViewForm
private void fAuto_Load(object sender, EventArgs e)
{
ctlAuto1.dev_agv = PUB.AGV;
ctlAuto1.dev_plc = PUB.PLC;
// ctlAuto1.dev_plc = PUB.PLC;
ctlAuto1.dev_bms = PUB.BMS;
ctlAuto1.dev_xbe = PUB.XBE;
this.timer1.Start();
@@ -40,7 +41,7 @@ namespace Project.ViewForm
{
PUB.log.Add("ui reset click");
PUB.AGV.AGVErrorReset();
}
}
}
private void Sm_StepChanged(object sender, StepChangeEventArgs e)
@@ -52,7 +53,7 @@ namespace Project.ViewForm
}
private void FAuto_FormClosed(object sender, FormClosedEventArgs e)
{
{
timer1.Stop();
PUB.sm.StepChanged -= Sm_StepChanged;
this.ctlAuto1.ButtonClick -= CtlAuto1_ButtonClick;
@@ -67,21 +68,13 @@ namespace Project.ViewForm
this.ctlAuto1.OnUpdateMode = true;
//lbBatteryLevel.Text = $"{PUB.BMS.Current_Level}%";
//lbBatteryLevel.ProgressValue = PUB.BMS.Current_Level;
if(this.ctlAuto1.Scean == CtlAuto.eScean.Progress)
if (this.ctlAuto1.Scean == CtlAuto.eScean.Progress)
{
ctlAuto1.ProgressVal = PUB.Result.SMSG_ProgressValue;
ctlAuto1.ProgressMax = PUB.Result.SMSG_ProgressMax;
ctlAuto1.StatusMessage = VAR.STR?.Get(eVarString.StatusMessage) ?? string.Empty;
}
//if(Pub.Result.StopMessagePLC.StartsWith()
if (PUB.PLC.GetValueI(arDev.FakePLC.DIName.PINI_EMG) == true)
this.ctlAuto1.StopMessage = PUB.Result.StopMessagePLC;
else
this.ctlAuto1.StopMessage = string.Empty;
this.ctlAuto1.StopMessage = string.Empty;
if (PUB.sm.Step == StateMachine.eSMStep.RUN)
{

View File

@@ -7,6 +7,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using AR;
using COMM;
namespace Project.ViewForm

View File

@@ -29,28 +29,29 @@
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
arFrame.Control.ColorListItem colorListItem1 = new arFrame.Control.ColorListItem();
arFrame.Control.ColorListItem colorListItem2 = new arFrame.Control.ColorListItem();
arFrame.Control.ColorListItem colorListItem3 = new arFrame.Control.ColorListItem();
arFrame.Control.ColorListItem colorListItem4 = new arFrame.Control.ColorListItem();
arFrame.Control.ColorListItem colorListItem5 = new arFrame.Control.ColorListItem();
arFrame.Control.ColorListItem colorListItem6 = new arFrame.Control.ColorListItem();
arFrame.Control.ColorListItem colorListItem7 = new arFrame.Control.ColorListItem();
arFrame.Control.ColorListItem colorListItem8 = new arFrame.Control.ColorListItem();
arFrame.Control.ColorListItem colorListItem25 = new arFrame.Control.ColorListItem();
arFrame.Control.ColorListItem colorListItem26 = new arFrame.Control.ColorListItem();
arFrame.Control.ColorListItem colorListItem27 = new arFrame.Control.ColorListItem();
arFrame.Control.ColorListItem colorListItem28 = new arFrame.Control.ColorListItem();
arFrame.Control.ColorListItem colorListItem29 = new arFrame.Control.ColorListItem();
arFrame.Control.ColorListItem colorListItem30 = new arFrame.Control.ColorListItem();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(fIO));
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.HWState = new arFrame.Control.GridView();
this.tblMain = new arFrame.Control.GridView();
this.panel1 = new System.Windows.Forms.Panel();
this.label1 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.panel3 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.button4 = new System.Windows.Forms.Button();
this.button5 = new System.Windows.Forms.Button();
this.tableLayoutPanel1.SuspendLayout();
this.panel1.SuspendLayout();
this.panel3.SuspendLayout();
this.panel2.SuspendLayout();
this.SuspendLayout();
//
@@ -59,8 +60,8 @@
this.tableLayoutPanel1.ColumnCount = 1;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.Controls.Add(this.HWState, 0, 2);
this.tableLayoutPanel1.Controls.Add(this.tblMain, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.panel1, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.panel3, 0, 1);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
@@ -68,38 +69,38 @@
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 58F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(957, 583);
this.tableLayoutPanel1.Size = new System.Drawing.Size(1056, 583);
this.tableLayoutPanel1.TabIndex = 5;
//
// HWState
//
this.HWState.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.HWState.BorderSize = 0;
colorListItem1.BackColor1 = System.Drawing.Color.Gray;
colorListItem1.BackColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(100)))), ((int)(((byte)(100)))));
colorListItem1.Remark = "타이틀바(상)";
colorListItem2.BackColor1 = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
colorListItem2.BackColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
colorListItem2.Remark = "상태표시(하)";
colorListItem3.BackColor1 = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
colorListItem3.BackColor2 = System.Drawing.Color.Lime;
colorListItem3.Remark = "정상";
colorListItem4.BackColor1 = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
colorListItem4.BackColor2 = System.Drawing.Color.Red;
colorListItem4.Remark = "오류";
colorListItem5.BackColor1 = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
colorListItem5.BackColor2 = System.Drawing.Color.Yellow;
colorListItem5.Remark = "오류(깜박)";
colorListItem6.BackColor1 = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
colorListItem6.BackColor2 = System.Drawing.Color.DarkViolet;
colorListItem6.Remark = "오류(유효)";
colorListItem25.BackColor1 = System.Drawing.Color.Gray;
colorListItem25.BackColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(100)))), ((int)(((byte)(100)))));
colorListItem25.Remark = "타이틀바(상)";
colorListItem26.BackColor1 = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
colorListItem26.BackColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
colorListItem26.Remark = "상태표시(하)";
colorListItem27.BackColor1 = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
colorListItem27.BackColor2 = System.Drawing.Color.Lime;
colorListItem27.Remark = "정상";
colorListItem28.BackColor1 = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
colorListItem28.BackColor2 = System.Drawing.Color.Red;
colorListItem28.Remark = "오류";
colorListItem29.BackColor1 = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
colorListItem29.BackColor2 = System.Drawing.Color.Yellow;
colorListItem29.Remark = "오류(깜박)";
colorListItem30.BackColor1 = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
colorListItem30.BackColor2 = System.Drawing.Color.DarkViolet;
colorListItem30.Remark = "오류(유효)";
this.HWState.ColorList = new arFrame.Control.ColorListItem[] {
colorListItem1,
colorListItem2,
colorListItem3,
colorListItem4,
colorListItem5,
colorListItem6};
colorListItem25,
colorListItem26,
colorListItem27,
colorListItem28,
colorListItem29,
colorListItem30};
this.HWState.Dock = System.Windows.Forms.DockStyle.Fill;
this.HWState.Font = new System.Drawing.Font("Consolas", 13F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.HWState.FontPin = new System.Drawing.Font("Consolas", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
@@ -107,7 +108,7 @@
this.HWState.ForeColorPin = System.Drawing.Color.Moccasin;
this.HWState.Location = new System.Drawing.Point(0, 525);
this.HWState.Margin = new System.Windows.Forms.Padding(0);
this.HWState.MatrixSize = new System.Drawing.Point(4, 2);
this.HWState.MatrixSize = new System.Drawing.Point(3, 2);
this.HWState.MenuBorderSize = 1;
this.HWState.MenuGap = 5;
this.HWState.MinimumSize = new System.Drawing.Size(100, 0);
@@ -128,61 +129,21 @@
this.HWState.ShadowColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.HWState.showDebugInfo = false;
this.HWState.ShowIndexString = false;
this.HWState.Size = new System.Drawing.Size(957, 58);
this.HWState.Size = new System.Drawing.Size(1056, 58);
this.HWState.TabIndex = 9;
this.HWState.Tags = null;
this.HWState.Text = "gridView3";
this.HWState.TextAttachToImage = true;
this.HWState.Titles = new string[] {
"AGV|XBE|PLC|BAT|",
"C00|C00|C00|C00|"};
"AGV|XBE|BAT|",
"C00|C00|C00|"};
this.HWState.Values = new ushort[] {
((ushort)(0)),
((ushort)(0)),
((ushort)(0)),
((ushort)(0)),
((ushort)(1)),
((ushort)(1)),
((ushort)(1)),
((ushort)(1))};
//
// tblMain
//
this.tblMain.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(100)))), ((int)(((byte)(100)))));
this.tblMain.BorderSize = 1;
colorListItem7.BackColor1 = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
colorListItem7.BackColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(18)))), ((int)(((byte)(18)))), ((int)(((byte)(18)))));
colorListItem7.Remark = "";
colorListItem8.BackColor1 = System.Drawing.Color.Orange;
colorListItem8.BackColor2 = System.Drawing.Color.DarkOrange;
colorListItem8.Remark = "";
this.tblMain.ColorList = new arFrame.Control.ColorListItem[] {
colorListItem7,
colorListItem8};
this.tblMain.Cursor = System.Windows.Forms.Cursors.Arrow;
this.tblMain.Dock = System.Windows.Forms.DockStyle.Fill;
this.tblMain.Font = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.tblMain.FontPin = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Bold);
this.tblMain.ForeColor = System.Drawing.Color.White;
this.tblMain.ForeColorPin = System.Drawing.Color.WhiteSmoke;
this.tblMain.Location = new System.Drawing.Point(3, 23);
this.tblMain.MatrixSize = new System.Drawing.Point(8, 4);
this.tblMain.MenuBorderSize = 1;
this.tblMain.MenuGap = 5;
this.tblMain.MinimumSize = new System.Drawing.Size(100, 50);
this.tblMain.Name = "tblMain";
this.tblMain.Names = null;
this.tblMain.ShadowColor = System.Drawing.Color.Black;
this.tblMain.showDebugInfo = false;
this.tblMain.ShowIndexString = true;
this.tblMain.Size = new System.Drawing.Size(951, 499);
this.tblMain.TabIndex = 4;
this.tblMain.Tags = null;
this.tblMain.Text = "gridView1";
this.tblMain.TextAttachToImage = true;
this.tblMain.Titles = null;
this.tblMain.Values = null;
this.tblMain.ItemClick += new System.EventHandler<arFrame.Control.GridView.ItemClickEventArgs>(this.tblIn1_ItemClick);
//
// panel1
//
@@ -191,7 +152,7 @@
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(3, 3);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(951, 14);
this.panel1.Size = new System.Drawing.Size(1050, 14);
this.panel1.TabIndex = 6;
//
// label1
@@ -200,7 +161,7 @@
this.label1.ForeColor = System.Drawing.Color.White;
this.label1.Location = new System.Drawing.Point(0, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(551, 14);
this.label1.Size = new System.Drawing.Size(650, 14);
this.label1.TabIndex = 5;
this.label1.Text = "label1";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
@@ -209,17 +170,23 @@
//
this.label3.Dock = System.Windows.Forms.DockStyle.Right;
this.label3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));
this.label3.Location = new System.Drawing.Point(551, 0);
this.label3.Location = new System.Drawing.Point(650, 0);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(400, 14);
this.label3.TabIndex = 6;
this.label3.Text = "label3";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// timer1
// panel3
//
this.timer1.Interval = 200;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
this.panel3.Controls.Add(this.button5);
this.panel3.Controls.Add(this.button4);
this.panel3.Controls.Add(this.panel2);
this.panel3.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel3.Location = new System.Drawing.Point(3, 23);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(1050, 499);
this.panel3.TabIndex = 10;
//
// panel2
//
@@ -227,10 +194,9 @@
this.panel2.Controls.Add(this.button2);
this.panel2.Controls.Add(this.button3);
this.panel2.Controls.Add(this.button1);
this.panel2.Dock = System.Windows.Forms.DockStyle.Right;
this.panel2.Location = new System.Drawing.Point(957, 0);
this.panel2.Location = new System.Drawing.Point(925, 15);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(99, 583);
this.panel2.Size = new System.Drawing.Size(99, 315);
this.panel2.TabIndex = 6;
//
// button2
@@ -239,7 +205,7 @@
this.button2.Image = ((System.Drawing.Image)(resources.GetObject("button2.Image")));
this.button2.Location = new System.Drawing.Point(0, 100);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(99, 383);
this.button2.Size = new System.Drawing.Size(99, 115);
this.button2.TabIndex = 1;
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
@@ -248,7 +214,7 @@
//
this.button3.Dock = System.Windows.Forms.DockStyle.Bottom;
this.button3.Image = ((System.Drawing.Image)(resources.GetObject("button3.Image")));
this.button3.Location = new System.Drawing.Point(0, 483);
this.button3.Location = new System.Drawing.Point(0, 215);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(99, 100);
this.button3.TabIndex = 2;
@@ -266,13 +232,37 @@
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// timer1
//
this.timer1.Interval = 200;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// button4
//
this.button4.Location = new System.Drawing.Point(726, 53);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(134, 100);
this.button4.TabIndex = 7;
this.button4.Text = "Magnet On";
this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// button5
//
this.button5.Location = new System.Drawing.Point(726, 159);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(134, 100);
this.button5.TabIndex = 8;
this.button5.Text = "Magnet Off";
this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// fIO
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(15)))), ((int)(((byte)(15)))), ((int)(((byte)(15)))));
this.ClientSize = new System.Drawing.Size(1056, 583);
this.Controls.Add(this.tableLayoutPanel1);
this.Controls.Add(this.panel2);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "fIO";
this.Text = "fIO";
@@ -280,14 +270,13 @@
this.VisibleChanged += new System.EventHandler(this.fIO_VisibleChanged);
this.tableLayoutPanel1.ResumeLayout(false);
this.panel1.ResumeLayout(false);
this.panel3.ResumeLayout(false);
this.panel2.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private arFrame.Control.GridView tblMain;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.Label label1;
@@ -298,5 +287,8 @@
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Button button5;
}
}

View File

@@ -16,7 +16,6 @@ namespace Project.ViewForm
{
InitializeComponent();
tblMain.SuspendLayout();
//이름설정 INput #1
List<string> namearray = new List<string>(32);
@@ -50,25 +49,17 @@ namespace Project.ViewForm
}
namearray.Add(flagName);
}
this.tblMain.setTitle(namearray.ToArray());
this.tblMain.setTag(tagarray.ToArray());
this.tblMain.setItemTextAlign(ContentAlignment.BottomLeft);
////값설정
//List<Boolean> fgValueM = new List<bool>();
//List<Boolean> fgValueS = new List<bool>();
////mainplc
//for (byte i = 0; i < 16; i++)
// fgValueM.Add(PUB.PLC.GetValueI(i));
//for (byte i = 0; i < 16; i++)
// fgValueM.Add(PUB.PLC.GetValueO(i));
//값설정
List<Boolean> fgValueM = new List<bool>();
List<Boolean> fgValueS = new List<bool>();
//mainplc
for (byte i = 0; i < 16; i++)
fgValueM.Add(PUB.PLC.GetValueI(i));
for (byte i = 0; i < 16; i++)
fgValueM.Add(PUB.PLC.GetValueO(i));
tblMain.setValue(fgValueM.ToArray());
tblMain.ResumeLayout();
this.FormClosed += FIO_FormClosed;
UpdateControl();
@@ -85,8 +76,8 @@ namespace Project.ViewForm
if (PUB.XBE.IsOpen == false) BlinkGridViewItem(HWState, rownum, colIdx++, 3, 4);
else HWState.setValue(rownum, colIdx++, 2); //
if (PUB.PLC.IsOpen == false) BlinkGridViewItem(HWState, rownum, colIdx++, 3, 4);
else HWState.setValue(rownum, colIdx++, 2); //
//if (PUB.PLC.IsOpen == false) BlinkGridViewItem(HWState, rownum, colIdx++, 3, 4);
//else HWState.setValue(rownum, colIdx++, 2); //
if (PUB.BMS.IsOpen == false) BlinkGridViewItem(HWState, rownum, colIdx++, 3, 4);
else HWState.setValue(rownum, colIdx++, 2); //
@@ -103,13 +94,13 @@ namespace Project.ViewForm
var colIdx = 0;
HWState.setTitle(0, colIdx++, "AGV");
HWState.setTitle(0, colIdx++, "XBE");
HWState.setTitle(0, colIdx++, "PLC");
//HWState.setTitle(0, colIdx++, "PLC");
HWState.setTitle(0, colIdx++, "BAT");
colIdx = 0;
HWState.setTitle(rowNum, colIdx++, PUB.setting.Port_AGV);
HWState.setTitle(rowNum, colIdx++, PUB.setting.Port_XBE);
HWState.setTitle(rowNum, colIdx++, PUB.setting.Port_PLC);
//HWState.setTitle(rowNum, colIdx++, PUB.setting.Port_PLC);
HWState.setTitle(rowNum, colIdx++, PUB.setting.Port_BAT);
HWState.Invalidate();
@@ -126,27 +117,7 @@ namespace Project.ViewForm
}
private void tblIn1_ItemClick(object sender, arFrame.Control.GridView.ItemClickEventArgs e)
{
var dataIndex = (byte)e.idx;
if (dataIndex >= 16)
{
var ctl = sender as arFrame.Control.GridView;
var pinNoStr = ctl.Tags[e.idx];
if (pinNoStr.isEmpty() == true)
{
Util.MsgE("해당 포트는 핀번호가 설정되지 않았습니다", true);
}
else
{
var pinNo = byte.Parse(pinNoStr);
var curVal = PUB.PLC.GetValueO((byte)(dataIndex - 16));
PUB.PLC.SetOutput(pinNo, !curVal);// .Sendcommand(Device.PLC1.eCommand.SET_DOUTPUT, pinNo, newval);
}
}
else Util.MsgE("해당 주소는 허용되지 않습니다.", true);
}
bool tmrun = false;
@@ -156,24 +127,11 @@ namespace Project.ViewForm
if (tmrun == true) return;
tmrun = true;
label1.Text = string.Format("{0} / {1}",
PUB.PLC.ioBinStr, PUB.PLC.SetupStr);
label3.Text = PUB.PLC.LastMessage;
Update_HWStatus();
List<Boolean> fgValueM = new List<bool>();
List<Boolean> fgValueS = new List<bool>();
//mainplc
for (byte i = 0; i < 16; i++)
this.tblMain.setValue(i, PUB.PLC.GetValueI(i));
for (byte i = 0; i < 16; i++)
this.tblMain.setValue(i + 16, PUB.PLC.GetValueO(i));
this.tblMain.Invalidate();
tmrun = false;
}
@@ -187,18 +145,28 @@ namespace Project.ViewForm
private void button1_Click(object sender, EventArgs e)
{
PUB.PLC.ZMot(arDev.FakePLC.ZMotDirection.Up);
PUB.AGV.LiftControl(arDev.Narumi.LiftCommand.UP);
}
private void button2_Click(object sender, EventArgs e)
{
PUB.PLC.ZMot(arDev.FakePLC.ZMotDirection.Stop);
PUB.AGV.LiftControl(arDev.Narumi.LiftCommand.STP);
}
private void button3_Click_1(object sender, EventArgs e)
{
PUB.PLC.ZMot(arDev.FakePLC.ZMotDirection.Down);
PUB.AGV.LiftControl(arDev.Narumi.LiftCommand.DN);
}
private void button4_Click(object sender, EventArgs e)
{
PUB.AGV.LiftControl(arDev.Narumi.LiftCommand.ON);
}
private void button5_Click(object sender, EventArgs e)
{
PUB.AGV.LiftControl(arDev.Narumi.LiftCommand.OFF);
}
}
}

View File

@@ -117,9 +117,6 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="button2.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
@@ -211,4 +208,7 @@
iAXpTl+ARH8vfFW5YszxNxI+Afqdj2aEL3vaoNP9AxkclDhe7/QIAAAAAElFTkSuQmCC
</value>
</data>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@@ -7,6 +7,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using AR;
using arDev;
using COMM;
@@ -330,25 +331,7 @@ namespace Project.ViewForm
}
private void button2_Click(object sender, EventArgs e)
{
PUB.AGV.AGVCommand("SCK", "0010");
}
private void button2_Click_1(object sender, EventArgs e)
{
PUB.PLC.ZMot(arDev.FakePLC.ZMotDirection.Stop);
}
private void button3_Click_1(object sender, EventArgs e)
{
PUB.PLC.ZMot(arDev.FakePLC.ZMotDirection.Up);
}
private void button4_Click_1(object sender, EventArgs e)
{
PUB.PLC.ZMot(arDev.FakePLC.ZMotDirection.Down);
}
private void arLabel1_Click_1(object sender, EventArgs e)
{

View File

@@ -12,6 +12,7 @@ using Microsoft.Speech.Synthesis;
using Microsoft.Speech;
using COMM;
using System.CodeDom;
using AR;
namespace Project
{
@@ -31,7 +32,7 @@ namespace Project
public fMain()
{
InitializeComponent();
COMM.VAR.Init(128);
VAR.Init(128);
PUB.initCore();
this.KeyDown += (s1, e1) =>
{
@@ -186,15 +187,15 @@ namespace Project
VAR.BOOL.PropertyChanged += BOOL_PropertyChanged;
///모터용 pLC
PUB.PLC = new arDev.FakePLC();
PUB.PLC.ValueChanged += PLC_DioChanged;
PUB.PLC.FlagChanged += PLC_FlagChanged;
PUB.PLC.Message += PLC_Message;
/////모터용 pLC
//PUB.PLC = new arDev.FakePLC();
//PUB.PLC.ValueChanged += PLC_DioChanged;
//PUB.PLC.FlagChanged += PLC_FlagChanged;
//PUB.PLC.Message += PLC_Message;
//지그비통신
PUB.XBE = new Device.Xbee();
PUB.XBE.Message += Xbee_Message;
//PUB.XBE.Message += Xbee_Message;
//HWState.setTitle(1, 3, Pub.setting.Port_Xbee);
//HWState.setTitle(1, 0, Pub.setting.Address_RFID);
@@ -294,63 +295,7 @@ namespace Project
#endregion
string last_xbee_tx = "";
string last_xbee_rx = "";
DateTime lasttime_xbee_tx = DateTime.Now;
DateTime lasttime_xbee_rx = DateTime.Now;
private void Xbee_Message(object sender, arDev.arRS232.MessageEventArgs e)
{
if (e.MsgType == arDev.arRS232.MessageType.Error) PUB.logcal.AddE("xbee err : " + e.Message);
else if (e.MsgType == arDev.arRS232.MessageType.Normal) PUB.logcal.Add("xbe", e.Message);
else if (e.MsgType == arDev.arRS232.MessageType.Recv)
{
var datastr = System.Text.Encoding.Default.GetString(e.Data, 1, e.Data.Length - 2);
var val = datastr.Substring(datastr.Length - 1);
var kitno = datastr.Substring(0, datastr.Length - 1);
if (last_xbee_rx.Equals(e.Message) == false)
{
PUB.logcal.Add("xbe-rx", e.Message);
last_xbee_rx = e.Message;
lasttime_xbee_rx = DateTime.Now;
}
else
{
var ts = DateTime.Now - lasttime_xbee_rx;
if (ts.TotalSeconds > 30)
{
PUB.logcal.Add("xbe-rx", e.Message);
last_xbee_rx = e.Message;
lasttime_xbee_rx = DateTime.Now;
}
}
PUB.log.Add($"콜버튼:{kitno} 값:{val} 수신");
//PUB.XBE.NewMsgEvent(kitno[0], val[0]);
}
else if (e.MsgType == arDev.arRS232.MessageType.Send)
{
if (last_xbee_tx.Equals(e.Message) == false)
{
PUB.logcal.Add("xbe-tx", e.Message);
last_xbee_tx = e.Message;
lasttime_xbee_tx = DateTime.Now;
}
else
{
var ts = DateTime.Now - lasttime_xbee_tx;
if (ts.TotalSeconds > 30)
{
PUB.logcal.Add("xbe-tx", e.Message);
last_xbee_tx = e.Message;
lasttime_xbee_tx = DateTime.Now;
}
}
}
else PUB.logcal.Add("XBEE", $"Rx:{e.Message}");
}
private void CtlPos1_ItemClick(object sender, CtlPos.ItemClickEventArgs e)
{
if (VAR.BOOL[eVarBool.FLAG_CHARGEONM] == true)
@@ -1005,7 +950,7 @@ namespace Project
private void btChargeM_Click(object sender, EventArgs e)
{
if (COMM.VAR.BOOL[eVarBool.FLAG_CHARGEONM])
if (VAR.BOOL[eVarBool.FLAG_CHARGEONM])
{
var dlg = Util.MsgQ("수동 충전을 해제 할까요?");
if (dlg != DialogResult.Yes) return;

View File

@@ -84,7 +84,6 @@
this.button3 = new System.Windows.Forms.Button();
this.label30 = new System.Windows.Forms.Label();
this.label12 = new System.Windows.Forms.Label();
this.label13 = new System.Windows.Forms.Label();
this.button2 = new System.Windows.Forms.Button();
this.tbBaudBAT = new System.Windows.Forms.ComboBox();
this.tbportBMS = new System.Windows.Forms.TextBox();
@@ -93,16 +92,11 @@
this.tbBaudAGV = new System.Windows.Forms.ComboBox();
this.tbPortAGV = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.btSelPlc1 = new System.Windows.Forms.Button();
this.btSelXbee = new System.Windows.Forms.Button();
this.tbBaudPLC = new System.Windows.Forms.ComboBox();
this.tbBaudXBE = new System.Windows.Forms.ComboBox();
this.tbPortPLC = new System.Windows.Forms.TextBox();
this.tbPortXBE = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.valIntervalBMS = new AGVControl.ValueSelect();
this.valueSelect4 = new AGVControl.ValueSelect();
this.valIntervalXBE = new AGVControl.ValueSelect();
this.tabPage3 = new System.Windows.Forms.TabPage();
this.cmbChargerPos = new System.Windows.Forms.ComboBox();
@@ -171,6 +165,7 @@
this.vcTagNOT = new AGVControl.ValueSelect();
this.tabPage4 = new System.Windows.Forms.TabPage();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.chkClearPos = new System.Windows.Forms.CheckBox();
this.propertyGrid1 = new System.Windows.Forms.PropertyGrid();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.tbMCID = new System.Windows.Forms.TextBox();
@@ -207,7 +202,6 @@
this.bt1 = new arCtl.arLabel();
this.bt0 = new arCtl.arLabel();
this.btSave = new arCtl.arLabel();
this.chkClearPos = new System.Windows.Forms.CheckBox();
this.tabControl1.SuspendLayout();
this.tabPage6.SuspendLayout();
this.panel1.SuspendLayout();
@@ -1236,7 +1230,6 @@
this.tabPage2.Controls.Add(this.button3);
this.tabPage2.Controls.Add(this.label30);
this.tabPage2.Controls.Add(this.label12);
this.tabPage2.Controls.Add(this.label13);
this.tabPage2.Controls.Add(this.button2);
this.tabPage2.Controls.Add(this.tbBaudBAT);
this.tabPage2.Controls.Add(this.tbportBMS);
@@ -1245,16 +1238,11 @@
this.tabPage2.Controls.Add(this.tbBaudAGV);
this.tabPage2.Controls.Add(this.tbPortAGV);
this.tabPage2.Controls.Add(this.label6);
this.tabPage2.Controls.Add(this.btSelPlc1);
this.tabPage2.Controls.Add(this.btSelXbee);
this.tabPage2.Controls.Add(this.tbBaudPLC);
this.tabPage2.Controls.Add(this.tbBaudXBE);
this.tabPage2.Controls.Add(this.tbPortPLC);
this.tabPage2.Controls.Add(this.tbPortXBE);
this.tabPage2.Controls.Add(this.label7);
this.tabPage2.Controls.Add(this.label5);
this.tabPage2.Controls.Add(this.valIntervalBMS);
this.tabPage2.Controls.Add(this.valueSelect4);
this.tabPage2.Controls.Add(this.valIntervalXBE);
this.tabPage2.Location = new System.Drawing.Point(4, 4);
this.tabPage2.Name = "tabPage2";
@@ -1296,17 +1284,6 @@
this.label12.TabIndex = 33;
this.label12.Text = "ms";
//
// label13
//
this.label13.AutoSize = true;
this.label13.Font = new System.Drawing.Font("궁서체", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
this.label13.ForeColor = System.Drawing.Color.WhiteSmoke;
this.label13.Location = new System.Drawing.Point(946, 114);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(36, 24);
this.label13.TabIndex = 15;
this.label13.Text = "ms";
//
// button2
//
this.button2.Location = new System.Drawing.Point(383, 178);
@@ -1405,17 +1382,6 @@
this.label6.TabIndex = 21;
this.label6.Text = "AGV PORT";
//
// btSelPlc1
//
this.btSelPlc1.Location = new System.Drawing.Point(383, 98);
this.btSelPlc1.Name = "btSelPlc1";
this.btSelPlc1.Size = new System.Drawing.Size(89, 56);
this.btSelPlc1.TabIndex = 15;
this.btSelPlc1.Tag = "PLC";
this.btSelPlc1.Text = "...";
this.btSelPlc1.UseVisualStyleBackColor = true;
this.btSelPlc1.Click += new System.EventHandler(this.btSelXbee_Click);
//
// btSelXbee
//
this.btSelXbee.Location = new System.Drawing.Point(383, 257);
@@ -1427,23 +1393,6 @@
this.btSelXbee.UseVisualStyleBackColor = true;
this.btSelXbee.Click += new System.EventHandler(this.btSelXbee_Click);
//
// tbBaudPLC
//
this.tbBaudPLC.Font = new System.Drawing.Font("궁서체", 32F, System.Drawing.FontStyle.Bold);
this.tbBaudPLC.FormattingEnabled = true;
this.tbBaudPLC.Items.AddRange(new object[] {
"4800",
"9600",
"19200",
"46800",
"115200",
"250000"});
this.tbBaudPLC.Location = new System.Drawing.Point(478, 101);
this.tbBaudPLC.Name = "tbBaudPLC";
this.tbBaudPLC.Size = new System.Drawing.Size(217, 51);
this.tbBaudPLC.TabIndex = 10;
this.tbBaudPLC.Tag = "P1";
//
// tbBaudXBE
//
this.tbBaudXBE.Font = new System.Drawing.Font("궁서체", 32F, System.Drawing.FontStyle.Bold);
@@ -1461,16 +1410,6 @@
this.tbBaudXBE.TabIndex = 8;
this.tbBaudXBE.Tag = "XB";
//
// tbPortPLC
//
this.tbPortPLC.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
this.tbPortPLC.Font = new System.Drawing.Font("궁서체", 32F, System.Drawing.FontStyle.Bold);
this.tbPortPLC.Location = new System.Drawing.Point(161, 98);
this.tbPortPLC.Name = "tbPortPLC";
this.tbPortPLC.Size = new System.Drawing.Size(216, 56);
this.tbPortPLC.TabIndex = 5;
this.tbPortPLC.Tag = "P1";
//
// tbPortXBE
//
this.tbPortXBE.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
@@ -1481,17 +1420,6 @@
this.tbPortXBE.TabIndex = 3;
this.tbPortXBE.Tag = "XB";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Font = new System.Drawing.Font("궁서체", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
this.label7.ForeColor = System.Drawing.Color.WhiteSmoke;
this.label7.Location = new System.Drawing.Point(38, 114);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(114, 24);
this.label7.TabIndex = 2;
this.label7.Text = "PLC PORT";
//
// label5
//
this.label5.AutoSize = true;
@@ -1526,29 +1454,6 @@
this.valIntervalBMS.Value = 0D;
this.valIntervalBMS.ButtonClick += new System.EventHandler<AGVControl.ValueSelect.ButtonClickEventArgs>(this.valIntervalBMS_ButtonClick);
//
// valueSelect4
//
this.valueSelect4.BackColorButton = System.Drawing.Color.White;
this.valueSelect4.ButtonWidth = "30";
this.valueSelect4.ColorBorder = System.Drawing.Color.White;
this.valueSelect4.DecimalPosition = ((ushort)(0));
this.valueSelect4.Font = new System.Drawing.Font("궁서체", 32F, System.Drawing.FontStyle.Bold);
this.valueSelect4.FontSideButton = new System.Drawing.Font("Consolas", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.valueSelect4.ForeColor = System.Drawing.Color.White;
this.valueSelect4.ForeColorButton = System.Drawing.Color.Black;
this.valueSelect4.Location = new System.Drawing.Point(701, 101);
this.valueSelect4.MaxValue = 254D;
this.valueSelect4.MinValue = 0D;
this.valueSelect4.Name = "valueSelect4";
this.valueSelect4.NullDisplay = "--";
this.valueSelect4.SideButtonClickValue = 20D;
this.valueSelect4.Size = new System.Drawing.Size(239, 51);
this.valueSelect4.TabIndex = 13;
this.valueSelect4.Tag = "SL";
this.valueSelect4.Text = "1";
this.valueSelect4.Value = 1D;
this.valueSelect4.ButtonClick += new System.EventHandler<AGVControl.ValueSelect.ButtonClickEventArgs>(this.vcChargeLow_ButtonClick);
//
// valIntervalXBE
//
this.valIntervalXBE.BackColorButton = System.Drawing.Color.White;
@@ -2762,6 +2667,17 @@
this.groupBox3.TabStop = false;
this.groupBox3.Text = "일반 설정";
//
// chkClearPos
//
this.chkClearPos.AutoSize = true;
this.chkClearPos.Font = new System.Drawing.Font("궁서체", 20F, System.Drawing.FontStyle.Bold);
this.chkClearPos.Location = new System.Drawing.Point(27, 371);
this.chkClearPos.Name = "chkClearPos";
this.chkClearPos.Size = new System.Drawing.Size(468, 31);
this.chkClearPos.TabIndex = 12;
this.chkClearPos.Text = "자동모드 해제 시 위치정보 삭제";
this.chkClearPos.UseVisualStyleBackColor = true;
//
// propertyGrid1
//
this.propertyGrid1.Font = new System.Drawing.Font("맑은 고딕", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
@@ -3410,17 +3326,6 @@
this.btSave.TextVisible = true;
this.btSave.Click += new System.EventHandler(this.btSave_Click);
//
// chkClearPos
//
this.chkClearPos.AutoSize = true;
this.chkClearPos.Font = new System.Drawing.Font("궁서체", 20F, System.Drawing.FontStyle.Bold);
this.chkClearPos.Location = new System.Drawing.Point(27, 371);
this.chkClearPos.Name = "chkClearPos";
this.chkClearPos.Size = new System.Drawing.Size(468, 31);
this.chkClearPos.TabIndex = 12;
this.chkClearPos.Text = "자동모드 해제 시 위치정보 삭제";
this.chkClearPos.UseVisualStyleBackColor = true;
//
// fSetup
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
@@ -3477,20 +3382,14 @@
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.TabPage tabPage2;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.TextBox tbPortXBE;
private System.Windows.Forms.TextBox tbPortPLC;
private System.Windows.Forms.ComboBox tbBaudXBE;
private System.Windows.Forms.ComboBox tbBaudPLC;
private System.Windows.Forms.Button btSelXbee;
private System.Windows.Forms.Button btSelPlc1;
private System.Windows.Forms.Panel panTopMenu;
private arCtl.arLabel btClose;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Label label10;
private AGVControl.ValueSelect valIntervalXBE;
private AGVControl.ValueSelect valueSelect4;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.TabPage tabPage4;

View File

@@ -53,12 +53,12 @@ namespace Project
//통신값 표시
//tbPortBMS.Text = Pub.setting.Port_BMS;
tbPortPLC.Text = PUB.setting.Port_PLC;
///tbPortPLC.Text = PUB.setting.Port_PLC;
tbPortAGV.Text = PUB.setting.Port_AGV;
tbPortXBE.Text = PUB.setting.Port_XBE;
tbportBMS.Text = PUB.setting.Port_BAT;
tbBaudPLC.Text = PUB.setting.Baud_PLC.ToString();
// tbBaudPLC.Text = PUB.setting.Baud_PLC.ToString();
tbBaudAGV.Text = PUB.setting.Baud_AGV.ToString();
tbBaudXBE.Text = PUB.setting.Baud_XBE.ToString();
tbBaudBAT.Text = PUB.setting.Baud_BAT.ToString();
@@ -66,7 +66,7 @@ namespace Project
//valueSelect1.Value = Pub.setting.interval_bms;
valIntervalXBE.Value = PUB.setting.interval_xbe;
vcpidDS.Value = PUB.setting.ZSpeed;
valueSelect4.Value = PUB.setting.interval_iostate;
//valueSelect4.Value = PUB.setting.interval_iostate;
valIntervalBMS.Value = PUB.setting.interval_bms;
tbChargerID.Value = PUB.setting.ChargerID;
@@ -221,13 +221,13 @@ namespace Project
//통신정보저장
// Pub.setting.Port_BMS = tbPortBMS.Text;
PUB.setting.Port_XBE = tbPortXBE.Text;
PUB.setting.Port_PLC = tbPortPLC.Text;
//PUB.setting.Port_PLC = tbPortPLC.Text;
PUB.setting.Port_AGV = tbPortAGV.Text;
PUB.setting.Port_BAT = tbportBMS.Text;
// Pub.setting.Baud_bms = int.Parse(tbBaudBms.Text);
PUB.setting.Baud_XBE = int.Parse(tbBaudXBE.Text);
PUB.setting.Baud_PLC = int.Parse(tbBaudPLC.Text);
//PUB.setting.Baud_PLC = int.Parse(tbBaudPLC.Text);
PUB.setting.Baud_AGV = int.Parse(tbBaudAGV.Text);
PUB.setting.Baud_BAT = int.Parse(tbBaudBAT.Text);
@@ -237,7 +237,7 @@ namespace Project
PUB.setting.interval_bms = (int)valIntervalBMS.Value;
PUB.setting.interval_xbe = (float)valIntervalXBE.Value;
PUB.setting.ZSpeed = (byte)vcpidDS.Value;
PUB.setting.interval_iostate = (byte)valueSelect4.Value;
//PUB.setting.interval_iostate = (byte)valueSelect4.Value;
PUB.setting.chargerpos = this.cmbChargerPos.SelectedIndex;
PUB.setting.AutoModeOffAndClearPosition = this.chkClearPos.Checked;
//PUB.setting.MotorUpTime = (byte)valueSelect5.Value;
@@ -487,7 +487,7 @@ namespace Project
if (tagStr == "XBE") tbPortXBE.Text = newPort;
else if (tagStr == "AGV") tbPortAGV.Text = newPort;
else if (tagStr == "PLC") tbPortPLC.Text = newPort;
// else if (tagStr == "PLC") tbPortPLC.Text = newPort;
else if (tagStr == "BAT") tbportBMS.Text = newPort;
}
@@ -551,14 +551,14 @@ namespace Project
if (this.tbPortAGV.Text == "COM21")
{
this.tbPortAGV.Text = "COM11";
this.tbPortPLC.Text = "COM6";
// this.tbPortPLC.Text = "COM6";
this.tbportBMS.Text = "COM15";
this.tbPortXBE.Text = "COM18";
}
else
{
this.tbPortAGV.Text = "COM21";
this.tbPortPLC.Text = "COM31";
// this.tbPortPLC.Text = "COM31";
this.tbportBMS.Text = "COM41";
this.tbPortXBE.Text = "COM51";
}

View File

@@ -8,6 +8,7 @@ using System.Threading.Tasks;
using System.Collections;
using COMM;
using System.Security.Cryptography.X509Certificates;
using AR;
namespace arDev
{
@@ -41,7 +42,6 @@ namespace arDev
else cmd += item.ToString()[0];
cmd += speed.ToString("0000");
return AddCommand(cmd);
}
public bool AGVMoveStop(string Reason, eStopOpt opt = eStopOpt.Stop)
{
@@ -236,6 +236,11 @@ namespace arDev
retval = AddCommand(cmdString);
break;
case eAgvCmd.CPUReset:
cmdString = "CRS0000";
retval = AddCommand(cmdString);
break;
}
return retval;
}

View File

@@ -173,6 +173,8 @@ namespace arDev
/// SRS
/// </summary>
SetSpeed,
CPUReset,
}
public enum eForm
{

View File

@@ -59,6 +59,10 @@
<Project>{14e8c9a5-013e-49ba-b435-efefc77dd623}</Project>
<Name>CommData</Name>
</ProjectReference>
<ProjectReference Include="..\CommUtil\arCommUtil.csproj">
<Project>{14e8c9a5-013e-49ba-b435-ffffff7dd623}</Project>
<Name>arCommUtil</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -8,6 +8,7 @@ using System.Threading.Tasks;
using System.Collections;
using COMM;
using System.Security.Cryptography.X509Certificates;
using AR;
namespace arDev
{
@@ -61,7 +62,7 @@ namespace arDev
Errlog = new Queue();
MinRecvLength = 4;
COMM.VAR.Init(128);
VAR.Init(128);
}

View File

@@ -26,6 +26,13 @@ namespace arDev
front_right_sensor,
front_center_sensor,
charger_align_sensor,
lift_up,
lift_down,
magnet_on,
cart_detect1,
cart_detect2,
}
public bool GetValue(eflag idx)
@@ -46,6 +53,11 @@ namespace arDev
public Boolean front_right_sensor { get { return GetValue(eflag.front_right_sensor); } }
public Boolean front_center_sensor { get { return GetValue(eflag.front_center_sensor); } }
public Boolean charger_align_sensor { get { return GetValue(eflag.charger_align_sensor); } }
public Boolean lift_up { get { return GetValue(eflag.lift_up); } }
public Boolean lift_down { get { return GetValue(eflag.lift_down); } }
public Boolean magnet_on { get { return GetValue(eflag.magnet_on); } }
public Boolean cart_detect1 { get { return GetValue(eflag.cart_detect1); } }
public Boolean cart_detect2 { get { return GetValue(eflag.cart_detect2); } }
public override string ToString()
{
//모든사태값을 탭으로 구분하여 문자를 생성한다

View File

@@ -135,10 +135,7 @@ namespace COMM
public enum eVarTime
{
LastConnTry_PLC,
LastConn_PLC,
LastRecv_PLC,
LastConnTry_XBE,
LastConn_XBE,
LastRecv_XBE,

View File

@@ -1,340 +1,340 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
//using System;
//using System.Collections.Generic;
//using System.ComponentModel;
//using System.Linq;
//using System.Text;
namespace COMM
{
public abstract class VarData<T> : INotifyPropertyChanged
{
protected T[] _values;
protected T defaultvalue;
protected string[] _code;
protected string[] _desc;
//namespace COMM
//{
// public abstract class VarData<T> : INotifyPropertyChanged
// {
// protected T[] _values;
// protected T defaultvalue;
// protected string[] _code;
// protected string[] _desc;
public event PropertyChangedEventHandler PropertyChanged;
// public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string name)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
// protected void OnPropertyChanged(string name)
// {
// PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
// }
public T this[int idx]
{
get { return Get(idx); }
set { Set(idx, value); }
}
// public T this[int idx]
// {
// get { return Get(idx); }
// set { Set(idx, value); }
// }
public string StrType
{
get
{
return typeof(T).ToString();
}
}
public VarData(int capa, T defvalue = default(T))
{
_values = new T[capa];
_code = new string[capa];
_desc = new string[capa];
// public string StrType
// {
// get
// {
// return typeof(T).ToString();
// }
// }
// public VarData(int capa, T defvalue = default(T))
// {
// _values = new T[capa];
// _code = new string[capa];
// _desc = new string[capa];
defaultvalue = defvalue;
Clear();
// defaultvalue = defvalue;
// Clear();
if (typeof(T) == typeof(UInt16)) SupportAdd = true;
else if (typeof(T) == typeof(UInt32)) SupportAdd = true;
else if (typeof(T) == typeof(Int16)) SupportAdd = true;
else if (typeof(T) == typeof(Int32)) SupportAdd = true;
else if (typeof(T) == typeof(Int64)) SupportAdd = true;
else if (typeof(T) == typeof(UInt64)) SupportAdd = true;
else if (typeof(T) == typeof(byte)) SupportAdd = true;
else if (typeof(T) == typeof(double)) SupportAdd = true;
else if (typeof(T) == typeof(Single)) SupportAdd = true;
else if (typeof(T) == typeof(string)) SupportAdd = false;
else if (typeof(T) == typeof(bool)) SupportAdd = false;
else if (typeof(T) == typeof(DateTime)) SupportAdd = false;
else throw new Exception($"Support Data Type : {typeof(T)}");
}
// if (typeof(T) == typeof(UInt16)) SupportAdd = true;
// else if (typeof(T) == typeof(UInt32)) SupportAdd = true;
// else if (typeof(T) == typeof(Int16)) SupportAdd = true;
// else if (typeof(T) == typeof(Int32)) SupportAdd = true;
// else if (typeof(T) == typeof(Int64)) SupportAdd = true;
// else if (typeof(T) == typeof(UInt64)) SupportAdd = true;
// else if (typeof(T) == typeof(byte)) SupportAdd = true;
// else if (typeof(T) == typeof(double)) SupportAdd = true;
// else if (typeof(T) == typeof(Single)) SupportAdd = true;
// else if (typeof(T) == typeof(string)) SupportAdd = false;
// else if (typeof(T) == typeof(bool)) SupportAdd = false;
// else if (typeof(T) == typeof(DateTime)) SupportAdd = false;
// else throw new Exception($"Support Data Type : {typeof(T)}");
// }
public virtual void Set(int idx, T value)
{
var changed = _values[idx].Equals(value);
_values[idx] = value;
if (changed) OnPropertyChanged($"{idx}|{value}"); //idx값을 알림한다
}
public virtual T Get(int idx)
{
return _values[idx];
}
// public virtual void Set(int idx, T value)
// {
// var changed = _values[idx].Equals(value);
// _values[idx] = value;
// if (changed) OnPropertyChanged($"{idx}|{value}"); //idx값을 알림한다
// }
// public virtual T Get(int idx)
// {
// return _values[idx];
// }
public virtual void Clear(T value)
{
for (int i = 0; i < _values.Length; i++)
_values[i] = value;
}
public virtual void Clear()
{
Clear(defaultvalue);
}
public void Clear(int idx)
{
_values[idx] = defaultvalue;
}
public Tuple<string, string> GetCodeDesc(int idx)
{
return new Tuple<string, string>(_code[idx], _desc[idx]);
}
public virtual bool SupportAdd { get; private set; }
}
// public virtual void Clear(T value)
// {
// for (int i = 0; i < _values.Length; i++)
// _values[i] = value;
// }
// public virtual void Clear()
// {
// Clear(defaultvalue);
// }
// public void Clear(int idx)
// {
// _values[idx] = defaultvalue;
// }
// public Tuple<string, string> GetCodeDesc(int idx)
// {
// return new Tuple<string, string>(_code[idx], _desc[idx]);
// }
// public virtual bool SupportAdd { get; private set; }
// }
public abstract class VarDataNumber<T> : VarData<T>
{
public VarDataNumber(int capa) : base(capa) { }
// public abstract class VarDataNumber<T> : VarData<T>
// {
// public VarDataNumber(int capa) : base(capa) { }
public abstract void Add(T value);
public abstract void Add(int idx, T value);
}
// public abstract void Add(T value);
// public abstract void Add(int idx, T value);
// }
public class VarDataI32 : VarDataNumber<Int32>
{
public VarDataI32(int capa) : base(capa) { }
// public class VarDataI32 : VarDataNumber<Int32>
// {
// public VarDataI32(int capa) : base(capa) { }
public override void Add(Int32 value)
{
for (int i = 0; i < _values.Length; i++)
_values[i] += value;
}
// public override void Add(Int32 value)
// {
// for (int i = 0; i < _values.Length; i++)
// _values[i] += value;
// }
public override void Add(int idx, Int32 value)
{
_values[idx] += value;
}
public void Add(eVarInt32 idx, Int32 value = 1)
{
Add((int)idx, value);
}
public void Clear(eVarInt32 idx)
{
Clear((int)idx);
}
public Int32 this[eVarInt32 idx]
{
get { return Get((int)idx); }
set { Set((int)idx, value); }
}
// public override void Add(int idx, Int32 value)
// {
// _values[idx] += value;
// }
// public void Add(eVarInt32 idx, Int32 value = 1)
// {
// Add((int)idx, value);
// }
// public void Clear(eVarInt32 idx)
// {
// Clear((int)idx);
// }
// public Int32 this[eVarInt32 idx]
// {
// get { return Get((int)idx); }
// set { Set((int)idx, value); }
// }
}
public class VarDataDBL : VarDataNumber<double>
{
public VarDataDBL(int capa) : base(capa) { }
// }
// public class VarDataDBL : VarDataNumber<double>
// {
// public VarDataDBL(int capa) : base(capa) { }
public override void Add(double value)
{
for (int i = 0; i < _values.Length; i++)
_values[i] += value;
}
// public override void Add(double value)
// {
// for (int i = 0; i < _values.Length; i++)
// _values[i] += value;
// }
public override void Add(int idx, double value)
{
_values[idx] += value;
}
public void Add(eVarDBL idx, double value = 1)
{
Add((int)idx, value);
}
public void Clear(eVarDBL idx)
{
Clear((int)idx);
}
public double this[eVarDBL idx]
{
get { return Get((int)idx); }
set { Set((int)idx, value); }
}
}
public class VarDataUI32 : VarDataNumber<UInt32>
{
public VarDataUI32(int capa) : base(capa) { }
// public override void Add(int idx, double value)
// {
// _values[idx] += value;
// }
// public void Add(eVarDBL idx, double value = 1)
// {
// Add((int)idx, value);
// }
// public void Clear(eVarDBL idx)
// {
// Clear((int)idx);
// }
// public double this[eVarDBL idx]
// {
// get { return Get((int)idx); }
// set { Set((int)idx, value); }
// }
// }
// public class VarDataUI32 : VarDataNumber<UInt32>
// {
// public VarDataUI32(int capa) : base(capa) { }
public override void Add(UInt32 value)
{
for (int i = 0; i < _values.Length; i++)
_values[i] += value;
}
// public override void Add(UInt32 value)
// {
// for (int i = 0; i < _values.Length; i++)
// _values[i] += value;
// }
public override void Add(int idx, UInt32 value)
{
_values[idx] += value;
}
public void Add(eVarUInt32 idx, UInt32 value = 1)
{
Add((int)idx, value);
}
public void Clear(eVarUInt32 idx)
{
Clear((int)idx);
}
public UInt32 this[eVarUInt32 idx]
{
get { return Get((int)idx); }
set { Set((int)idx, value); }
}
}
// public override void Add(int idx, UInt32 value)
// {
// _values[idx] += value;
// }
// public void Add(eVarUInt32 idx, UInt32 value = 1)
// {
// Add((int)idx, value);
// }
// public void Clear(eVarUInt32 idx)
// {
// Clear((int)idx);
// }
// public UInt32 this[eVarUInt32 idx]
// {
// get { return Get((int)idx); }
// set { Set((int)idx, value); }
// }
// }
public class VarDataByte : VarDataNumber<byte>
{
public VarDataByte(int capa) : base(capa) { }
// public class VarDataByte : VarDataNumber<byte>
// {
// public VarDataByte(int capa) : base(capa) { }
public override void Add(byte value)
{
for (int i = 0; i < _values.Length; i++)
_values[i] += value;
}
public override void Add(int idx, byte value)
{
_values[idx] += value;
}
public void Add(eVarByte idx, byte value)
{
Add((int)idx, value);
}
public byte this[eVarByte idx]
{
get
{
return Get((int)idx);
}
set
{
Set((int)idx, value);
}
}
}
// public override void Add(byte value)
// {
// for (int i = 0; i < _values.Length; i++)
// _values[i] += value;
// }
// public override void Add(int idx, byte value)
// {
// _values[idx] += value;
// }
// public void Add(eVarByte idx, byte value)
// {
// Add((int)idx, value);
// }
// public byte this[eVarByte idx]
// {
// get
// {
// return Get((int)idx);
// }
// set
// {
// Set((int)idx, value);
// }
// }
// }
public class VarDataBool : VarData<bool>
{
public VarDataBool(int capa) : base(capa) { }
// public class VarDataBool : VarData<bool>
// {
// public VarDataBool(int capa) : base(capa) { }
public bool this[eVarBool idx]
{
get
{
return Get(idx);
}
set
{
Set(idx, value);
}
}
public bool Get(eVarBool idx)
{
return Get((int)idx);
}
public void Set(eVarBool idx, bool value)
{
Set((int)idx, value);
}
}
// public bool this[eVarBool idx]
// {
// get
// {
// return Get(idx);
// }
// set
// {
// Set(idx, value);
// }
// }
// public bool Get(eVarBool idx)
// {
// return Get((int)idx);
// }
// public void Set(eVarBool idx, bool value)
// {
// Set((int)idx, value);
// }
// }
public class VarDataStr : VarData<string>
{
public VarDataStr(int capa) : base(capa, string.Empty) { }
public string Get(eVarString idx)
{
return Get((int)idx);
}
public void Set(eVarString idx, string value)
{
Set((int)idx, value);
}
public string this[eVarString idx]
{
get { return Get(idx); }
set { Set(idx, value); }
}
}
public class VarDataDateTime : VarData<DateTime>
{
public VarDataDateTime(int capa) : base(capa, new DateTime(1982, 11, 23)) { }
// public class VarDataStr : VarData<string>
// {
// public VarDataStr(int capa) : base(capa, string.Empty) { }
// public string Get(eVarString idx)
// {
// return Get((int)idx);
// }
// public void Set(eVarString idx, string value)
// {
// Set((int)idx, value);
// }
// public string this[eVarString idx]
// {
// get { return Get(idx); }
// set { Set(idx, value); }
// }
// }
// public class VarDataDateTime : VarData<DateTime>
// {
// public VarDataDateTime(int capa) : base(capa, new DateTime(1982, 11, 23)) { }
public DateTime this[eVarTime idx]
{
get
{
return Get((int)idx);
}
set
{
Set(idx, value);
}
}
// public DateTime this[eVarTime idx]
// {
// get
// {
// return Get((int)idx);
// }
// set
// {
// Set(idx, value);
// }
// }
public TimeSpan RUN(int idx)
{
return DateTime.Now - _values[idx];
}
public TimeSpan RUN(eVarTime idx)
{
return RUN((int)idx);
}
[Browsable(false)]
public void Add(int idx, TimeSpan value)
{
_values[idx] += value;
}
// public TimeSpan RUN(int idx)
// {
// return DateTime.Now - _values[idx];
// }
// public TimeSpan RUN(eVarTime idx)
// {
// return RUN((int)idx);
// }
// [Browsable(false)]
// public void Add(int idx, TimeSpan value)
// {
// _values[idx] += value;
// }
public void Add(eVarTime idx, TimeSpan value)
{
Add((int)idx, value);
}
/// <summary>
/// 지정된 시간으로 업데이트 합니다
/// </summary>
/// <param name="idx"></param>
/// <param name="value"></param>
public void Set(eVarTime idx, DateTime value)
{
Set((int)idx, value);
}
/// <summary>
/// 현재시간으로 업데이트 합니다
/// </summary>
/// <param name="idx"></param>
public void Set(eVarTime idx)
{
Set(idx, DateTime.Now);
}
public bool IsSet(eVarTime idx)
{
return this[idx].Year != 1982;
}
}
//공용변수(시간)
public static class VAR
{
public static VarDataBool BOOL;
public static VarDataByte BYTE;
public static VarDataStr STR;
public static VarDataDateTime TIME;
public static VarDataI32 I32;
public static VarDataUI32 U32;
public static VarDataDBL DBL;
// public void Add(eVarTime idx, TimeSpan value)
// {
// Add((int)idx, value);
// }
// /// <summary>
// /// 지정된 시간으로 업데이트 합니다
// /// </summary>
// /// <param name="idx"></param>
// /// <param name="value"></param>
// public void Set(eVarTime idx, DateTime value)
// {
// Set((int)idx, value);
// }
// /// <summary>
// /// 현재시간으로 업데이트 합니다
// /// </summary>
// /// <param name="idx"></param>
// public void Set(eVarTime idx)
// {
// Set(idx, DateTime.Now);
// }
// public bool IsSet(eVarTime idx)
// {
// return this[idx].Year != 1982;
// }
// }
// //공용변수(시간)
// public static class VAR
// {
// public static VarDataBool BOOL;
// public static VarDataByte BYTE;
// public static VarDataStr STR;
// public static VarDataDateTime TIME;
// public static VarDataI32 I32;
// public static VarDataUI32 U32;
// public static VarDataDBL DBL;
public static bool isInit { get; private set; } = false;
// public static bool isInit { get; private set; } = false;
public static void Init(int varlen)
{
if (isInit) return; //already init
//가변 데이트타임변수
BOOL = new VarDataBool(varlen);
BYTE = new VarDataByte(varlen);
STR = new VarDataStr(varlen);
TIME = new VarDataDateTime(varlen);
I32 = new VarDataI32(varlen);
U32 = new VarDataUI32(varlen);
DBL = new VarDataDBL(varlen);
isInit = true;
}
}
}
// public static void Init(int varlen)
// {
// if (isInit) return; //already init
// //가변 데이트타임변수
// BOOL = new VarDataBool(varlen);
// BYTE = new VarDataByte(varlen);
// STR = new VarDataStr(varlen);
// TIME = new VarDataDateTime(varlen);
// I32 = new VarDataI32(varlen);
// U32 = new VarDataUI32(varlen);
// DBL = new VarDataDBL(varlen);
// isInit = true;
// }
// }
//}

View File

@@ -6,6 +6,8 @@ using System.Threading;
using System.Threading.Tasks;
using arDev.Arduino;
using COMM;
using AR;
namespace arDev
{
@@ -17,7 +19,7 @@ namespace arDev
public FakePLC()
{
COMM.VAR.Init(128);
VAR.Init(128);
}
~FakePLC()
@@ -198,12 +200,12 @@ namespace arDev
}
public Boolean GetFlag(int flag)
{
return COMM.VAR.BOOL[flag];
return VAR.BOOL[flag];
}
public Boolean GetFlag(COMM.eVarBool flag)
{
return COMM.VAR.BOOL[(int)flag];
return VAR.BOOL[(int)flag];
}
public Boolean SetFlag(byte idx, Boolean value)