|
|
@@ -394,7 +394,7 @@ namespace TeamAAS_VP.ViewModels.Home
|
|
|
SelectedPoint.X_Position = curpos.X;
|
|
|
SelectedPoint.Y_Position = curpos.Y;
|
|
|
SelectedPoint.Z_Position_Start = curpos.Z;
|
|
|
- //SelectedPoint.Z_Position_Stop = curpos.Z - (float)this.Z_Distance;
|
|
|
+
|
|
|
SelectedPoint.Z_Position_Stop = 0;
|
|
|
|
|
|
AllProductParameter.TorqueValue = this.TorqueValue;
|
|
|
@@ -417,8 +417,14 @@ namespace TeamAAS_VP.ViewModels.Home
|
|
|
var res = FileHelper.ReadJsonFile<TorqueProduceModel>(FilePath.TorqueCheckPath);
|
|
|
|
|
|
res.TorqueValue = this.TorqueValue;
|
|
|
-
|
|
|
- FileHelper.WriteJsonFile(res, FilePath.TorqueCheckPath);
|
|
|
+ try
|
|
|
+ {
|
|
|
+ FileHelper.WriteJsonFile(res, FilePath.TorqueCheckPath);
|
|
|
+ }
|
|
|
+ catch (Exception)
|
|
|
+ {
|
|
|
+ MessageBox.Show("修改失败");
|
|
|
+ }
|
|
|
_eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 0.4 });
|
|
|
}
|
|
|
|
|
|
@@ -441,8 +447,12 @@ namespace TeamAAS_VP.ViewModels.Home
|
|
|
{
|
|
|
if (await MoveRobot())
|
|
|
{
|
|
|
-
|
|
|
- }
|
|
|
+ _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 0.4 });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.失败, Duration = 0.4 });
|
|
|
+ }
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
@@ -456,11 +466,12 @@ namespace TeamAAS_VP.ViewModels.Home
|
|
|
/// <returns></returns>
|
|
|
public async Task<bool> MoveRobot()
|
|
|
{
|
|
|
- var Plc_Point = FileHelper.ReadJsonFile<TorqueProduceModel>(FilePath.TorqueCheckPath);
|
|
|
+ TorqueProduceModel Plc_Point = new TorqueProduceModel();
|
|
|
PlcAddressConfig addressConfig = _configService.GetPlcAddresses();
|
|
|
OpcUaClientPLC plc = _plcService.GetPlcByNumber(addressConfig.PlcNo) as OpcUaClientPLC;
|
|
|
try
|
|
|
{
|
|
|
+ Plc_Point = FileHelper.ReadJsonFile<TorqueProduceModel>(FilePath.TorqueCheckPath);
|
|
|
if (Plc_Point == null || addressConfig == null || plc == null)
|
|
|
{
|
|
|
return false;
|
|
|
@@ -496,7 +507,7 @@ namespace TeamAAS_VP.ViewModels.Home
|
|
|
}
|
|
|
MessageBox.Show("执行回安全点失败"); return false;
|
|
|
}
|
|
|
- MessageBox.Show("点检失败");return false;
|
|
|
+ MessageBox.Show("点检失败"); return false;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
@@ -513,7 +524,7 @@ namespace TeamAAS_VP.ViewModels.Home
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- Thread.Sleep(100);
|
|
|
+ await Task.Delay(100);
|
|
|
TValue = management.SignalValue;
|
|
|
double tvalue = double.Parse(TValue.Split(' ')[0]);
|
|
|
double pvalue = Value;
|
|
|
@@ -521,7 +532,7 @@ namespace TeamAAS_VP.ViewModels.Home
|
|
|
SubValue = $"{Math.Round(Math.Abs(tvalue - pvalue), 3)} kgf.cm";
|
|
|
double sub = Math.Abs(tvalue - pvalue);
|
|
|
|
|
|
- var res = FileHelper.ReadJsonFile<TorqueTest>(FilePath.TorqueCheckPath);
|
|
|
+ var res = FileHelper.ReadJsonFile<TorqueProduceModel>(FilePath.TorqueCheckPath);
|
|
|
if (res != null)
|
|
|
{
|
|
|
if (sub <= res.TorqueValue)
|
|
|
@@ -548,6 +559,8 @@ namespace TeamAAS_VP.ViewModels.Home
|
|
|
Result = "NG";
|
|
|
}
|
|
|
}
|
|
|
+ await _torqueService.Save_Torque_Log($"{DateTime.Now},{TValue},{PValue},{Math.Round(sub, 4)},{TorqueValue},{Result}");
|
|
|
+ SendTaskMessage("点检扭矩成功", MessageLevel.Info);
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
@@ -555,19 +568,15 @@ namespace TeamAAS_VP.ViewModels.Home
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void Save_Torque_Parameter()
|
|
|
- {
|
|
|
- }
|
|
|
-
|
|
|
public async Task<bool> WatchAsync(OpcUaClientPLC plc, PlcAddressConfig addressConfig)
|
|
|
{
|
|
|
- Thread.Sleep(100);
|
|
|
object oking = null;
|
|
|
object nging = null;
|
|
|
int count = 0;
|
|
|
|
|
|
- while (count++ < 10)
|
|
|
+ while (count++ < 20)
|
|
|
{
|
|
|
+ await Task.Delay(100);
|
|
|
oking = plc.ReadNode(addressConfig.Screw_OK.Address);
|
|
|
nging = plc.ReadNode(addressConfig.Screw_NG.Address);
|
|
|
|
|
|
@@ -618,12 +627,8 @@ namespace TeamAAS_VP.ViewModels.Home
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- var res = FileHelper.ReadJsonFile<TorqueTest>(FilePath.TorqueCheckPath);
|
|
|
- if (res != null)
|
|
|
- {
|
|
|
- res.TorqueValue = TorqueValue;
|
|
|
- }
|
|
|
- else
|
|
|
+ var res = FileHelper.ReadJsonFile<TorqueProduceModel>(FilePath.TorqueCheckPath);
|
|
|
+ if (res == null)
|
|
|
{
|
|
|
MessageBox.Show("还未示教,请先示教");
|
|
|
}
|
|
|
@@ -632,7 +637,6 @@ namespace TeamAAS_VP.ViewModels.Home
|
|
|
{
|
|
|
MessageBox.Show("还未示教,请先示教");
|
|
|
}
|
|
|
-
|
|
|
if (Robot == null)
|
|
|
{
|
|
|
Robot = _robotService.GetRobotByNumber(1);
|
|
|
@@ -704,6 +708,14 @@ namespace TeamAAS_VP.ViewModels.Home
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
+ private void SendTaskMessage(string msg, MessageLevel level)
|
|
|
+ {
|
|
|
+ App.Current.Dispatcher.Invoke(() =>
|
|
|
+ {
|
|
|
+ _eventAggregator.GetEvent<TaskMessageNotification>().Publish(new Models.MessageStruct() { Message = msg, level = level });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
private void ExecuteSavePointsCommand()
|
|
|
{
|
|
|
AllProductParameter.TorqueValue = this.TorqueValue;
|