读取箱体数量

master
11 months ago
parent d9f18a2636
commit 7050ab32bc

@ -1705,6 +1705,17 @@ where machine_code = 'X1' and bind_status = '0' order by update_time DESC";
} }
return ""; return "";
} }
public DataTable GetWcsPlcPointBoxCount(string pointNo)
{
string sql = $"SELECT * FROM wcs_plc_point WHERE plc_point_no ='{pointNo}' and equip='BoxCount'";
DataSet ds = Utils.netClientDBHelper.getDataSet(sql);
if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
{
return ds.Tables[0];
}
return null;
}
} }
public class MesTableSelfDetialModel public class MesTableSelfDetialModel
{ {

@ -10,7 +10,7 @@
<!--车间编码--> <!--车间编码-->
<add key="SiteCode" value="999" /> <add key="SiteCode" value="999" />
<!--设备编码--> <!--设备编码-->
<add key="DeviceCode" value="C4" /> <add key="DeviceCode" value="C3" />
<!--上位机类型 0:工单准备1成型机\shoupei2烘房,3:人员登录--> <!--上位机类型 0:工单准备1成型机\shoupei2烘房,3:人员登录-->
<add key="ClientMode" value="1" /> <add key="ClientMode" value="1" />
<add key="SerialPort" value="COM5" /> <add key="SerialPort" value="COM5" />

@ -10,7 +10,7 @@
<!--车间编码--> <!--车间编码-->
<add key="SiteCode" value="1000" /> <add key="SiteCode" value="1000" />
<!--设备编码--> <!--设备编码-->
<add key="DeviceCode" value="XL02" /> <add key="DeviceCode" value="XL03" />
<!--上位机类型 0:工单准备1成型机\shoupei2烘房,3:人员登录,4:称重系统--> <!--上位机类型 0:工单准备1成型机\shoupei2烘房,3:人员登录,4:称重系统-->
<add key="ClientMode" value="1" /> <add key="ClientMode" value="1" />

@ -369,8 +369,7 @@
Margin="20,0" Margin="20,0"
Click="ReadOrder_Click" Click="ReadOrder_Click"
Content="获取" Content="获取"
Style="{StaticResource btnKey}" Style="{StaticResource btnKey}" />
Visibility="Collapsed" />
</StackPanel> </StackPanel>
<StackPanel <StackPanel
Grid.Row="2" Grid.Row="2"

@ -1035,29 +1035,49 @@ namespace XGLFinishPro.Views
{ {
} }
private bool IsReading = false;
private void ReadOrder_Click(object sender, RoutedEventArgs e) private void ReadOrder_Click(object sender, RoutedEventArgs e)
{ {
int count = 0; try
bool isSuccess = false;
while (count++ < 3)
{ {
try if (IsReading)
{ {
LanJu_Operator.plc.Connection(LanJu_Operator.PlcIp); return;
int number = int.Parse(_deviceCode.Substring(2));
isSuccess = true;
break;
} }
catch IsReading = true;
LanJu_Operator.plc.Connection(LanJu_Operator.PlcIp);
int number = int.Parse(_deviceCode.Substring(2));
DataTable dataTable = formingMachineService.GetWcsPlcPointBoxCount("BoxCount" + number);
if (dataTable != null && dataTable.Rows.Count > 0)
{ {
LanJu_Operator.plc = new PlcHelper(); string address = dataTable.Rows[0]["plc_point_address"].ToString();
var boxCount = LanJu_Operator.plc.Read(new CentralControl.BaseData.PlcSetting
{
PlcAddress = address,
PlcDataType = 1,
PlcValueLength = "2"
});
if (boxCount != null && int.TryParse(boxCount.ToString(), out int count))
{
txtQuantity.Text = boxCount.ToString();
}
else
{
CustomMessageBox.Show("读取失败!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
}
}
else
{
CustomMessageBox.Show("获取点位信息失败!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
} }
} }
if (!isSuccess) catch
{ {
CustomMessageBox.Show("读取失败!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning); CustomMessageBox.Show("Plc连接失败", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
return; }
finally
{
IsReading = false;
} }
} }
} }

File diff suppressed because it is too large Load Diff

@ -2,11 +2,14 @@
using CommonFunc; using CommonFunc;
using CommonFunc.Tools; using CommonFunc.Tools;
using HandyControl.Tools.Extension; using HandyControl.Tools.Extension;
using LiveCharts.Charts;
using Microsoft.SqlServer.Server;
using Newtonsoft.Json; using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Net.Http; using System.Net.Http;
using System.Net.Sockets;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Timers; using System.Timers;
@ -30,7 +33,7 @@ namespace XGLFinishPro.Views
/// </summary> /// </summary>
public partial class LanJu_Operator : UserControl public partial class LanJu_Operator : UserControl
{ {
public static string PlcIp= "172.18.15.20"; public static string PlcIp = "172.18.15.20";
public static bool isSuccess = false; public static bool isSuccess = false;
public static bool IsWrite = false; public static bool IsWrite = false;
public static PlcHelper plc = new PlcHelper(); public static PlcHelper plc = new PlcHelper();
@ -789,7 +792,7 @@ namespace XGLFinishPro.Views
} }
else if (type == 1) else if (type == 1)
{ {
if (!formingMachineService.UpdateProWorkBatchInWorkBatchCode(lineCode, batchCode, status,productCode,productName)) if (!formingMachineService.UpdateProWorkBatchInWorkBatchCode(lineCode, batchCode, status, productCode, productName))
{ {
CustomMessageBox.Show("更新打印机表状态失败!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning); CustomMessageBox.Show("更新打印机表状态失败!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
return false; return false;
@ -1211,9 +1214,10 @@ namespace XGLFinishPro.Views
{ {
if (row["plc_point_no"].ToString() == height) if (row["plc_point_no"].ToString() == height)
{ {
plc.Write(new PlcSetting() { plc.Write(new PlcSetting()
PlcAddress= row["plc_point_address"].ToString() , {
PlcValueLength="2" PlcAddress = row["plc_point_address"].ToString(),
PlcValueLength = "2"
}, h); }, h);
} }
else if (row["plc_point_no"].ToString() == width1) else if (row["plc_point_no"].ToString() == width1)

Loading…
Cancel
Save