liuwf 11 months ago
commit 78f0aa54d7

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Admin.Core.Common")] [assembly: System.Reflection.AssemblyCompanyAttribute("Admin.Core.Common")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] [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.AssemblyProductAttribute("Admin.Core.Common")]
[assembly: System.Reflection.AssemblyTitleAttribute("Admin.Core.Common")] [assembly: System.Reflection.AssemblyTitleAttribute("Admin.Core.Common")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

@ -1 +1 @@
3c08b2a6f95957043123cba0d01dcd1675663fc7 084e48044896d89835d97ecf2b6482131ddb1364494a27aefb0b1990a1319ddf

@ -8,4 +8,6 @@ build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules = build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = Admin.Core.Common 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" /> <ProjectReference Include="..\Aucma.Core.Tasks\Aucma.Core.Tasks.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Log\" />
</ItemGroup>
</Project> </Project>

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

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

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

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

@ -18,6 +18,7 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Threading; using System.Windows.Threading;
using static ICSharpCode.SharpZipLib.Zip.ExtendedUnixData;
namespace Aucma.Core.BoxFoam.ViewModels namespace Aucma.Core.BoxFoam.ViewModels
{ {
@ -35,6 +36,7 @@ namespace Aucma.Core.BoxFoam.ViewModels
MonitorPageView monitorPage = new MonitorPageView();//任务监控 MonitorPageView monitorPage = new MonitorPageView();//任务监控
FoamMachinesPageView foamMachinesPageView = new FoamMachinesPageView(); FoamMachinesPageView foamMachinesPageView = new FoamMachinesPageView();
bool startflag = true; bool startflag = true;
bool flag2 = true;
public MainWindowViewModel() public MainWindowViewModel()
{ {
UserContent = firstPage; UserContent = firstPage;
@ -46,6 +48,7 @@ namespace Aucma.Core.BoxFoam.ViewModels
{ {
await init(); await init();
await RefreshTeamTime();//班组时间 await RefreshTeamTime();//班组时间
await ClearProduct();
}); });
TeamSwitchBusiness teamSwitchBusiness = new TeamSwitchBusiness(); TeamSwitchBusiness teamSwitchBusiness = new TeamSwitchBusiness();
@ -496,66 +499,6 @@ namespace Aucma.Core.BoxFoam.ViewModels
{ {
DateTime now = DateTime.Now; DateTime now = DateTime.Now;
CurrentDateTime = now.ToString("yyyy-MM-dd HH:mm:ss"); 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) catch (Exception ex)
{ {
@ -572,23 +515,90 @@ namespace Aucma.Core.BoxFoam.ViewModels
} }
#endregion #endregion
#region MyRegion #region 定时清除产量
//private void Timer_Tick(object sender, EventArgs e) private Task ClearProduct()
//{ {
// DateTime now = DateTime.Now; while (true)
{
// // 判断当前是否是白班时间段 if (flag2)
// if (now.Hour >= 8 && now.Hour < 20) {
// { flag2 = false;
// ShiftStr = $"白班 08点-20点"; try
// } {
// else 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);
// ShiftStr = $"夜班 20点-08点"; string sTime = scheduledTime.ToString("yyyy-MM-dd HH:mm:ss");
// } Console.WriteLine($"定时班组切换清空产量时间夜班:{sTime.Equals(date)}");
// CurrentDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); 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 #endregion
} }
} }

Loading…
Cancel
Save