- 값이 마이너스일 때 중량값이 나오지 않는 버그 수정

- Stop 통신 보내는 부분 주석처리
main
CJY 2025-07-28 19:49:45 +09:00
parent 1ee3ab4361
commit 5c9c0053bc
7 changed files with 198 additions and 25 deletions

View File

@ -240,6 +240,7 @@ namespace INT63DC_6CH.Controls
{ {
// 중량 // 중량
value = Helper.StringToDecimalPlaces(weightDatas[i].WeightString, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces); value = Helper.StringToDecimalPlaces(weightDatas[i].WeightString, this.ParentForm.ParentForm.SystemConfig.DecimalPlaces);
if (this.CollectionLabelWeightValue[i].Text != value) if (this.CollectionLabelWeightValue[i].Text != value)
this.CollectionLabelWeightValue[i].Text = value; this.CollectionLabelWeightValue[i].Text = value;
if (this.CollectionLabelWeightValue[i].ForeColor != Color.Black) if (this.CollectionLabelWeightValue[i].ForeColor != Color.Black)

View File

@ -60,6 +60,15 @@ namespace INT63DC_6CH
Japanese, Japanese,
}; };
public enum E_CommMode
{
f0_None = 0,
f1_STD1 = 1,
f2_STD2 = 2,
f3_STD3 = 3,
f4_Modbus = 4,
};
public enum UserGroup public enum UserGroup
{ {
None = 0, None = 0,
@ -1666,17 +1675,18 @@ namespace INT63DC_6CH
/// </summary> /// </summary>
public string WeightString public string WeightString
{ {
get get
{ {
string ret = ""; string ret = "";
if (this.Sign == "-") if (this.Sign == "-")
ret = "-" + this.m_WeightString.Remove(1, 0); ret = "-" + this.m_WeightString.Remove(0, 1);
else else
ret = this.m_WeightString; ret = this.m_WeightString;
return ret; return ret;
} }
//get { return this.m_WeightString; }
set { this.m_WeightString = value; } set { this.m_WeightString = value; }
} }
public string Sign public string Sign

View File

@ -159,7 +159,7 @@ namespace INT63DC_6CH.Forms
this.comboBoxMode.Items.Add("STD1"); this.comboBoxMode.Items.Add("STD1");
this.comboBoxMode.Items.Add("STD2"); this.comboBoxMode.Items.Add("STD2");
this.comboBoxMode.Items.Add("STD3"); this.comboBoxMode.Items.Add("STD3");
//this.comboBoxMode.Items.Add("Modbus"); this.comboBoxMode.Items.Add("Modbus");
this.comboBoxMode.SelectedIndex = 0; this.comboBoxMode.SelectedIndex = 0;
this.comboBoxMode.SelectedIndexChanged += new EventHandler(this.comboBoxMode_SelectedIndexChanged); this.comboBoxMode.SelectedIndexChanged += new EventHandler(this.comboBoxMode_SelectedIndexChanged);
@ -454,10 +454,18 @@ namespace INT63DC_6CH.Forms
{ {
switch (index) switch (index)
{ {
case 3 : // Modbus case (int)DataStore.E_CommMode.f4_Modbus : // Modbus
this.labelTitleStartAddress.Visible = true; if (this.comboBoxOperationMode.SelectedIndex == 2)
this.labelStartAddress.Visible = true; {
this.labelStartAddress.Text = this.ParentForm.SystemConfig.ModbusTcpStartAddress.ToString(); this.labelTitleStartAddress.Visible = true;
this.labelStartAddress.Visible = true;
this.labelStartAddress.Text = this.ParentForm.SystemConfig.ModbusTcpStartAddress.ToString();
}
else
{
this.labelTitleStartAddress.Visible = false;
this.labelStartAddress.Visible = false;
}
break; break;
default: default:
this.labelTitleStartAddress.Visible = false; this.labelTitleStartAddress.Visible = false;
@ -758,13 +766,13 @@ namespace INT63DC_6CH.Forms
{ {
string before = "", after = ""; string before = "", after = "";
if (this.ParentForm.SystemConfig.EthernetMode == 1) if (this.ParentForm.SystemConfig.EthernetMode == (int)DataStore.E_CommMode.f1_STD1)
before = "STD1"; before = "STD1";
else if (this.ParentForm.SystemConfig.EthernetMode == 2) else if (this.ParentForm.SystemConfig.EthernetMode == (int)DataStore.E_CommMode.f2_STD2)
before = "STD2"; before = "STD2";
else if (this.ParentForm.SystemConfig.EthernetMode == 3) else if (this.ParentForm.SystemConfig.EthernetMode == (int)DataStore.E_CommMode.f3_STD3)
before = "STD3"; before = "STD3";
else if (this.ParentForm.SystemConfig.EthernetMode == 4) else if (this.ParentForm.SystemConfig.EthernetMode == (int)DataStore.E_CommMode.f4_Modbus)
before = "Modbus"; before = "Modbus";
else else
before = "None"; before = "None";

View File

@ -420,7 +420,7 @@ namespace INT63DC_6CH.Forms
if (myKeyPad.ShowDialog() == DialogResult.OK) if (myKeyPad.ShowDialog() == DialogResult.OK)
{ {
if (myKeyPad.doubleValue < 0 || myKeyPad.doubleValue > 99) if (myKeyPad.doubleValue < 1 || myKeyPad.doubleValue > 99)
{ {
// 입력범위를 확인하세요 // 입력범위를 확인하세요
DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language); DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);

View File

@ -114,6 +114,7 @@
this.smartTCPMultiServer.MaxReceiveBufferSize = 1000; this.smartTCPMultiServer.MaxReceiveBufferSize = 1000;
this.smartTCPMultiServer.Port = 5001; this.smartTCPMultiServer.Port = 5001;
this.smartTCPMultiServer.ReceiveTimeout = 3000; this.smartTCPMultiServer.ReceiveTimeout = 3000;
this.smartTCPMultiServer.OnReceiveHandler += new SmartX.SmartTCPMultiServer.ReceiveHandler(this.smartTCPMultiServer_OnReceiveHandler);
// //
// timerUserList // timerUserList
// //

View File

@ -889,7 +889,7 @@ namespace INT63DC_6CH.Forms
// 비상정지시 장비 정지상태로 변환 // 비상정지시 장비 정지상태로 변환
if (this.IsServoOrigin == true) if (this.IsServoOrigin == true)
{ {
this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard); //this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
this.ChildFormMainDisplay.UpdateDisplayAlarmMessageServoOrigin(); this.ChildFormMainDisplay.UpdateDisplayAlarmMessageServoOrigin();
} }
break; break;
@ -1348,32 +1348,32 @@ namespace INT63DC_6CH.Forms
if (this.SystemConfig.CurrentForm == DataStore.FormStore.FormMainDisplay) if (this.SystemConfig.CurrentForm == DataStore.FormStore.FormMainDisplay)
{ {
#region Serial 3 #region Serial 3
if (this.SystemConfig.Serial3Mode == 1) // STD1 - 중량 데이터 피드백 if (this.SystemConfig.Serial3Mode == (int)DataStore.E_CommMode.f1_STD1) // STD1 - 중량 데이터 피드백
this.SerialCH3STD1(this.CollectionWeightData); this.SerialCH3STD1(this.CollectionWeightData);
else if (this.SystemConfig.Serial3Mode == 2) // STD2 - 중량 데이터 피드백 else if (this.SystemConfig.Serial3Mode == (int)DataStore.E_CommMode.f2_STD2) // STD2 - 중량 데이터 피드백
this.SerialCH3STD2(this.CollectionWeightData); this.SerialCH3STD2(this.CollectionWeightData);
else if (this.SystemConfig.Serial3Mode == 3) // STD3 - 중량 데이터 피드백 else if (this.SystemConfig.Serial3Mode == (int)DataStore.E_CommMode.f3_STD3) // STD3 - 중량 데이터 피드백
this.SerialCH3STD3(this.CollectionWeightData); this.SerialCH3STD3(this.CollectionWeightData);
#endregion #endregion
#region 이더넷 #region 이더넷
if (this.SystemConfig.IsEthernetEnable == true) if (this.SystemConfig.IsEthernetEnable == true)
{ {
if (this.SystemConfig.EthernetMode == 1) // STD1 - 중량 데이터 피드백 if (this.SystemConfig.EthernetMode == (int)DataStore.E_CommMode.f1_STD1) // STD1 - 중량 데이터 피드백
{ {
#region OPT2 #region OPT2
etherStringData = this.Protocol_STD1(this.SystemConfig, this.CollectionWeightData); etherStringData = this.Protocol_STD1(this.SystemConfig, this.CollectionWeightData);
this.SendEthernetData(etherStringData); this.SendEthernetData(etherStringData);
#endregion #endregion
} }
else if (this.SystemConfig.EthernetMode == 2) // STD2 - 중량 데이터 피드백 else if (this.SystemConfig.EthernetMode == (int)DataStore.E_CommMode.f2_STD2) // STD2 - 중량 데이터 피드백
{ {
#region OPT2 #region OPT2
etherStringData = this.Protocol_STD2(this.SystemConfig, this.CollectionWeightData, this.CurrentProductItem); etherStringData = this.Protocol_STD2(this.SystemConfig, this.CollectionWeightData, this.CurrentProductItem);
this.SendEthernetData(etherStringData); this.SendEthernetData(etherStringData);
#endregion #endregion
} }
else if (this.SystemConfig.EthernetMode == 3) // STD3 - 중량 데이터 피드백 else if (this.SystemConfig.EthernetMode == (int)DataStore.E_CommMode.f3_STD3) // STD3 - 중량 데이터 피드백
{ {
#region OPT3 #region OPT3
etherStringData = this.Protocol_STD3(this.SystemConfig, this.CollectionWeightData, this.CurrentProductItem); etherStringData = this.Protocol_STD3(this.SystemConfig, this.CollectionWeightData, this.CurrentProductItem);
@ -6971,7 +6971,7 @@ namespace INT63DC_6CH.Forms
if (this.EquipmentStatus == DataStore.EquipmentStatus.Start) if (this.EquipmentStatus == DataStore.EquipmentStatus.Start)
{ {
this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard); //this.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
this.timerEmergencyStop.Enabled = true; this.timerEmergencyStop.Enabled = true;
} }
} }
@ -7273,5 +7273,152 @@ namespace INT63DC_6CH.Forms
this.EquipmentStatus1 = this.EquipmentStatus; this.EquipmentStatus1 = this.EquipmentStatus;
} }
private void smartTCPMultiServer_OnReceiveHandler(SmartTCPMultiServer.CHandleClinet.READINFO datas)
{
int ret = 0;
byte[] readByte;
string strRecData = "";
byte[] sendOPCDatas = new byte[57];
byte[] sendModbusDatas;
byte[] madeDatas;
try
{
readByte = datas.receiveDatas;
strRecData = SmartTCPMultiServer.ConvertAsciiByteToString(readByte);
}
catch
{
return;
}
switch (this.SystemConfig.EthernetMode)
{
case (int)DataStore.E_CommMode.f4_Modbus:
#region Modbus TCP
if (this.smartTCPMultiServer.ClientInfoList != null)
{
if (readByte[7] == 0x03) // Read Holding Register
{
#region Read Holding Register
try
{
byte[] responseData;
byte errorCheck = this.Modbus.CheckRequestSpecialDataErrorTCP(readByte, ModbusFunctionCode.FunctionCode_03);
if (errorCheck == 0x00)
responseData = this.Modbus.MakeTCPResponseData(readByte, this.Protocol_Modbus_Server_Read_Lane_Data(readByte), ModbusFunctionCode.FunctionCode_03);
else
responseData = this.Modbus.MakeTCPErrorResponseData(readByte, errorCheck, ModbusFunctionCode.FunctionCode_03);
foreach (SmartTCPMultiServer.CLIENTSINFOS client in this.smartTCPMultiServer.ClientInfoList)
{
this.smartTCPMultiServer.SendByteByClientID(client.strID, responseData);
}
// 로그
if (this.IsCommunicationLogOpen == true)
{
this.smartFileCommunicationLog.WriteString(string.Format("Receive TCP ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, BitConverter.ToString(readByte)));
this.smartFileCommunicationLog.WriteString(string.Format("Send TCP ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, BitConverter.ToString(responseData)));
}
}
catch
{
}
#endregion
}
else if (readByte[7] == 0x10) // Write Multiple Register
{
#region Write Multiple Register
try
{
byte[] errorResponseData = new byte[9];
byte[] responseData = new byte[12];
byte errorCheck = this.Modbus.CheckRequestSpecialDataErrorTCP(readByte, ModbusFunctionCode.FunctionCode_16);
if (errorCheck == 0x00)
{
for (int i = 0; i < 12; i++)
responseData[i] = readByte[i];
responseData[5] = 0x06;
foreach (SmartTCPMultiServer.CLIENTSINFOS client in this.smartTCPMultiServer.ClientInfoList)
{
this.smartTCPMultiServer.SendByteByClientID(client.strID, responseData);
}
this.ReceiveModbusTCPWriteManager(readByte);
}
else
{
for (int i = 0; i < 5; i++)
errorResponseData[i] = readByte[i];
// Length
errorResponseData[5] = 0x03;
// Unit ID
errorResponseData[6] = 0x01;
// Function Code
errorResponseData[7] = 0x90;
// Error Code
errorResponseData[8] = errorCheck;
foreach (SmartTCPMultiServer.CLIENTSINFOS client in this.smartTCPMultiServer.ClientInfoList)
{
this.smartTCPMultiServer.SendByteByClientID(client.strID, responseData);
}
}
// 로그
if (this.IsCommunicationLogOpen == true)
{
this.smartFileCommunicationLog.WriteString(string.Format("Receive TCP ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, BitConverter.ToString(readByte)));
this.smartFileCommunicationLog.WriteString(string.Format("Send TCP ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, BitConverter.ToString(responseData)));
}
}
catch
{
}
#endregion
}
else // Read Input Register(0x04)
{
#region Read Input Register
try
{
byte[] responseData;
byte errorCheck = this.Modbus.CheckRequestSpecialDataErrorTCP(readByte, ModbusFunctionCode.FunctionCode_04);
if (errorCheck == 0x00)
responseData = this.Modbus.MakeTCP04ResponseData(readByte, this.Protocol_Modbus_Server_Read_Lane_Data(readByte));
else
responseData = this.Modbus.MakeTCP04ErrorResponseData(readByte, errorCheck);
foreach (SmartTCPMultiServer.CLIENTSINFOS client in this.smartTCPMultiServer.ClientInfoList)
{
this.smartTCPMultiServer.SendByteByClientID(client.strID, responseData);
}
// 로그
if (this.IsCommunicationLogOpen == true)
{
this.smartFileCommunicationLog.WriteString(string.Format("Receive TCP ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, BitConverter.ToString(readByte)));
this.smartFileCommunicationLog.WriteString(string.Format("Send TCP ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, BitConverter.ToString(responseData)));
}
}
catch
{
}
#endregion
}
}
#endregion
break;
default:
break;
}
}
} }
} }

View File

@ -1497,8 +1497,8 @@ namespace INT63DC_6CH.Forms
this.labelProductName.Enabled = false; this.labelProductName.Enabled = false;
// 공압 알람 이면 장비 정지 // 공압 알람 이면 장비 정지
if(this.ParentForm.CurrentAlarmList.IsPressureError == true) //if(this.ParentForm.CurrentAlarmList.IsPressureError == true)
this.ParentForm.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard); // this.ParentForm.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
#endregion #endregion
} }
else else
@ -1804,10 +1804,16 @@ namespace INT63DC_6CH.Forms
this.panelAlarmMessageBox2.BringToFront(); this.panelAlarmMessageBox2.BringToFront();
this.panelAlarmMessageBox2.Visible = true; this.panelAlarmMessageBox2.Visible = true;
this.ParentForm.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard); //this.ParentForm.TransferData(CommunicationCommand.Stop, CommunicationID.MainBoard);
this.ParentForm.TransferData(CommunicationCommand.BuzzerOn, CommunicationID.MainBoard); this.ParentForm.TransferData(CommunicationCommand.BuzzerOn, CommunicationID.MainBoard);
this.ParentForm.CurrentAlarmList.IsBuzzerStatus = true; this.ParentForm.CurrentAlarmList.IsBuzzerStatus = true;
} }
else
{
this.panelAlarmMessageBox2.Visible = false;
this.ParentForm.TransferData(CommunicationCommand.BuzzerOff, CommunicationID.MainBoard);
this.ParentForm.CurrentAlarmList.IsBuzzerStatus = false;
}
} }
public void UpdateDisplayAlarmMessageServoOrigin() public void UpdateDisplayAlarmMessageServoOrigin()
{ {