taoye 2 лет назад
Родитель
Сommit
e1cf8a6960
8 измененных файлов: 132 добавлений и 69 удалений
  1. +40
    -21
      BPASmartClient.AgvApi/Controllers/robotjobController.cs
  2. +1
    -1
      BPASmartClient.CustomResource/Pages/View/UserManageView.xaml
  3. +27
    -18
      BPASmartClient.CustomResource/Pages/ViewModel/NfcSetViewModel.cs
  4. +23
    -17
      BPASmartClient.MorkF/Control_MorkF.cs
  5. +1
    -1
      BPASmartClient.MorkF/View/DebugView.xaml
  6. +30
    -6
      FryPot_DosingSystem/App.xaml.cs
  7. +3
    -0
      FryPot_DosingSystem/ViewModel/DebugViewModel.cs
  8. +7
    -5
      TestDemo/Form1.cs

+ 40
- 21
BPASmartClient.AgvApi/Controllers/robotjobController.cs Просмотреть файл

@@ -2,6 +2,8 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
using Newtonsoft.Json;
using System.Diagnostics;
using System.Text;

namespace BPASmartClient.AgvApi.Controllers
{
@@ -9,31 +11,44 @@ namespace BPASmartClient.AgvApi.Controllers
[Route("apicallback/quicktron/[Controller]")]
public class robotjobController : ControllerBase
{

/// <summary>
/// 搬运任务状态上报
/// </summary>
/// <param name="sign"></param>
/// <returns></returns>
[HttpPost("report")]
public string report(string sign)
public async Task<string> report()
{
if (sign != null)
//if (sign != null)
//{
try
{
try
using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8))
{
var res = JsonConvert.DeserializeObject<AGVToUpSystem>(sign);
if (res != null)
string body = await reader.ReadToEndAsync();

AGVToUpSystem s = JsonConvert.DeserializeObject<AGVToUpSystem>(body);
if (s != null)
{
Factory.GetInstance.SendReport(res);
Factory.GetInstance.SendReport(s);
return "SUCCESS";
}
}
catch (Exception ex)
{
return ex.ToString();
}

}
//var res = JsonConvert.DeserializeObject<AGVToUpSystem>(sign);
//if (res != null)
//{
// Factory.GetInstance.SendReport(res);
// return "SUCCESS";
//}
}
catch (Exception ex)
{
return ex.ToString();
}

// }
return "Error";
}

@@ -43,25 +58,29 @@ namespace BPASmartClient.AgvApi.Controllers
/// <param name="sign"></param>
/// <returns></returns>
[HttpPost("upstreamrequest")]
public string upstreamrequest(string sign)
public async Task<string> upstreamrequest()
{
if (sign != null)
//if (sign != null)
//{
try
{
try
using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8))
{
var res = JsonConvert.DeserializeObject<Upstreamrequest>(sign);
string body = await reader.ReadToEndAsync();
var res = JsonConvert.DeserializeObject<Upstreamrequest>(body);
if (res != null)
{
Factory.GetInstance.SendUpstreamrequest(sign);
Factory.GetInstance.SendUpstreamrequest(res);
return "SUCCESS";
}
}
catch (Exception ex)
{
return ex.ToString();
}

}
catch (Exception ex)
{
return ex.ToString();
}

// }
return "Error";
}



+ 1
- 1
BPASmartClient.CustomResource/Pages/View/UserManageView.xaml Просмотреть файл

@@ -385,7 +385,7 @@
<Button.Content>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock x:Name="t1" Width="auto" Height="auto" FontFamily="../../Fonts/font/#iconfont" Text="&#xe602;" VerticalAlignment="Center" FontSize="18" Margin="0,0,6,0"/>
<TextBlock x:Name="t2" Width="auto" Height="auto" Text="添加账号" FontSize="17" VerticalAlignment="Center"/>
<TextBlock x:Name="t2" Width="auto" Height="auto" Text="添加用户" FontSize="17" VerticalAlignment="Center"/>
</StackPanel>
</Button.Content>


+ 27
- 18
BPASmartClient.CustomResource/Pages/ViewModel/NfcSetViewModel.cs Просмотреть файл

@@ -20,8 +20,9 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel
{
NfcServer.GetInstance.EnableLogin = true;
permissions.Clear();
Enum.GetNames(typeof(Permission)).ToList()?.ForEach(item => {
if(item !="管理员") permissions.Add(new PermissionSelect() { PermissionName = item });
Enum.GetNames(typeof(Permission)).ToList()?.ForEach(item =>
{
if (item != "管理员") permissions.Add(new PermissionSelect() { PermissionName = item });
});

UserAddCommand = new RelayCommand(() =>
@@ -29,12 +30,12 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel
if (permissions?.FirstOrDefault(p => p.PermissionSelected == true) == null)
{
Info = "Error:请选择一个权限;";
return ;
return;
}
if (CardNum == null || CardNum?.Length <= 0)
{
Info = "Error:请将卡放到刷卡区;";
return ;
return;
}
var per = Global.userManager.userInfos.FirstOrDefault(p => p.CardId == CardNum);
if (per != null)
@@ -54,7 +55,7 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel
return;
}

var name = Global.userManager.userInfos.FirstOrDefault(p =>p.UserName == UserName);
var name = Global.userManager.userInfos.FirstOrDefault(p => p.UserName == UserName);
if (name != null)
{
Info = "Error:用户名已存在!;";
@@ -80,33 +81,41 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel
}
else
Info = $"Info:ID {NFCHelper.GetInstance.GetReadResult.CardNum} 已存在;";
}
});

UserCancelCommand = new RelayCommand(() =>
{
var res = Global.userManager.userInfos.FirstOrDefault(p=>p.CardId == CardNum);
if(res != null)
if (CardNum != null && CardNum != string.Empty)
{
Global.userManager.userInfos.Remove(res);
Config.GetInstance.SaveUser();
Info = $"Info:ID {CardNum} 注销成功;";
MessageLog.GetInstance.ShowRunLog($"ID {CardNum} 用户注销成功");
Thread.Sleep(1000);
ActionManage.GetInstance.Send("Exit");
var res = Global.userManager.userInfos.FirstOrDefault(p => p.CardId == CardNum);

if (res != null)
{
Global.userManager.userInfos.Remove(res);
Config.GetInstance.SaveUser();
Info = $"Info:ID {CardNum} 注销成功;";
MessageLog.GetInstance.ShowRunLog($"ID {CardNum} 用户注销成功");
Thread.Sleep(1000);
ActionManage.GetInstance.Send("Exit");
}
else
{
Info = "Info:当前卡在系统中不存在;";
return;
}
}
else
{
Info = "Info:当前卡在系统中不存在;";
return;
Info = "Error:请将卡放到刷卡区;";
}
});

NfcServer.GetInstance.Update = new Action(() =>
{
CardNum = NFCHelper.GetInstance.GetReadResult.CardNum;
});
}

@@ -133,7 +142,7 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel
public string Info { get { return _mInfo; } set { _mInfo = value; OnPropertyChanged(); } }
private string _mInfo;

public string UserName { get { return _userName; } set { _userName = value; OnPropertyChanged(); } }
public string UserName { get { return _userName; } set { _userName = value; OnPropertyChanged(); } }
private string _userName = string.Empty;

public string CurrentPassword { get { return _currentPassword; } set { _currentPassword = value; OnPropertyChanged(); } }


+ 23
- 17
BPASmartClient.MorkF/Control_MorkF.cs Просмотреть файл

@@ -107,6 +107,7 @@ namespace BPASmartClient.MorkF
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T9, PotActions = new List<StirFryPotAction>() { StirFryPotAction.中火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 30 });
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T10, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T11, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.灶取锅 } });
morkF.listStirBom.Add(stirFryBom);
}
/// <summary>
/// 盐煎肉流程
@@ -319,14 +320,23 @@ namespace BPASmartClient.MorkF
/// </summary>
private void InitialData()
{
//单个订单
string subId = Guid.NewGuid().ToString();
morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = new List<int>() { 1 } });//A料
morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = new List<int>() { 2 } });//B料
morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = new List<int>() { 3 } });//C料
morkF.TakePlateQueue.Enqueue(new OrderLocInfo() { SuborderId = subId });
resultorder.AddRange(new int[] { 1, 2, 3 });
morkF.listStirBom.Add(stirFryBom);
//单个订单
//string subId = Guid.NewGuid().ToString();
//morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = new List<int>() { 1 } });//A料
//morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = new List<int>() { 2 } });//B料
//morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = new List<int>() { 3 } });//C料
//morkF.TakePlateQueue.Enqueue(new OrderLocInfo() { SuborderId = subId });
//resultorder.AddRange(new int[] { 1, 2, 3 });

for (int i = 0; i < morkF.listStirBom.Count; i++)
{
morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+i, MaterialLoc = new List<int>() { 1 } });//A料
morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+i, MaterialLoc = new List<int>() { 2 } });//B料
morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+i, MaterialLoc = new List<int>() { 3 } });//C料
morkF.TakePlateQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+i });
//resultorder.AddRange(new int[] { 1, 2, 3 });
}

//多个订单
//string subId = Guid.NewGuid().ToString();
@@ -340,8 +350,7 @@ namespace BPASmartClient.MorkF
//morkF.TakePlateQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+1 });
//resultorder.AddRange(new int[] { 1, 2, 3 });
//resultorder.AddRange(new int[] { 1, 2, 3 });
//morkF.listStirBom.Add(stirFryBom);
//morkF.listStirBom.Add(stirFryBom);
}
#endregion

@@ -707,6 +716,7 @@ namespace BPASmartClient.MorkF
{
if (morkF.MainHasTakeMaterial)
{

}
else
{
@@ -913,15 +923,11 @@ namespace BPASmartClient.MorkF
//模拟订单
if (morkF.TakeMaterialQueue.Count > 0 && !morkF.TurnTableLock && General_Config.SimOrderAllow)
{

if (resultorder != null)
if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo info))
{

TurnMaterialStore(resultorder[0]);
DeviceProcessLogShow($"转台转到【{resultorder[0]}】位置");
resultorder.RemoveAt(0);
morkF.TurnTableLock = true; //取料完成后置false

TurnMaterialStore(info.MaterialLoc[0]);
DeviceProcessLogShow($"转台转到【{info.MaterialLoc[0]}】位置");
morkF.TurnTableLock = true;
}
else
{


+ 1
- 1
BPASmartClient.MorkF/View/DebugView.xaml Просмотреть файл

@@ -35,7 +35,7 @@
<Button Content="料仓5" Command="{Binding MaterialFive}" Margin="10,0,10,0"></Button>
<Button Content="供盘" Command="{Binding OutPlate}" Margin="10,0,10,0"></Button>
<Button Content="清洗模组1启动" Command="{Binding StartQXOne}" Margin="10,0,10,0"></Button>
<Button Content="清洗模组2启动" Command="{Binding StartQXTwo}" Margin="10,10,10,0" Cursor="Hand"></Button>
<Button Content="清洗模组2启动" Command="{Binding StartQXTwo}" Margin="10,0,10,0" Cursor="Hand"></Button>
<CheckBox Name="checkValue" Content="运行模拟订单程序" Margin="10,10,10,0" IsChecked="{Binding SimOrderEnable}"></CheckBox>
</WrapPanel>
</GroupBox>


+ 30
- 6
FryPot_DosingSystem/App.xaml.cs Просмотреть файл

@@ -144,23 +144,47 @@ namespace FryPot_DosingSystem
subMenumodels = InfoLog,
});
#endregion

#region 硬件设备监控
ObservableCollection<SubMenumodel> DeviceMonitor = new ObservableCollection<SubMenumodel>();
DeviceMonitor.Add(new SubMenumodel()
#region 参数设置
ObservableCollection<SubMenumodel> ParamSet = new ObservableCollection<SubMenumodel>();
ParamSet.Add(new SubMenumodel()
{
SubMenuName = "PLC通讯设置",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 },
AssemblyName = "FryPot_DosingSystem",
ToggleWindowPath = "View.DeviceListVIew"
});
DeviceMonitor.Add(new SubMenumodel()
ParamSet.Add(new SubMenumodel()
{
SubMenuName = "PLC变量配置",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 },
AssemblyName = "BPASmartClient.CustomResource",
ToggleWindowPath = "Pages.View.VariableConfigView"
});
MenuManage.GetInstance.menuModels.Add(new MenuModel()
{
MainMenuIcon = "&#xe603;",
MainMenuName = "参数设置",
Alias = "Parameters Set",
MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员, Permission.观察员 },
subMenumodels = ParamSet,
});
#endregion
#region 硬件设备监控
ObservableCollection<SubMenumodel> DeviceMonitor = new ObservableCollection<SubMenumodel>();
//DeviceMonitor.Add(new SubMenumodel()
//{
// SubMenuName = "PLC通讯设置",
// SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 },
// AssemblyName = "FryPot_DosingSystem",
// ToggleWindowPath = "View.DeviceListVIew"
//});
//DeviceMonitor.Add(new SubMenumodel()
//{
// SubMenuName = "PLC变量配置",
// SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 },
// AssemblyName = "BPASmartClient.CustomResource",
// ToggleWindowPath = "Pages.View.VariableConfigView"
//});

DeviceMonitor.Add(new SubMenumodel()
{
@@ -216,7 +240,7 @@ namespace FryPot_DosingSystem
});
UserManager.Add(new SubMenumodel()
{
SubMenuName = "账号管理",
SubMenuName = "用户管理",
SubMenuPermission = new Permission[] { Permission.管理员 },
AssemblyName = "BPASmartClient.CustomResource",
ToggleWindowPath = "Pages.View.UserManageView"


+ 3
- 0
FryPot_DosingSystem/ViewModel/DebugViewModel.cs Просмотреть файл

@@ -8,6 +8,7 @@ using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace FryPot_DosingSystem.ViewModel
{
@@ -80,6 +81,8 @@ namespace FryPot_DosingSystem.ViewModel
public RelayCommand LineTwoEmptyRollerCleanTaskRestart { get; set; }

public RelayCommand LineThreeEmptyRollerCleanTaskRestart { get; set; }

public DebugViewModel()
{
AgvDebug = new RelayCommand(new Action(() =>


+ 7
- 5
TestDemo/Form1.cs Просмотреть файл

@@ -16,16 +16,18 @@ namespace TestDemo
private void button1_Click(object sender, EventArgs e)
{
AGVToUpSystem aGVToUpSystem = new AGVToUpSystem();
string value = JsonConvert.SerializeObject(aGVToUpSystem);
string url = $"http://192.168.1.40:8089/apicallback/quicktron/robotjob/report?sign={value}";
//string value = JsonConvert.SerializeObject(aGVToUpSystem);
//string url = $"http://192.168.1.40:8089/apicallback/quicktron/robotjob/report?sign={value}";
string url = "http://192.168.1.40:8089/apicallback/quicktron/robotjob/report";
var res = APIHelper.GetInstance.HttpRequest(url, "", aGVToUpSystem, RequestType.POST);
}

private void button2_Click(object sender, EventArgs e)
{
Upstreamrequest aGVToUpSystem = new Upstreamrequest();
string value = JsonConvert.SerializeObject(aGVToUpSystem);
string url = $"http://192.168.1.40:8089/apicallback/quicktron/robotjob/upstreamrequest?sign={value}";
Upstreamrequest aGVToUpSystem = new Upstreamrequest() { agvCode="123" };
// string value = JsonConvert.SerializeObject(aGVToUpSystem);
// string url = $"http://192.168.1.40:8089/apicallback/quicktron/robotjob/upstreamrequest?sign={value}";
string url = $"http://192.168.1.40:8089/apicallback/quicktron/robotjob/upstreamrequest";
var res = APIHelper.GetInstance.HttpRequest(url, "", aGVToUpSystem, RequestType.POST);

}


Загрузка…
Отмена
Сохранить