liuwf 11 months ago
commit 78f0aa54d7

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Admin.Core.Common")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b14cee841cc126714bd9974bfb490340b0c3a348")]
[assembly: System.Reflection.AssemblyProductAttribute("Admin.Core.Common")]
[assembly: System.Reflection.AssemblyTitleAttribute("Admin.Core.Common")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

@ -1 +1 @@
3c08b2a6f95957043123cba0d01dcd1675663fc7
084e48044896d89835d97ecf2b6482131ddb1364494a27aefb0b1990a1319ddf

@ -8,4 +8,6 @@ build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = Admin.Core.Common
build_property.ProjectDir = E:\c#\AUCMA\new\Admin.Core.Common\
build_property.ProjectDir = D:\Project\gitea\AUCMA\SCADA\Admin.Core.Common\
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =

@ -38,8 +38,4 @@
<ProjectReference Include="..\Aucma.Core.Tasks\Aucma.Core.Tasks.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Log\" />
</ItemGroup>
</Project>

@ -57,11 +57,7 @@ namespace Admin.Core.RealTimeService
//AutoMapper
services.AddAutoMapperSetup();
//PLC
//services.AddPlcSetup();
//ÈÎÎñµ÷¶È
//services.AddJobSetup();
//ÈÎÎñ
services.AddTouchSocketSetup();
services.AddPlcSetup();
//支持编码大全 例如:支持 System.Text.Encoding.GetEncoding("GB2312") System.Text.Encoding.GetEncoding("GB18030")
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
}
@ -82,11 +78,12 @@ namespace Admin.Core.RealTimeService
/// </summary>
/// <param name="app"></param>
/// <param name="env"></param>
public void Configure(IApplicationBuilder app, ITouchSocketService socket)
public void Configure(IApplicationBuilder app, IRunPlcService runPlcService, ITouchSocketService socket)
{
// 使用静态文件
app.UseStaticFiles();
app.UseTouchSocketMildd(socket);
//PLC
app.UsePlcMildd(runPlcService);
}
#region 注册服务

@ -181,27 +181,19 @@
"PLCServer": [
{
"Id": 1,
"EquipName": "MCPlc1",
"IP": "10.10.93.151",
"Port": 5002
},
{
"Id": 1,
"EquipName": "MCPlc2",
"IP": "10.10.93.152",
"Port": 5002
},
{
"Id": 1,
"EquipName": "MCPlc3",
"IP": "10.10.93.153",
"Port": 5002
"EquipName": "foamLine1Plc",
"PlcType": "Siemens",
"Enabled": true,
"IP": "10.10.93.21",
"Port": 102
},
{
"Id": 1,
"EquipName": "MCPlc4",
"IP": "10.10.93.154",
"Port": 5002
"Id": 2,
"EquipName": "foamLine2Plc",
"PlcType": "Siemens",
"Enabled": true,
"IP": "10.10.93.1",
"Port": 102
}
],
"IpRateLimiting": {

@ -156,11 +156,16 @@ namespace Aucma.Core.BoxFoam.Business
bool result= obj.plc.WriteString("DB200.132", materialCode);//写入物料号
if (result)
{
Thread.Sleep(2500);
int space = obj.plc.ReadInt16("DB200.438");//读取货道号大约1.5s 可以获取
Console.WriteLine($"物料MES码{materialBarCode},》入库货道:{space}");
logHelper.Info($"物料MES码{materialBarCode},》入库货道:{space}");
LogDelegateEvent?.Invoke($"物料MES码{materialBarCode},》物料码:{materialCode}", "White");
int space = 0;
do
{
space = obj.plc.ReadInt16("DB200.438");//读取货道号大约1.5s 可以获取
Console.WriteLine($"物料入库货道:{space}");
} while (space==0);
Console.WriteLine($"物料MES码{materialBarCode}》入库货道:{space}");
logHelper.Info($"物料MES码{materialBarCode}》入库货道:{space}");
LogDelegateEvent?.Invoke($"物料MES码{materialBarCode}》物料码:{materialCode}", "White");
//更新货道入库
await EnterStore(materialBarCode, space);
//更新过点数

@ -159,7 +159,7 @@ namespace Aucma.Core.BoxFoam.Business
var flag = obj1.plc.WriteBool("M6.0", true);//换班 数据清空
Thread.Sleep(500);
obj1.plc.WriteBool("M6.0", false);//数据清空后复位
Console.WriteLine($"班组切换清空1~6区产量数据{(flag == true ? "" : "")}");
Console.WriteLine($"【{DateTime.Now}】班组切换清空1~6区产量数据{(flag == true ? "" : "")}");
log.Warn($"班组切换清空1~6区产量数据{(flag == true ? "" : "")}");
}
}
@ -171,7 +171,7 @@ namespace Aucma.Core.BoxFoam.Business
bool flag = obj2.plc.WriteBool("M6.0", true);//换班 数据清空
Thread.Sleep(500);
obj2.plc.WriteBool("M6.0", false);//数据清空后复位
Console.WriteLine($"班组切换清空7~12区产量数据{(flag == true ? "" : "")}");
Console.WriteLine($"【{DateTime.Now}】班组切换清空7~12区产量数据{(flag == true ? "" : "")}");
log.Warn($"班组切换清空7~12区产量数据{(flag == true ? "" : "")}");
}
}

@ -18,6 +18,7 @@ using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;
using static ICSharpCode.SharpZipLib.Zip.ExtendedUnixData;
namespace Aucma.Core.BoxFoam.ViewModels
{
@ -35,6 +36,7 @@ namespace Aucma.Core.BoxFoam.ViewModels
MonitorPageView monitorPage = new MonitorPageView();//任务监控
FoamMachinesPageView foamMachinesPageView = new FoamMachinesPageView();
bool startflag = true;
bool flag2 = true;
public MainWindowViewModel()
{
UserContent = firstPage;
@ -46,6 +48,7 @@ namespace Aucma.Core.BoxFoam.ViewModels
{
await init();
await RefreshTeamTime();//班组时间
await ClearProduct();
});
TeamSwitchBusiness teamSwitchBusiness = new TeamSwitchBusiness();
@ -496,66 +499,6 @@ namespace Aucma.Core.BoxFoam.ViewModels
{
DateTime now = DateTime.Now;
CurrentDateTime = now.ToString("yyyy-MM-dd HH:mm:ss");
//DateTime scheduledTime = new DateTime(now.Year, now.Month, now.Day, 20, 00, 00);
//string date = scheduledTime.ToString("yyyy-MM-dd HH:mm:ss");
//Console.WriteLine($"班组切换清空产量时间夜班:{CurrentDateTime.Equals(date)}");
//if (CurrentDateTime.Equals(date))
//{
// var obj1 = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamLine1Plc"));
// if (obj1 != null)
// {
// if (obj1.plc.IsConnected)
// {
// var flag = obj1.plc.WriteBool("M6.0", true);//换班 数据清空
// Thread.Sleep(500);
// obj1.plc.WriteBool("M6.0", false);//换班 数据清空
// Console.WriteLine($"班组切换清空1~6区产量数据{(flag == true ? "成功" : "失败")}");
// log.Warn($"班组切换清空1~6区产量数据{(flag == true ? "成功" : "失败")}");
// }
// }
// var obj2 = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamLine2Plc"));
// if (obj2 != null)
// {
// if (obj2.plc.IsConnected)
// {
// bool flag = obj2.plc.WriteBool("M6.0", true);//换班 数据清空
// Thread.Sleep(500);
// obj2.plc.WriteBool("M6.0", false);//换班 数据清空
// Console.WriteLine($"班组切换清空7~12区产量数据{(flag == true ? "成功" : "失败")}");
// log.Warn($"班组切换清空7~12区产量数据{(flag == true ? "成功" : "失败")}");
// }
// }
//}
//DateTime scheduledTime2 = new DateTime(now.Year, now.Month, now.Day, 8, 00, 00);
//string date2 = scheduledTime2.ToString("yyyy-MM-dd HH:mm:ss");
//Console.WriteLine($"班组切换清空产量时间白班:{CurrentDateTime.Equals(date2)}");
//if (CurrentDateTime.Equals(date2))
//{
// var obj1 = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamLine1Plc"));
// if (obj1 != null)
// {
// if (obj1.plc.IsConnected)
// {
// var flag = obj1.plc.WriteBool("M6.0", true);//换班 数据清空
// Thread.Sleep(500);
// obj1.plc.WriteBool("M6.0", false);//换班 数据清空
// Console.WriteLine($"班组切换清空产量时间夜班:{(flag == true ? "成功" : "失败")}");
// log.Warn($"班组切换清空1~6区产量数据{(flag == true ? "成功" : "失败")}");
// }
// }
// var obj2 = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamLine2Plc"));
// if (obj2 != null)
// {
// if (obj2.plc.IsConnected)
// {
// bool flag = obj2.plc.WriteBool("M6.0", true);//换班 数据清空
// Thread.Sleep(500);
// obj2.plc.WriteBool("M6.0", false);//换班 数据清空
// Console.WriteLine($"班组切换清空产量时间夜班:{(flag == true ? "成功" : "失败")}");
// log.Warn($"班组切换清空7~12区产量数据{(flag == true ? "成功" : "失败")}");
// }
// }
//}
}
catch (Exception ex)
{
@ -572,23 +515,90 @@ namespace Aucma.Core.BoxFoam.ViewModels
}
#endregion
#region MyRegion
//private void Timer_Tick(object sender, EventArgs e)
//{
// DateTime now = DateTime.Now;
// // 判断当前是否是白班时间段
// if (now.Hour >= 8 && now.Hour < 20)
// {
// ShiftStr = $"白班 08点-20点";
// }
// else
// {
// ShiftStr = $"夜班 20点-08点";
// }
// CurrentDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
//}
#region 定时清除产量
private Task ClearProduct()
{
while (true)
{
if (flag2)
{
flag2 = false;
try
{
DateTime now = DateTime.Now;
string date = now.ToString("yyyy-MM-dd HH:mm:ss");
DateTime scheduledTime = new DateTime(now.Year, now.Month, now.Day, 20, 00, 00);
string sTime = scheduledTime.ToString("yyyy-MM-dd HH:mm:ss");
Console.WriteLine($"定时班组切换清空产量时间夜班:{sTime.Equals(date)}");
if (sTime.Equals(date))
{
var obj1 = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamLine1Plc"));
if (obj1 != null)
{
if (obj1.plc.IsConnected)
{
bool flag = obj1.plc.WriteBool("M6.0", true);//换班 数据清空
Thread.Sleep(500);
bool flag1 = obj1.plc.WriteBool("M6.0", false);//换班 数据清空
Console.WriteLine($"班组切换清空1~6区产量数据{flag}:{flag1}");
log.Warn($"定时班组切换清空1~6区产量数据{(flag == true ? "" : "")}");
}
}
var obj2 = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamLine2Plc"));
if (obj2 != null)
{
if (obj2.plc.IsConnected)
{
bool flag = obj2.plc.WriteBool("M6.0", true);//换班 数据清空
Thread.Sleep(500);
bool flag1 = obj2.plc.WriteBool("M6.0", false);//换班 数据清空
Console.WriteLine($"班组切换清空7~12区产量数据{flag}:{flag1}");
log.Warn($"定时班组切换清空7~12区产量数据{(flag == true ? "" : "")}");
}
}
}
DateTime scheduledTime2 = new DateTime(now.Year, now.Month, now.Day, 8, 00, 00);
string date2 = scheduledTime2.ToString("yyyy-MM-dd HH:mm:ss");
Console.WriteLine($"定时班组切换清空产量时间白班:{sTime.Equals(date2)}");
if (sTime.Equals(date2))
{
var obj1 = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamLine1Plc"));
if (obj1 != null)
{
if (obj1.plc.IsConnected)
{
var flag = obj1.plc.WriteBool("M6.0", true);//换班 数据清空
Thread.Sleep(500);
var flag1 = obj1.plc.WriteBool("M6.0", false);//换班 数据清空
Console.WriteLine($"班组切换清空产量时间夜班:{flag}:{flag1}");
log.Warn($"定时班组切换清空1~6区产量数据{(flag1 == true ? "" : "")}");
}
}
var obj2 = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamLine2Plc"));
if (obj2 != null)
{
if (obj2.plc.IsConnected)
{
bool flag = obj2.plc.WriteBool("M6.0", true);//换班 数据清空
Thread.Sleep(500);
bool flag2 = obj2.plc.WriteBool("M6.0", false);//换班 数据清空
Console.WriteLine($"班组切换清空产量时间夜班:{flag}:{flag2}");
log.Warn($"定时班组切换清空7~12区产量数据{(flag == true ? "" : "")}");
}
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
startflag = true;
}
}
}
}
#endregion
}
}

Loading…
Cancel
Save