更新CAN的配置和CAN和实时数据的连接
This commit is contained in:
@@ -95,9 +95,9 @@ namespace CapMachine.Wpf
|
|||||||
containerRegistry.RegisterSingleton<AlarmService>();
|
containerRegistry.RegisterSingleton<AlarmService>();
|
||||||
////注册设备服务
|
////注册设备服务
|
||||||
//containerRegistry.RegisterSingleton<MachineDataService>();
|
//containerRegistry.RegisterSingleton<MachineDataService>();
|
||||||
|
containerRegistry.RegisterSingleton<CanDriveService>();
|
||||||
containerRegistry.RegisterSingleton<MachineRtDataService>();
|
containerRegistry.RegisterSingleton<MachineRtDataService>();
|
||||||
containerRegistry.RegisterSingleton<DataRecordService>();
|
containerRegistry.RegisterSingleton<DataRecordService>();
|
||||||
containerRegistry.RegisterSingleton<CanDriveService>();
|
|
||||||
containerRegistry.RegisterSingleton<HighSpeedDataService>();
|
containerRegistry.RegisterSingleton<HighSpeedDataService>();
|
||||||
containerRegistry.RegisterSingleton<PPCService>();
|
containerRegistry.RegisterSingleton<PPCService>();
|
||||||
containerRegistry.RegisterSingleton<ComActionService>();
|
containerRegistry.RegisterSingleton<ComActionService>();
|
||||||
|
|||||||
@@ -372,6 +372,7 @@ namespace CapMachine.Wpf.CanDrive
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 发送CAN数据
|
/// 发送CAN数据
|
||||||
|
/// 发送一次
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void SendCanMsg(List<CanCmdData> CmdData)
|
public void SendCanMsg(List<CanCmdData> CmdData)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -78,28 +78,96 @@ namespace CapMachine.Wpf.Services
|
|||||||
|
|
||||||
#region 程序驱动CAN
|
#region 程序驱动CAN
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 转速 指令数据 实例
|
||||||
|
/// </summary>
|
||||||
|
private CanCmdData SpeedCanCmdData { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 功率限制 指令数据 实例
|
||||||
|
/// </summary>
|
||||||
|
private CanCmdData PwLimitCanCmdData { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 使能 指令数据 实例
|
||||||
|
/// </summary>
|
||||||
|
private CanCmdData EnableCanCmdData { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 要发送的CAN指令数据
|
/// 要发送的CAN指令数据
|
||||||
/// 在程序配置好后就确定要发送哪些数据
|
/// 在程序配置好后就确定要发送哪些数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<CanCmdData> CmdData { get; set; } = new List<CanCmdData>();
|
public List<CanCmdData> CmdData { get; set; } = new List<CanCmdData>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 增加发送的指令数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="canCmdData"></param>
|
||||||
|
public void AddCmdData(CanCmdData SendCanCmdData)
|
||||||
|
{
|
||||||
|
//提取常用的实例数据
|
||||||
|
switch (SendCanCmdData.ConfigName)
|
||||||
|
{
|
||||||
|
case "转速":
|
||||||
|
SpeedCanCmdData = SendCanCmdData;
|
||||||
|
break;
|
||||||
|
case "功率限制":
|
||||||
|
PwLimitCanCmdData = SendCanCmdData;
|
||||||
|
break;
|
||||||
|
case "使能":
|
||||||
|
EnableCanCmdData = SendCanCmdData;
|
||||||
|
break;
|
||||||
|
case "Anti_Sleep":
|
||||||
|
//SpeedCanCmdData = SendCanCmdData;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//添加到发送数据集合
|
||||||
|
CmdData.Add(SendCanCmdData);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新速度信息
|
||||||
|
/// 默认是启动
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="canCmdData"></param>
|
||||||
|
public void UpdateSpeedCmdData(double SpeedData)
|
||||||
|
{
|
||||||
|
if (SpeedCanCmdData != null)
|
||||||
|
{
|
||||||
|
SpeedCanCmdData.SignalCmdValue = SpeedData;
|
||||||
|
}
|
||||||
|
if (EnableCanCmdData!=null)
|
||||||
|
{
|
||||||
|
EnableCanCmdData.SignalCmdValue = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 发送消息给CAN 驱动
|
/// 发送消息给CAN 驱动
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void SendMsgToCanDrive()
|
public void SendMsgToCanDrive(double SpeedData)
|
||||||
{
|
{
|
||||||
if (ToomossCanDrive.OpenState)
|
if (ToomossCanDrive.OpenState)
|
||||||
{
|
{
|
||||||
if (CmdData.Count > 0)
|
if (CmdData.Count > 0)
|
||||||
{
|
{
|
||||||
|
//更新速度信息
|
||||||
|
UpdateSpeedCmdData(SpeedData);
|
||||||
|
|
||||||
ToomossCanDrive.SendCanMsg(CmdData);
|
ToomossCanDrive.SendCanMsg(CmdData);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
System.Windows.MessageBox.Show("未发现配置的数据内容", "提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Hand);
|
System.Windows.MessageBox.Show("未发现配置的数据内容", "提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Hand);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
System.Windows.MessageBox.Show("未打开CAN通信,无法发送数据", "提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Hand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ namespace CapMachine.Wpf.Services
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private IEventAggregator _EventAggregator { get; set; }
|
private IEventAggregator _EventAggregator { get; set; }
|
||||||
public AlarmService AlarmService { get; }
|
public AlarmService AlarmService { get; }
|
||||||
|
public CanDriveService CanDriveService { get; }
|
||||||
|
public SysRunService SysRunService { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// PLCScanTask扫描Task
|
/// PLCScanTask扫描Task
|
||||||
@@ -105,7 +107,7 @@ namespace CapMachine.Wpf.Services
|
|||||||
/// 实例化函数
|
/// 实例化函数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="eventAggregator"></param>
|
/// <param name="eventAggregator"></param>
|
||||||
public MachineRtDataService(IEventAggregator eventAggregator, AlarmService alarmService)//, AlarmService alarmService
|
public MachineRtDataService(IEventAggregator eventAggregator, AlarmService alarmService, CanDriveService canDriveService, SysRunService sysRunService)//, AlarmService alarmService
|
||||||
{
|
{
|
||||||
//ConcurrentDictionary<DateTime, RecordInfo> keyValuePairs = new ConcurrentDictionary<DateTime, RecordInfo>();
|
//ConcurrentDictionary<DateTime, RecordInfo> keyValuePairs = new ConcurrentDictionary<DateTime, RecordInfo>();
|
||||||
|
|
||||||
@@ -119,6 +121,8 @@ namespace CapMachine.Wpf.Services
|
|||||||
//事件服务
|
//事件服务
|
||||||
_EventAggregator = eventAggregator;
|
_EventAggregator = eventAggregator;
|
||||||
AlarmService = alarmService;
|
AlarmService = alarmService;
|
||||||
|
CanDriveService = canDriveService;
|
||||||
|
SysRunService = sysRunService;
|
||||||
|
|
||||||
//秒触发一次
|
//秒触发一次
|
||||||
CycleTimer = new System.Timers.Timer(500);
|
CycleTimer = new System.Timers.Timer(500);
|
||||||
@@ -1115,8 +1119,9 @@ namespace CapMachine.Wpf.Services
|
|||||||
if (OperateResultShort.IsSuccess)
|
if (OperateResultShort.IsSuccess)
|
||||||
{
|
{
|
||||||
TagManger.GetTagInfoValueByName<short>(itemTag.Value.Name)!.Value = SiemensDrive.ReadInt16(itemTag.Value.PVAddress).Content;
|
TagManger.GetTagInfoValueByName<short>(itemTag.Value.Name)!.Value = SiemensDrive.ReadInt16(itemTag.Value.PVAddress).Content;
|
||||||
TagManger.GetTagByName<short>(itemTag.Value.Name).EngPvValue = TagManger.GetTagInfoValueByName<short>(itemTag.Value.Name)!.Value * 1.0 / TagManger.GetTagByName<short>(itemTag.Value.Name)!.Precision;
|
TagManger.GetTagByName<short>(itemTag.Value.Name)!.EngPvValue = TagManger.GetTagInfoValueByName<short>(itemTag.Value.Name)!.Value * 1.0 / TagManger.GetTagByName<short>(itemTag.Value.Name)!.Precision;
|
||||||
LinkState = true;
|
LinkState = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1130,8 +1135,15 @@ namespace CapMachine.Wpf.Services
|
|||||||
if (OperateResultSVShort.IsSuccess)
|
if (OperateResultSVShort.IsSuccess)
|
||||||
{
|
{
|
||||||
//TagManger.GetTagInfoValueByName<short>(itemTag.Value.Name)!.Value = OperateResultSVShort.Content;
|
//TagManger.GetTagInfoValueByName<short>(itemTag.Value.Name)!.Value = OperateResultSVShort.Content;
|
||||||
TagManger.GetTagByName<short>(itemTag.Value.Name).EngSvValue = OperateResultSVShort.Content * 1.0 / TagManger.GetTagByName<short>(itemTag.Value.Name)!.Precision;
|
TagManger.GetTagByName<short>(itemTag.Value.Name)!.EngSvValue = OperateResultSVShort.Content * 1.0 / TagManger.GetTagByName<short>(itemTag.Value.Name)!.Precision;
|
||||||
LinkState = true;
|
LinkState = true;
|
||||||
|
|
||||||
|
//在运行时,更新速度的SV的值
|
||||||
|
if (itemTag.Value.Name == "转速[rpm]" && SysRunService.MachineRunState1.RunStateMsg == "运行")
|
||||||
|
{
|
||||||
|
//更新SV的速度值
|
||||||
|
CanDriveService.UpdateSpeedCmdData(TagManger.GetTagByName<short>(itemTag.Value.Name)!.EngSvValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1145,7 +1157,7 @@ namespace CapMachine.Wpf.Services
|
|||||||
if (OperateResultMVShort.IsSuccess)
|
if (OperateResultMVShort.IsSuccess)
|
||||||
{
|
{
|
||||||
//TagManger.GetTagInfoValueByName<short>(itemTag.Value.Name)!.Value = OperateResultMVShort.Content;
|
//TagManger.GetTagInfoValueByName<short>(itemTag.Value.Name)!.Value = OperateResultMVShort.Content;
|
||||||
TagManger.GetTagByName<short>(itemTag.Value.Name).EngMvValue = OperateResultMVShort.Content*1.0/10;
|
TagManger.GetTagByName<short>(itemTag.Value.Name)!.EngMvValue = OperateResultMVShort.Content * 1.0 / 10;
|
||||||
LinkState = true;
|
LinkState = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1155,8 +1167,8 @@ namespace CapMachine.Wpf.Services
|
|||||||
}
|
}
|
||||||
|
|
||||||
//手自动切换按钮条件
|
//手自动切换按钮条件
|
||||||
AutoHandSwtichConditionState.AlarmStateResult= SiemensDrive.ReadBool(AutoHandSwtichConditionState.AlarmAddress);
|
AutoHandSwtichConditionState.AlarmStateResult = SiemensDrive.ReadBool(AutoHandSwtichConditionState.AlarmAddress);
|
||||||
AutoHandSwtichConditionState.HandStateResult= SiemensDrive.ReadBool(AutoHandSwtichConditionState.HandStateAddress);
|
AutoHandSwtichConditionState.HandStateResult = SiemensDrive.ReadBool(AutoHandSwtichConditionState.HandStateAddress);
|
||||||
AutoHandSwtichConditionState.SumResult();
|
AutoHandSwtichConditionState.SumResult();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -120,13 +120,20 @@ namespace CapMachine.Wpf.ViewModels
|
|||||||
CanDriveService.CmdData.Clear();
|
CanDriveService.CmdData.Clear();
|
||||||
foreach (var item in WirteData)
|
foreach (var item in WirteData)
|
||||||
{
|
{
|
||||||
CanDriveService.CmdData.Add(new CanCmdData()
|
CanDriveService.AddCmdData(new CanCmdData()
|
||||||
{
|
{
|
||||||
ConfigName = item.Name,
|
ConfigName = item.Name,
|
||||||
MsgName = item.MsgFrameName,
|
MsgName = item.MsgFrameName,
|
||||||
SignalName = item.SignalName,
|
SignalName = item.SignalName,
|
||||||
SignalCmdValue = double.TryParse(item.DefautValue, out double result) == true ? result : 0,
|
SignalCmdValue = double.TryParse(item.DefautValue, out double result) == true ? result : 0,
|
||||||
});
|
});
|
||||||
|
//CanDriveService.CmdData.Add(new CanCmdData()
|
||||||
|
//{
|
||||||
|
// ConfigName = item.Name,
|
||||||
|
// MsgName = item.MsgFrameName,
|
||||||
|
// SignalName = item.SignalName,
|
||||||
|
// SignalCmdValue = double.TryParse(item.DefautValue, out double result) == true ? result : 0,
|
||||||
|
//});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -411,13 +418,21 @@ namespace CapMachine.Wpf.ViewModels
|
|||||||
CanDriveService.CmdData.Clear();
|
CanDriveService.CmdData.Clear();
|
||||||
foreach (var item in WirteData)
|
foreach (var item in WirteData)
|
||||||
{
|
{
|
||||||
CanDriveService.CmdData.Add(new CanCmdData()
|
CanDriveService.AddCmdData(new CanCmdData()
|
||||||
{
|
{
|
||||||
ConfigName = item.Name,
|
ConfigName = item.Name,
|
||||||
MsgName = item.MsgFrameName,
|
MsgName = item.MsgFrameName,
|
||||||
SignalName = item.SignalName,
|
SignalName = item.SignalName,
|
||||||
SignalCmdValue = double.TryParse(item.DefautValue, out double result) == true ? result : 0,
|
SignalCmdValue = double.TryParse(item.DefautValue, out double result) == true ? result : 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//CanDriveService.CmdData.Add(new CanCmdData()
|
||||||
|
//{
|
||||||
|
// ConfigName = item.Name,
|
||||||
|
// MsgName = item.MsgFrameName,
|
||||||
|
// SignalName = item.SignalName,
|
||||||
|
// SignalCmdValue = double.TryParse(item.DefautValue, out double result) == true ? result : 0,
|
||||||
|
//});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -829,7 +844,7 @@ namespace CapMachine.Wpf.ViewModels
|
|||||||
case "HandSend"://手动发送
|
case "HandSend"://手动发送
|
||||||
|
|
||||||
//手动发送数据
|
//手动发送数据
|
||||||
CanDriveService.SendMsgToCanDrive();
|
CanDriveService.SendMsgToCanDrive(HandSpeed);
|
||||||
|
|
||||||
//CanDriveService.ToomossCanDrive.SendCanMsg(new List<CanCmdData>()
|
//CanDriveService.ToomossCanDrive.SendCanMsg(new List<CanCmdData>()
|
||||||
//{
|
//{
|
||||||
@@ -854,6 +869,18 @@ namespace CapMachine.Wpf.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private double _HandSpeed;
|
||||||
|
/// <summary>
|
||||||
|
/// 手动转速数据
|
||||||
|
/// </summary>
|
||||||
|
public double HandSpeed
|
||||||
|
{
|
||||||
|
get { return _HandSpeed; }
|
||||||
|
set { _HandSpeed = value; RaisePropertyChanged(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -420,6 +420,33 @@
|
|||||||
<TextBox Style="{StaticResource TextBoxStyle}" Text="{Binding SelectedCANConfigExdDto.Cycle}" />
|
<TextBox Style="{StaticResource TextBoxStyle}" Text="{Binding SelectedCANConfigExdDto.Cycle}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
|
<StackPanel
|
||||||
|
Grid.Row="2"
|
||||||
|
Grid.Column="2"
|
||||||
|
Orientation="Horizontal">
|
||||||
|
<TextBlock
|
||||||
|
Margin="10,0,5,0"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
FontFamily="/Assets/Fonts/#iconfont"
|
||||||
|
FontSize="18"
|
||||||
|
Text="" />
|
||||||
|
<TextBlock
|
||||||
|
Width="90"
|
||||||
|
Style="{StaticResource TextBlockStyle}"
|
||||||
|
Text="转速(rpm)" />
|
||||||
|
<TextBox
|
||||||
|
Margin="5,0"
|
||||||
|
Style="{StaticResource TextBoxStyle}"
|
||||||
|
Text="{Binding HandSpeed}" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
Margin="5,0"
|
||||||
|
Command="{Binding CanOpCmd}"
|
||||||
|
CommandParameter="HandSend"
|
||||||
|
Content="手动发送"
|
||||||
|
Foreground="White" />
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
<StackPanel
|
<StackPanel
|
||||||
Grid.Row="2"
|
Grid.Row="2"
|
||||||
Grid.ColumnSpan="3"
|
Grid.ColumnSpan="3"
|
||||||
@@ -496,11 +523,7 @@
|
|||||||
</Button.Style>
|
</Button.Style>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Button
|
|
||||||
Margin="5,0"
|
|
||||||
Command="{Binding CanOpCmd}"
|
|
||||||
CommandParameter="HandSend"
|
|
||||||
Content="手动发送" />
|
|
||||||
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
|
|||||||
@@ -1059,7 +1059,7 @@
|
|||||||
Canvas.Top="4"
|
Canvas.Top="4"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
Content="工艺图流程图"
|
Content="工艺流程图"
|
||||||
FontSize="30"
|
FontSize="30"
|
||||||
FontWeight="Bold"
|
FontWeight="Bold"
|
||||||
Foreground="Gray" />
|
Foreground="Gray" />
|
||||||
|
|||||||
Reference in New Issue
Block a user