change-门体发泡状态,条码绑定业务逻辑

dev
liuwf 1 year ago
parent 5ba16b20aa
commit 3d247fb91d

@ -40,6 +40,7 @@ namespace Admin.Core.Service
List<CodeBindCharts> list = null;
var _db = this.BaseDal.Db;
list = await _db.CopyNew().Ado.SqlQueryAsync<CodeBindCharts>("SELECT BOX_NAME as BoxName,COUNT(*) as Amount FROM CODE_BINDING WHERE PRODUCT_CODE IS NOT NULL GROUP BY BOX_NAME ");
list.OrderBy(x =>x.BoxName);
return list;
}
catch (Exception)

@ -299,10 +299,10 @@ namespace Aucma.Core.BoxFoam.Business
return fixtureStatuses;
}
/// <summary>
/// 读取夹具状态
/// 读取夹具状态1正常生产 3暂停生产
/// </summary>
static List<FixtureStatus> ReadFixtureStatus(HwPLc.PlcModel obj, HwPLc.PlcModel obj2)
{
@ -664,7 +664,7 @@ namespace Aucma.Core.BoxFoam.Business
}
/// <summary>
/// 根据二进制字符串确定夹具状态 1正常生产 2暂停生产
/// 根据二进制字符串确定夹具状态 1正常生产 3暂停生产
/// </summary>
static int judgeStatus(string str1)
{
@ -675,7 +675,7 @@ namespace Aucma.Core.BoxFoam.Business
}
else if (str1.Substring(1, 1) == "1")
{
item1 = 2; //
item1 = 3; //
}
return item1;
}

@ -32,6 +32,8 @@ using System.Windows.Media;
using System.Drawing;
using Brushes = System.Windows.Media.Brushes;
using Admin.Core.Model.Model_New;
using Microsoft.IdentityModel.Logging;
using static Npgsql.Replication.PgOutput.Messages.RelationMessage;
/*
*
*/
@ -53,8 +55,7 @@ namespace Aucma.Core.CodeBinding.ViewModels
// 静态变量存code2
private static string code2Str = string.Empty;
// 定时检测数据库有没有pad绑定未放行的数据
System.Timers.Timer timer = new System.Timers.Timer(1000);
public IndexPageViewModel()
{
try
@ -69,38 +70,37 @@ namespace Aucma.Core.CodeBinding.ViewModels
MvCodeHelper.ReceiveCode2Event += receiveCode2;
LoadData();
// 实时绑定两个条码
realBinding();
// pda手持检测plc放行定时器
StartPlcTimer();
//实时绑定条码和实时下发plc放行信号
realBindingAndSendPlc();
Task.Run(() =>
{
Thread.Sleep(5000);
receiveCode1("L23000000899");
Thread.Sleep(2000);
receiveCode2("B23000000824");
//Thread.Sleep(6000);
//receiveCode1("993000000899");
//receiveCode2("993000000824");
});
//Task.Run(() =>
//{
// Thread.Sleep(5000);
// receiveCode1("L23000000899");
// Thread.Sleep(2000);
// receiveCode2("B23000000824");
//});
}
catch (Exception)
catch (Exception ex)
{
log.Error(ex);
}
}
public void realBinding()
/// <summary>
/// 实时绑定条码和实时下发plc放行信号
/// </summary>
public void realBindingAndSendPlc()
{
string tempCode1 ;
string tempCode2;
// 实时绑定条码
Task.Run(() =>
{
while(true)
{
try
{
if (!string.IsNullOrEmpty(code1Str) && !string.IsNullOrEmpty(code2Str))
@ -115,45 +115,39 @@ namespace Aucma.Core.CodeBinding.ViewModels
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
Thread.Sleep(1000);
}
Thread.Sleep(500);
}
});
}
/// <summary>
/// 开启定时器定时读取数据库并下发plc放行信号
/// </summary>
private void StartPlcTimer()
{
if (!timer.Enabled)
{
timer.Elapsed += new System.Timers.ElapsedEventHandler(readDataSendPlc);
timer.AutoReset = true;
timer.Enabled = false;
timer.Start();
}
}
/// <summary>
/// 定时读取plc扫码信号放行完成反馈信号
/// </summary>
private async void readDataSendPlc(object source, System.Timers.ElapsedEventArgs e)
{
List<CodeBindingRecord> records =await _codeBindingRecordServices.QueryAsync(x => x.isPlcPass == 1 && x.RecordTime2 >= System.DateTime.Now.AddDays(-1), "RECORD_TIME2 desc");
if (records != null && records.Count>0)
// 实时下发plc放行信号
Task.Run(() =>
{
CodeBindingRecord record = records[0];
// 下发plc放行信号
if (SendPlcPass())
while (true)
{
record.isPlcPass = 2;
await _codeBindingRecordServices.UpdateAsync(record);
try
{
CodeBindingRecord record = _codeBindingRecordServices.FirstAsync(x => x.isPlcPass == 1 && x.RecordTime2 >= System.DateTime.Now.AddDays(-1)).Result;
if (record != null)
{
// 下发plc放行信号
if (SendPlcPass())
{
record.isPlcPass = 2;
_ = _codeBindingRecordServices.UpdateAsync(record).Result;
}
}
}
catch (Exception ex)
{
log.Error(ex.ToString());
}
Thread.Sleep(500);
}
}
});
}
#region 加载DataGrid数据
private async void LoadData()
{
@ -186,25 +180,53 @@ namespace Aucma.Core.CodeBinding.ViewModels
// 修改为统计近一天白班或夜班
private async void LoadCharts()
{
List<CodeBindCharts> list = await _codeBindingRecordServices.QueryCharts();
// 图表赋值
ChartValues<double> achievement = new ChartValues<double>();
List<string> chartList = new List<string>();
if (list == null) return;
foreach(CodeBindCharts item in list)
try
{
App.Current.Dispatcher.Invoke( () =>
{
ProductionHourList = new List<string>();
List<CodeBindCharts> list = _codeBindingRecordServices.QueryCharts().Result;
// 图表赋值
ChartValues<double> achievement = new ChartValues<double>();
List<string> chartList = new List<string>();
if (list == null) return;
foreach (CodeBindCharts item in list)
{
achievement.Add(item.Amount);
ProductionHourList.Add(item.BoxName.Substring(0, Math.Min(7, item.BoxName.Length)));
}
var column = new ColumnSeries();
column.DataLabels = true;
column.Title = "型号";
column.Values = achievement;
column.Foreground = Brushes.White;
if (ModelStatistics.Count>0 && ModelStatistics.FirstOrDefault().Values.Count == achievement.Count)
{
for (int i = 0; i < achievement.Count(); i++)
{
ModelStatistics.FirstOrDefault().Values[i] = achievement.ElementAt(i);
}
}
else
{
ModelStatistics.Clear();
ModelStatistics.Add(column);
}
});
}
catch (Exception)
{
achievement.Add(item.Amount);
chartList.Add(item.BoxName);
throw;
}
var column = new ColumnSeries();
column.DataLabels = true;
column.Title = "型号";
column.Values = achievement;
column.Foreground = Brushes.White;
ModelStatistics.Add(column);
ProductionHourList = chartList;
}
// 测试方法
@ -233,20 +255,20 @@ namespace Aucma.Core.CodeBinding.ViewModels
}
}
///// <summary>
///// 条码1扫描时间
///// </summary>
//private string code1Time = string.Empty;
//public string Code1Time
//{
// get { return code1Time; }
// set
// {
// code1Time = value;
// OnPropertyChanged(nameof(Code1Time));
// }
//}
/// <summary>
/// 条码1扫描时间
/// </summary>
private string code1Time = string.Empty;
public string Code1Time
{
get { return code1Time; }
set
{
code1Time = value;
OnPropertyChanged(nameof(Code1Time));
}
}
/// <summary>
/// 条码2
/// </summary>
@ -263,16 +285,17 @@ namespace Aucma.Core.CodeBinding.ViewModels
///// <summary>
///// 条码2扫描时间
///// </summary>
//private string code2Time = string.Empty;
//public string Code2Time
//{
// get { return code2Time; }
// set
// {
// code2Time = value;
// OnPropertyChanged(nameof(Code2Time));
// }
//}
private string code2Time = string.Empty;
public string Code2Time
{
get { return code2Time; }
set
{
code2Time = value;
OnPropertyChanged(nameof(Code2Time));
}
}
/// <summary>
/// 绑定提示信息
/// </summary>
@ -286,6 +309,7 @@ namespace Aucma.Core.CodeBinding.ViewModels
OnPropertyChanged(nameof(BindingInfo));
}
}
#region 日产量柱状图X轴日期
/// <summary>
/// 日产量柱状图X轴日期
@ -327,54 +351,16 @@ namespace Aucma.Core.CodeBinding.ViewModels
}
#endregion
/// <summary>
/// code1扫码信息刷新
/// </summary>
/// <param name="materialType"></param>
private void RefreshCode1(string code1, string time)
{
Code1 = code1;
// Code1Time = time;
}
/// <summary>
/// code2扫码信息及表格记录刷新
/// </summary>
/// <param name="materialType"></param>
private void RefreshCode2(CodeBindingRecord record)
{
Code2 = record.ProductCode;
// Code2Time = record.RecordTime2.ToString();
if (record.isPlcPass==2)
{
BindingInfo = "条码【" + record.BoxCode + "】与SN码【" + record.ProductCode + "】绑定成功,下发Plc放行成功";
}
else
{
BindingInfo = "条码【" + record.BoxCode + "】与SN码【" + record.ProductCode + "】下发Plc放行失败";
}
Application.Current.Dispatcher.Invoke(() =>
{
// ReaderInfo readerToUpdate = (ReaderInfo)ListItems.Select(item => item.No == 2);
ListItems.Add(new ReaderInfo() { No = ListItems.Count+1, BoxCode = record.BoxCode, ProductCode = record.ProductCode, BoxName = record.BoxName,BindingResult = record.BindingResult, IsPlcPass = record.isPlcPass==2?"plc放行成功":"",RecordTime = record.RecordTime2.ToString() });
});
}
/// <summary>
/// 条码绑定,条码1处理
/// </summary>
/// <param name="materialType"></param>
private async void receiveCode1(string code1)
{
log.Info("进入条码1处理函数receiveCode1,code1:" + code1);
DateTime time = System.DateTime.Now;
string strTime = time.ToString();
// 1.刷新界面条码信息
log.Info("扫描到MES条码:" + code1);
// 全局变量赋值SN码扫描后使用
code1Str = code1;
RefreshCode1(code1, strTime);
RefreshCode1(code1);
#region
// 2.创建任务更新数据库条码1
// CodeBindingRecord codeRecord = new CodeBindingRecord();
@ -393,70 +379,108 @@ namespace Aucma.Core.CodeBinding.ViewModels
//});
//log.Info("条码1记录更新");
#endregion
}
private async void receiveCode2(string code2)
{
log.Info("扫描到成品条码:" + code1);
// 1.刷新界面条码信息
// 全局变量赋值SN码扫描后使用
code2Str = code2;
RefreshCode2(code2);
}
private void RefreshCode1(string code1)
{
DateTime time = System.DateTime.Now;
Code1 = code1;
Code1Time = time.ToString();
}
private void RefreshCode2(string code2)
{
DateTime time = System.DateTime.Now;
Code2 = code2;
Code2Time = time.ToString();
// Code2 = record.ProductCode;
//// Code2Time = record.RecordTime2.ToString();
// if (record.isPlcPass==2)
// {
// BindingInfo = "条码【" + record.BoxCode + "】与SN码【" + record.ProductCode + "】绑定成功,下发Plc放行成功";
// }
// else
// {
// BindingInfo = "条码【" + record.BoxCode + "】与SN码【" + record.ProductCode + "】下发Plc放行失败";
// }
// Application.Current.Dispatcher.Invoke(() =>
// {
// // ReaderInfo readerToUpdate = (ReaderInfo)ListItems.Select(item => item.No == 2);
// ListItems.Add(new ReaderInfo() { No = ListItems.Count+1, BoxCode = record.BoxCode, ProductCode = record.ProductCode, BoxName = record.BoxName,BindingResult = record.BindingResult, IsPlcPass = record.isPlcPass==2?"plc放行成功":"",RecordTime = record.RecordTime2.ToString() });
// });
}
/// <summary>
/// 条码绑定,条码2处理
/// 提示信息刷新并且存日志
/// </summary>
/// <param name="materialType"></param>
private async void receiveCode2(string code2)
/// <param name="logStr"></param>
private void RefreshAndWriteLog(string logStr)
{
log.Info("进入条码2处理函数receiveCode2,code2:" + code2);
// 1.刷新界面条码信息
// 全局变量赋值SN码扫描后使用
code2Str = code2;
DateTime time = System.DateTime.Now;
BindingInfo = time + ":" + logStr;
log.Info(logStr);
}
public void BindingCode(string code1,string code2)
{
try
{
log.Info("开始处理条码绑定:");
RefreshAndWriteLog("开始绑定MES条码:" + code1 + " SN条码:" + code2);
// 1.数据库查询各个工序质检结果,不合格报警
// 2.查询条码绑定记录表(内胆箱壳绑定处就应该插入记录)绑定SN码
CodeBindingRecord record = _codeBindingRecordServices.FirstAsync(x => x.BoxCode == code1).Result;
BaseMaterialInfo materialInfo = _baseMaterialInfoServices.FirstAsync(x => x.MaterialCode == code2.Substring(2, 10)).Result;
if (record == null)
{
RefreshAndWriteLog("未查询到MES条码记录,集存库未绑定箱壳内胆");
return;
}
BaseMaterialInfo materialInfo = _baseMaterialInfoServices.FirstAsync(x => x.MaterialCode == code1.Substring(7, 10)).Result;
record.BoxName = materialInfo.MaterialName;
record.ProductCode = code2;
record.RecordTime1 = System.DateTime.Now;
record.RecordTime2 = System.DateTime.Now;
record.isPlcPass = 1;
record.BindingResult = "成功";
// 3.下发plc放行信号
if (SendPlcPass())
bool result =_codeBindingRecordServices.UpdateAsync(record).Result;
if (result)
{
record.isPlcPass = 2;
RefreshAndWriteLog("条码【" + record.BoxCode + "】与SN码【" + record.ProductCode + "】绑定成功");
#region 更新过点数据,插入记录到MATERIAL_COMPLETION表
//PrintBarCode print = await _printBarCodeServices.FirstAsync(x => x.MaterialBarcode == code1);
//if (print != null) return;
//MaterialCompletion completion = new MaterialCompletion();
//completion.OrderCode = print.OrderCode;
//completion.MaterialBarcode = code1;
//completion.MaterialCode = print.MaterialCode;
//completion.MaterialName = print.MaterialName;
//completion.StationName = "1007";
//completion.CompleteDate = DateTime.Now;
//await _iMaterialCompletionServices.AddAsync(completion);
#endregion
}
_codeBindingRecordServices.UpdateAsync(record);
#region 更新过点数据,插入记录到MATERIAL_COMPLETION表
//PrintBarCode print = await _printBarCodeServices.FirstAsync(x => x.MaterialBarcode == code1);
//if (print != null) return;
//MaterialCompletion completion = new MaterialCompletion();
//completion.OrderCode = print.OrderCode;
//completion.MaterialBarcode = code1;
//completion.MaterialCode = print.MaterialCode;
//completion.MaterialName = print.MaterialName;
//completion.StationName = "1007";
//completion.CompleteDate = DateTime.Now;
//await _iMaterialCompletionServices.AddAsync(completion);
#endregion
// 2.刷新界面信息
RefreshCode2(record);
}
catch (Exception ex)
{
code1Str = string.Empty;
code2Str = string.Empty;
Console.WriteLine(ex.Message.ToString());
RefreshAndWriteLog(ex.Message.ToString());
}
finally
{
@ -511,8 +535,6 @@ namespace Aucma.Core.CodeBinding.ViewModels
{
try
{
lock (string.Empty)
{
bool isFlag = true;
var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("条码绑定Plc"));
if (obj != null)
@ -539,7 +561,7 @@ namespace Aucma.Core.CodeBinding.ViewModels
{
log.Info("获取plc连接对象信息为空");
}
}
}
catch (Exception ex)
{

@ -100,19 +100,23 @@
<RowDefinition/>
<RowDefinition Height="2*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center" Margin="200 0 0 0 ">
<StackPanel Grid.Row="0" Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center" Margin="100 0 0 0 ">
<Label Content="MES条码 " FontSize="20" Foreground="#FFFFFF"/>
<TextBox TextWrapping="Wrap" Text="{Binding Code1}" Width="350" FontSize="20" Foreground="#FFFFFF"/>
<TextBox TextWrapping="Wrap" Text="{Binding Code1}" Width="300" FontSize="20" Foreground="#FFFFFF"/>
<Label Content="扫描时间 " FontSize="20" Foreground="#FFFFFF"/>
<TextBox TextWrapping="Wrap" Text="{Binding Code1Time}" Width="250" FontSize="20" Foreground="#FFFFFF"/>
<!--<Label Content="订单号 " FontSize="20" Foreground="#FFFFFF"/>
<TextBox TextWrapping="Wrap" Width="300" FontSize="20" Foreground="#FFFFFF"/>-->
</StackPanel>
<StackPanel Grid.Row="1" Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center" Margin="200 0 0 0 ">
<StackPanel Grid.Row="1" Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center" Margin="100 0 0 0 ">
<Label Content="成品条码 " FontSize="20" Foreground="#FFFFFF"/>
<TextBox TextWrapping="Wrap" Text="{Binding Code2}" Width="350" FontSize="20" Foreground="#FFFFFF"/>
<TextBox TextWrapping="Wrap" Text="{Binding Code2}" Width="300" FontSize="20" Foreground="#FFFFFF"/>
<Label Content="扫描时间 " FontSize="20" Foreground="#FFFFFF"/>
<TextBox TextWrapping="Wrap" Text="{Binding Code2Time}" Width="250" FontSize="20" Foreground="#FFFFFF"/>
<!--<Label Content="型号 " FontSize="20" Foreground="#FFFFFF"/>
<TextBox TextWrapping="Wrap" Width="300" FontSize="20" Foreground="#FFFFFF"/>-->
</StackPanel>
<StackPanel Grid.Row="2" Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center" Margin="200 0 0 0 ">
<StackPanel Grid.Row="2" Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center" Margin="100 0 0 0 ">
<Label Content="提示信息 " FontSize="20" Foreground="#FFFFFF"/>
<TextBox TextWrapping="Wrap" Text="{Binding BindingInfo}" Width="500" Height="150" FontSize="20" Foreground="#FFFFFF"/>
</StackPanel>
@ -127,7 +131,7 @@
<TextBlock Text="扫描型号统计" FontSize="20" FontWeight="Bold" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
<Border Grid.Row="1" BorderBrush="#0288d1" BorderThickness="0" CornerRadius="5" Background="Transparent" >
<lvc:CartesianChart Series="{Binding ModelStatistics, UpdateSourceTrigger=PropertyChanged}" LegendLocation="Top" Foreground="White">
<lvc:CartesianChart Series="{Binding ModelStatistics, UpdateSourceTrigger=PropertyChanged}" LegendLocation="Top" Foreground="White" DisableAnimations="True">
<lvc:CartesianChart.DataTooltip >
<lvc:DefaultTooltip SelectionMode="OnlySender" BulletSize="10" Foreground="Black"></lvc:DefaultTooltip>
</lvc:CartesianChart.DataTooltip>

@ -8,9 +8,9 @@ using System.Diagnostics;
using System.Threading;
using NPOI.HSSF.Record;
using Admin.Core.Common;
using Aucma.Core.PLc;
using Aucma.Core.Scanner;
using System.Linq;
using Aucma.Core.HwPLc;
namespace Aucma.Core.DoorFoam.ViewModels
{
@ -29,7 +29,7 @@ namespace Aucma.Core.DoorFoam.ViewModels
public void init()
{
// 设备状态刷新定时器
System.Timers.Timer timer = new System.Timers.Timer(1000 * 5);
System.Timers.Timer timer = new System.Timers.Timer(1000 * 1);
timer.Elapsed += new System.Timers.ElapsedEventHandler(RefreshStatus);
timer.AutoReset = true;
timer.Enabled = true;
@ -67,7 +67,10 @@ namespace Aucma.Core.DoorFoam.ViewModels
/// <param name="e"></param>
public void RefreshPlc()
{
var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("发泡Plc"));
var obj = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("FoamPlc"));
var obj2 = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("DoorPlc"));
// 发泡机plc
if (obj != null)
{
if (obj.plc.IsConnected)
@ -81,8 +84,26 @@ namespace Aucma.Core.DoorFoam.ViewModels
}
else
{
PlcState(true);
PlcState(false);
}
if (obj2 != null)
{
if (obj2.plc.IsConnected)
{
Plc2State(true);
}
else
{
Plc2State(false);
}
}
else
{
Plc2State(false);
}
}
/// <summary>
/// 扫码器状态刷新
@ -258,7 +279,7 @@ namespace Aucma.Core.DoorFoam.ViewModels
#region plc 状态
/// <summary>
/// UI plc 展示状态-文字
/// 发泡机 plc 展示状态-文字
/// </summary>
public string _plcUIStatusWb;
public string PlcUIStatusWb
@ -285,28 +306,72 @@ namespace Aucma.Core.DoorFoam.ViewModels
set => SetProperty(ref _plcUIIcon, value);
}
/// <summary>
/// PLC连接状态-true:连接成功false:失败
/// 发泡线 plc 展示状态-文字
/// </summary>
/// <param name="type"></param>
public string _plc2UIStatusWb;
public string Plc2UIStatusWb
{
get => _plc2UIStatusWb;
set => SetProperty(ref _plc2UIStatusWb, value);
}
/// <summary>
/// UI plc 展示状态-颜色
/// </summary>
public string _plc2UIColor;
public string Plc2UIColor
{
get => _plc2UIColor;
set => SetProperty(ref _plc2UIColor, value);
}
/// <summary>
/// UI plc 展示状态-图标
/// </summary>
public string _plc2UIIcon;
public string Plc2UIIcon
{
get => _plc2UIIcon;
set => SetProperty(ref _plc2UIIcon, value);
}
public void PlcState(bool type)
{
Application.Current.Dispatcher.Invoke(() =>
{
if (type)
{
PlcUIStatusWb = "PLC连接成功";
PlcUIStatusWb = "发泡机PLC";
PlcUIColor = "Green";
PlcUIIcon = "Assets/Images/Green.png";
}
else
{
PlcUIStatusWb = "PLC状态异常";
PlcUIStatusWb = "发泡机PLC";
PlcUIColor = "Red";
PlcUIIcon = "Assets/Images/Red.png";
}
});
}
public void Plc2State(bool type)
{
Application.Current.Dispatcher.Invoke(() =>
{
if (type)
{
Plc2UIStatusWb = "发泡线PLC";
Plc2UIColor = "Green";
Plc2UIIcon = "Assets/Images/Green.png";
}
else
{
Plc2UIStatusWb = "发泡线PLC";
Plc2UIColor = "Red";
Plc2UIIcon = "Assets/Images/Red.png";
}
});
}
#endregion
#region 扫码器1状态

@ -85,6 +85,14 @@
</Border.Background>
</Border>
<TextBlock x:Name="PLCState" Text="{Binding PlcUIStatusWb}" VerticalAlignment="Center" Foreground="{Binding PlcUIColor}" FontSize="15" Margin="10,0"/>
<Border Width="30" Height="30" CornerRadius="15">
<Border.Background>
<ImageBrush x:Name="Plc2Status" ImageSource="{Binding Plc2UIIcon}"/>
</Border.Background>
</Border>
<TextBlock x:Name="PLC2State" Text="{Binding Plc2UIStatusWb}" VerticalAlignment="Center" Foreground="{Binding Plc2UIColor}" FontSize="15" Margin="10,0"/>
<Border Width="30" Height="30" CornerRadius="15">
<Border.Background>
<ImageBrush x:Name="Scanner1Status" ImageSource="{Binding Scanner1UIIcon}"/>

@ -183,7 +183,7 @@
},
"Middleware": {
"Plc": {
"Enabled": false
"Enabled": true
},
"QuartzNetJob": {
"Enabled": false

@ -14,9 +14,9 @@ namespace Aucma.Core.HwPLc
public class SiemensPlc : IPlc
{
private readonly log4net.ILog log = LogManager.GetLogger(typeof(MelsecPlc));
private SiemensS7Net siemensS7Net;
public SiemensS7Net siemensS7Net;
private SiemensPLCS siemensPLCS = SiemensPLCS.S1200;
#region 构造函数
//public MelsecPlc()
//{
@ -478,19 +478,10 @@ namespace Aucma.Core.HwPLc
}
else
{
var k = read.ErrorCode < 0 ? false : true;
if (k)
{
IsConnected = true;
return await Task.FromResult(IsConnected);
}
else
{
IsConnected = false;
return await Task.FromResult(IsConnected);
}
}
}
catch (Exception ex)

@ -12,7 +12,7 @@ namespace Aucma.Core.RunPlc
public class RunPlcService : IRunPlcService
{
System.Timers.Timer timer = new System.Timers.Timer(3000);//创建定时器设置间隔时间为1000毫秒
System.Timers.Timer timer1 = new System.Timers.Timer(3000);
System.Timers.Timer timer1 = new System.Timers.Timer(1000);
#region 构造函数
public RunPlcService()
{
@ -119,12 +119,13 @@ namespace Aucma.Core.RunPlc
}
private async void ExecSiemensHeartTask(object? sender, ElapsedEventArgs e)
{
int num = PlcHelper.melsecList.Count;
int num = PlcHelper.siemensList.Count;
if (num == 0) return;
for (int i = 1; i <= num; i++)
{
var item = PlcHelper.melsecList.Where(c => c.Id == i).FirstOrDefault();
var item = PlcHelper.siemensList.Where(c => c.Id == i).FirstOrDefault();
if (item == null) continue;
if (await item.plc.Read("M100"))
{
item.IsConnect = true;

Loading…
Cancel
Save