79 lines
2.4 KiB
C#
79 lines
2.4 KiB
C#
using CapMachine.Model.CANLIN;
|
|
using CapMachine.Wpf.CanDrive;
|
|
using ImTools;
|
|
using Prism.Ioc;
|
|
using Prism.Mvvm;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace CapMachine.Wpf.Services
|
|
{
|
|
/// <summary>
|
|
/// Can驱动服务
|
|
/// </summary>
|
|
public class CanDriveService : BindableBase
|
|
{
|
|
/// <summary>
|
|
/// 实例化函数
|
|
/// </summary>
|
|
public CanDriveService(HighSpeedDataService highSpeedDataService,IContainerProvider containerProvider)
|
|
{
|
|
ToomossCanDrive = new ToomossCan(containerProvider);
|
|
//高速数据服务
|
|
HighSpeedDataService = highSpeedDataService;
|
|
|
|
//ToomossCanDrive.StartCanDrive();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 图莫斯 CAN Drive
|
|
/// ToomossCanDrive
|
|
/// </summary>
|
|
public ToomossCan ToomossCanDrive { get; set; }
|
|
|
|
/// <summary>
|
|
/// Dbc消息集合
|
|
/// 包括读取的实时值和数据
|
|
/// </summary>
|
|
public ObservableCollection<CanDbcModel> ListCanDbcModel { get; set; } = new ObservableCollection<CanDbcModel>();
|
|
|
|
/// <summary>
|
|
/// 初始化CAN的配置信息
|
|
/// </summary>
|
|
public void InitCanConfig(CanLinConfigPro selectedCanLinConfigPro)
|
|
{
|
|
//赋值配置数据
|
|
SelectedCanLinConfigPro = selectedCanLinConfigPro;
|
|
//为DBC实时数据关联配置的名称
|
|
foreach (var item in SelectedCanLinConfigPro.CanLinConfigContents)
|
|
{
|
|
var FindData = ListCanDbcModel.FindFirst(a => a.SignalName == item.Content);
|
|
if (FindData != null)
|
|
{
|
|
FindData.Name = item.Name;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 开始DBC 配置文件 加载
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public ObservableCollection<CanDbcModel> StartDbc(string Path)
|
|
{
|
|
ListCanDbcModel = ToomossCanDrive.StartDbc(Path);
|
|
return ListCanDbcModel;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 当前选中的CanLinConfigPro 程序
|
|
/// </summary>
|
|
public CanLinConfigPro SelectedCanLinConfigPro { get; set; }
|
|
public HighSpeedDataService HighSpeedDataService { get; }
|
|
}
|
|
}
|