Commit 9fe41017 by liulongfei

1. Tally信号支持

parent 404f3805
File added
......@@ -28,5 +28,10 @@ namespace VIZ.H2V.Domain
/// 3D鼠标映射配置
/// </summary>
public static Navigation3DMappingDomainModel Navigation3DMapping { get; private set; } = new Navigation3DMappingDomainModel();
/// <summary>
/// 当前使用的GPIO模型
/// </summary>
public static GPIOModel GPIOModel { get; set; }
}
}
......@@ -21,4 +21,25 @@
</Setter.Value>
</Setter>
</Style>
<Style x:Key="Button_Tally" TargetType="Button">
<Setter Property="FocusVisualStyle" Value="{x:Null}"></Setter>
<Setter Property="Width" Value="50"></Setter>
<Setter Property="Height" Value="40"></Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="bd" BorderBrush="Transparent" BorderThickness="1" Background="Transparent">
<Image Width="18" Height="18" HorizontalAlignment="Center" VerticalAlignment="Center"
Source="/VIZ.H2V.Module.Resource;component/Icons/tally_24x24.png"></Image>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="bd" Property="Background" Value="#22ffffff"></Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
\ No newline at end of file
......@@ -212,5 +212,8 @@
<Resource Include="Icons\ai_close_24x24.png" />
<Resource Include="Icons\ai_refresh_24x24.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Icons\tally_24x24.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
......@@ -4,6 +4,9 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Common;
using VIZ.Framework.Core;
using VIZ.H2V.Domain;
namespace VIZ.H2V.Module
{
......@@ -36,7 +39,33 @@ namespace VIZ.H2V.Module
/// </summary>
public void Init()
{
if (ApplicationDomainEx.GPIOModel != null)
{
// 关闭现在的GPIO模型
ApplicationDomainEx.GPIOModel.Close();
ApplicationDomainEx.GPIOModel = null;
}
List<USBDeviceInfo> infos = GPIOManager.ScanDevice();
if (infos == null || infos.Count == 0)
return;
foreach (USBDeviceInfo info in infos)
{
GPIOModel model = new GPIOModel(info);
GPIOManager.Models.Add(model);
}
ApplicationDomainEx.GPIOModel = GPIOManager.Models.FirstOrDefault();
bool result = ApplicationDomainEx.GPIOModel.Open();
ApplicationDomainEx.ServiceManager.GetServiceList<INDIViewService>().ForEach(p =>
{
p.UpdateTallyConfig(ApplicationDomainEx.GPIOModel);
});
MessageBoxEx.ShowDialog($"Tally 初始化 {(result ? "成功" : "失败")}!");
}
}
}
......@@ -39,9 +39,11 @@
<Grid Background="#ff12202d">
<TextBlock Text="横转竖智能裁切系统" FontSize="12" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock>
<StackPanel Orientation="Horizontal" Grid.Column="2" HorizontalAlignment="Right" VerticalAlignment="Top">
<Button Command="{Binding Path=InitTallyCommand}" ToolTip="初始Tally"
Style="{StaticResource Button_Tally}" Height="30"></Button>
<Button Command="{Binding Path=InitNavigation3DCommand}" ToolTip="初始化摇杆"
Style="{StaticResource Button_Navigation3D}" Height="30"></Button>
<Rectangle Width="2" Fill="#EEFFFFFF" Height="18"></Rectangle>
<Rectangle Width="2" Fill="#EEFFFFFF" Height="18" Margin="20,0,20,0"></Rectangle>
<Button Command="{Binding Path=SettingCommand}" ToolTip="系统设置"
Style="{StaticResource Button_Setting}" Height="30"></Button>
<Button Command="{Binding Path=MinCommand}" ToolTip="最小化"
......
......@@ -19,7 +19,7 @@ namespace VIZ.H2V.Module
/// <summary>
/// NDI主视图模型
/// </summary>
public class NDIMainViewModel : ViewModelBase, INDIMainViewService, IHotkeySupport
public class NDIMainViewModel : ViewModelBase, INDIMainViewService, IHotkeySupport, IGpioSupport
{
/// <summary>
/// NDI主视图模型
......@@ -58,6 +58,7 @@ namespace VIZ.H2V.Module
this.CloseCommand = new VCommand(this.Close);
this.SettingCommand = new VCommand(this.Setting);
this.InitNavigation3DCommand = new VCommand(this.InitNavigation3D);
this.InitTallyCommand = new VCommand(this.InitTally);
}
/// <summary>
......@@ -82,6 +83,7 @@ namespace VIZ.H2V.Module
private void InitController()
{
this.hotkeyController = new HotkeyController(this);
this.gpioController = new GpioController(this);
}
/// <summary>
......@@ -113,6 +115,11 @@ namespace VIZ.H2V.Module
/// </summary>
private HotkeyController hotkeyController;
/// <summary>
/// GPIO控制器
/// </summary>
private GpioController gpioController;
// ======================================================================================
// === Property ===
// ======================================================================================
......@@ -247,6 +254,23 @@ namespace VIZ.H2V.Module
#endregion
#region InitTallyCommand -- 初始化Tally命令
/// <summary>
/// 初始化Tally命令
/// </summary>
public VCommand InitTallyCommand { get; set; }
/// <summary>
/// 初始化Tally
/// </summary>
private void InitTally()
{
this.gpioController.Init();
}
#endregion
// ======================================================================================
// === Privatee Function ===
// ======================================================================================
......
......@@ -71,6 +71,26 @@ namespace VIZ.H2V.Module
void LoadClipBoxSmooth(double minCutoff);
/// <summary>
/// 更新Tally配置
/// </summary>
/// <param name="signalModel">信号模型</param>
/// <param name="gpioModel">GPIO模型</param>
void UpdateTallyConfig(TallyCamSignalModel signalModel, GPIOModel gpioModel);
/// <summary>
/// 更新Tally配置
/// </summary>
/// <param name="tallyInfo">Tally信息</param>
/// <param name="gpioModel">GPIO模型</param>
void UpdateTallyConfig(TallyInfo tallyInfo, GPIOModel gpioModel);
/// <summary>
/// 更新Tally配置
/// </summary>
/// <param name="gpioModel">GPIO模型</param>
void UpdateTallyConfig(GPIOModel gpioModel);
/// <summary>
/// 保存居中模式裁切框至算法配置
/// </summary>
void SaveCenterClipBoxToAlgorithmConfig();
......
......@@ -23,6 +23,8 @@
<ResourceDictionary Source="/VIZ.H2V.Module.Resource;component/Style/CheckBox/CheckBox_NdiView.xaml"></ResourceDictionary>
<ResourceDictionary Source="/VIZ.H2V.Module.Resource;component/Style/RadioButton/RadioButton_NdiView.xaml"></ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
<fcore:Bool2VisibilityConverter x:Key="Bool2VisibilityConverter"></fcore:Bool2VisibilityConverter>
<fcore:Color2SolidColorBrushConverter x:Key="Color2SolidColorBrushConverter"></fcore:Color2SolidColorBrushConverter>
<fcore:Bool2BoolConverter x:Key="Bool2BoolConverter"></fcore:Bool2BoolConverter>
<fcore:StringAppendConverter x:Key="StringAppendConverter"></fcore:StringAppendConverter>
<resource:NDIViewStatus2BoolConverter x:Key="NDIViewStatus2IsEnabledConverter" TrueListString="Detect,CropRoi"></resource:NDIViewStatus2BoolConverter>
......@@ -195,7 +197,7 @@
</RadioButton>-->
<!-- 近景机位 & 16米机位 & 战术机位 ===== 边线检测选择面板 -->
<Border Grid.Row="1" Background="{x:Null}"
<!--<Border Grid.Row="1" Background="{x:Null}"
Visibility="{Binding Path=AlgorithmConfig.IsShowBorder,Mode=OneWay,Converter={StaticResource Bool2VisibilityConverter}}">
<RadioButton Style="{StaticResource RadioButton_NdiView_None}"
Height="{Binding ElementName=uc,Path=DataContext.StrategyType,Converter={StaticResource AlgorithmStrategyType2FootballFieldHeightConverter}}"
......@@ -214,7 +216,7 @@
Orientation="{Binding ElementName=uc,Path=DataContext.StrategyType,Converter={StaticResource AlgorithmStrategyType2FootballFieldOrientationConverter}}">
</common:FootballFieldPanel>
</RadioButton>
</Border>
</Border>-->
<!-- 居中模式 按钮组-->
<Grid Grid.Row="1" Background="{x:Null}">
......@@ -239,9 +241,14 @@
<!-- Tally -->
<StackPanel Grid.Row="0" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,0,5" Orientation="Horizontal">
<Ellipse Width="24" Height="24" Fill="#DDFF0000" Margin="0,0,0,0"></Ellipse>
<!-- 信号2 -->
<Ellipse Width="24" Height="24" Margin="0,0,15,0"
Visibility="{Binding Path=TallyPartViewModel.Tally2.PinValue,Converter={StaticResource Bool2VisibilityConverter}}"
Fill="{Binding Path=TallyPartViewModel.Color2,Converter={StaticResource Color2SolidColorBrushConverter}}"></Ellipse>
<!-- 信号1 -->
<Ellipse Width="24" Height="24" Margin="0,0,0,0"
Visibility="{Binding Path=TallyPartViewModel.Tally1.PinValue,Converter={StaticResource Bool2VisibilityConverter}}"
Fill="{Binding Path=TallyPartViewModel.Color1,Converter={StaticResource Color2SolidColorBrushConverter}}"></Ellipse>
</StackPanel>
<!-- 功能区 -->
......@@ -336,7 +343,7 @@
<!-- AI功能区 -->
<StackPanel Orientation="Vertical" VerticalAlignment="Bottom" Grid.Row="1">
<TextBlock Text="AI" Foreground="#AAFFFFFF" HorizontalAlignment="Center"></TextBlock>
<Rectangle Height="2" Fill="#AAFFFFFF" Margin="0,2,0,0"></Rectangle>
<Rectangle Height="2" Width="30" Fill="#AAFFFFFF" Margin="0,2,0,0"></Rectangle>
<Border Margin="0,10,0,0" ToolTip="重启算法" Background="Transparent">
<Button Width="32" Height="32"
Style="{StaticResource Button_Function}"
......
......@@ -90,6 +90,7 @@ namespace VIZ.H2V.Module
/// </summary>
private void Loaded_Property()
{
SystemConfig systemConfig = ApplicationDomainEx.LiteDbContext.SystemConfig.FindAll().FirstOrDefault();
AlgorithmStrategy strategy = ApplicationDomainEx.CsvContext.AlgorithmStrategys.FirstOrDefault(p => p.ID == (int)this.ViewConfig.StrategyType);
// 算法ID
......@@ -105,6 +106,9 @@ namespace VIZ.H2V.Module
// 居中模式下的裁切框位置
this.ClipBoxX_CenterMode = this.AlgorithmConfig.CenterClipBoxX;
// 初始化Tally
this.InitTally(systemConfig);
// 记录档期操作日志
this.WriteLogOperation(this.StrategyMode);
}
......@@ -130,7 +134,7 @@ namespace VIZ.H2V.Module
SideCheckPolygonPlugin sideCheckPolygonPlugin = new SideCheckPolygonPlugin(view.video);
// -----------------------------------------------------------------------------------------
// 新的边线检测算法不需要校准 <新算法暂未上线>
sideCheckPolygonPlugin.Click += SideCheckPolygonPlugin_Click;
//sideCheckPolygonPlugin.Click += SideCheckPolygonPlugin_Click;
// -----------------------------------------------------------------------------------------
view.video.AttachPlugin(sideCheckPolygonPlugin);
......@@ -241,6 +245,33 @@ namespace VIZ.H2V.Module
view.video.UpdateManualCorrection(info);
}
/// <summary>
/// 初始化Tally
/// </summary>
/// <param name="systemConfig">系统配置</param>
private void InitTally(SystemConfig systemConfig)
{
// 获取当前Tally信号模型
TallyInfo tallyInfo = null;
switch (this.ViewKey)
{
case NDIViewKeys.CAM_1:
tallyInfo = systemConfig.TallyInfo1;
break;
case NDIViewKeys.CAM_2:
tallyInfo = systemConfig.TallyInfo2;
break;
case NDIViewKeys.CAM_3:
tallyInfo = systemConfig.TallyInfo3;
break;
case NDIViewKeys.CAM_4:
tallyInfo = systemConfig.TallyInfo4;
break;
}
this.UpdateTallyConfig(tallyInfo, GPIOManager.Models.FirstOrDefault());
}
#endregion
#region SettingCommand -- 设置命令
......
......@@ -161,11 +161,11 @@ namespace VIZ.H2V.Module
// --------------------------------------------------------------------------------------
// 更新边线检测框
this.OnAlgorithmMessage__crop_roi__borderline(msg, renderInfo, view);
//this.OnAlgorithmMessage__crop_roi__borderline(msg, renderInfo, view);
// --------------------------------------------------------------------------------------
// 更新边线检测框(新算法)<新算法暂未上线>
//this.OnAlgorithmMessage__crop_roi__field_border(msg, renderInfo, view);
this.OnAlgorithmMessage__crop_roi__field_border(msg, renderInfo, view);
// 更新手动校准区域
this.OnAlgorithmMessage__crop_roi__correction_area(msg, renderInfo, view);
......
......@@ -563,6 +563,20 @@ namespace VIZ.H2V.Module
#endregion
#region TallyPartViewModel -- Tally部分视图模型
private NDIViewTallyPartViewModel tallyPartViewModel = new NDIViewTallyPartViewModel();
/// <summary>
/// Tally部分视图模型
/// </summary>
public NDIViewTallyPartViewModel TallyPartViewModel
{
get { return tallyPartViewModel; }
set { tallyPartViewModel = value; this.RaisePropertyChanged(nameof(TallyPartViewModel)); }
}
#endregion
#region DebugLog -- 调试日志
private string debugLog;
......
......@@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI;
using System.Windows.Media;
using log4net;
using SharpDX.Mathematics.Interop;
using VIZ.Framework.Common;
......@@ -385,6 +386,49 @@ namespace VIZ.H2V.Module
}
/// <summary>
/// 更新Tally配置
/// </summary>
/// <param name="signalModel">信号模型</param>
/// <param name="gpioModel">GPIO模型</param>
public void UpdateTallyConfig(TallyCamSignalModel signalModel, GPIOModel gpioModel)
{
this.TallyPartViewModel.Tally1.PinMask = signalModel.PinIndex1.PinMask;
this.tallyPartViewModel.Color1 = signalModel.Color1;
this.TallyPartViewModel.Tally1.GPIOModel = gpioModel;
this.tallyPartViewModel.Tally2.PinMask = signalModel.PinIndex2.PinMask;
this.tallyPartViewModel.Color2 = signalModel.Color2;
this.tallyPartViewModel.Tally2.GPIOModel = gpioModel;
}
/// <summary>
/// 更新Tally配置
/// </summary>
/// <param name="tallyInfo">Tally信息</param>
/// <param name="gpioModel">GPIO模型</param>
public void UpdateTallyConfig(TallyInfo tallyInfo, GPIOModel gpioModel)
{
this.TallyPartViewModel.Tally1.PinMask = GPIOManager.GetPinMask(tallyInfo.PinIndex1);
this.tallyPartViewModel.Color1 = (Color)ColorConverter.ConvertFromString(tallyInfo.Color1);
this.TallyPartViewModel.Tally1.GPIOModel = gpioModel;
this.tallyPartViewModel.Tally2.PinMask = GPIOManager.GetPinMask(tallyInfo.PinIndex2);
this.tallyPartViewModel.Color2 = (Color)ColorConverter.ConvertFromString(tallyInfo.Color2);
this.tallyPartViewModel.Tally2.GPIOModel = gpioModel;
}
/// <summary>
/// 更新Tally配置
/// </summary>
/// <param name="gpioModel">GPIO模型</param>
public void UpdateTallyConfig(GPIOModel gpioModel)
{
this.TallyPartViewModel.Tally1.GPIOModel = gpioModel;
this.tallyPartViewModel.Tally2.GPIOModel = gpioModel;
}
/// <summary>
/// 停止算法
/// </summary>
public void StopAlgorithm()
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using VIZ.Framework.Core;
namespace VIZ.H2V.Module
{
/// <summary>
/// Tally部分视图模型
/// </summary>
public class NDIViewTallyPartViewModel : ModelBase
{
#region Tally1 -- Tally信号1
private GPIOPropertyModel tally1 = new GPIOPropertyModel();
/// <summary>
/// Tally信号1
/// </summary>
public GPIOPropertyModel Tally1
{
get { return tally1; }
set { tally1 = value; this.RaisePropertyChanged(nameof(Tally1)); }
}
#endregion
#region Tally2 -- Tally信号2
private GPIOPropertyModel tally2 = new GPIOPropertyModel();
/// <summary>
/// Tally信号2
/// </summary>
public GPIOPropertyModel Tally2
{
get { return tally2; }
set { tally2 = value; this.RaisePropertyChanged(nameof(Tally2)); }
}
#endregion
#region Color1 -- Tally信号1颜色
private Color color1;
/// <summary>
/// Tally信号1颜色
/// </summary>
public Color Color1
{
get { return color1; }
set { color1 = value; this.RaisePropertyChanged(nameof(Color1)); }
}
#endregion
#region Color2 -- Tally信号2颜色
private Color color2;
/// <summary>
/// Tally信号2颜色
/// </summary>
public Color Color2
{
get { return color2; }
set { color2 = value; this.RaisePropertyChanged(nameof(Color2)); }
}
#endregion
}
}
using log4net;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Management;
using VIZ.Framework.Core;
using VIZ.Framework.Connection;
using VIZ.Framework.Module;
using VIZ.H2V.Domain;
using VIZ.H2V.Storage;
using VIZ.H2V.Connection;
namespace VIZ.H2V.Module
{
/// <summary>
/// 应用程序启动 -- GPIO转USB信号
/// </summary>
public class AppSetup_GPIO2USB : AppSetupBase
{
/// <summary>
/// 日志
/// </summary>
private static ILog log = LogManager.GetLogger(typeof(AppSetup_GPIO2USB));
/// <summary>
/// 描述
/// </summary>
public override string Detail { get; } = "应用程序启动 -- GPIO转USB信号";
/// <summary>
/// 执行启动
/// </summary>
/// <param name="context">应用程序启动上下文</param>
/// <returns>是否成功执行</returns>
public override bool Setup(AppSetupContext context)
{
List<USBDeviceInfo> infos = GPIOManager.ScanDevice();
if (infos == null || infos.Count == 0)
return true;
foreach (USBDeviceInfo info in infos)
{
GPIOModel model = new GPIOModel(info);
GPIOManager.Models.Add(model);
}
ApplicationDomainEx.GPIOModel = GPIOManager.Models.FirstOrDefault();
ApplicationDomainEx.GPIOModel.Open();
return true;
}
/// <summary>
/// 执行关闭
/// </summary>
/// <param name="context">应用程序启动上下文</param>
public override void Shutdown(AppSetupContext context)
{
ApplicationDomainEx.GPIOModel?.Close();
}
}
}
......@@ -5,6 +5,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using VIZ.Framework.Core;
using VIZ.H2V.Domain;
namespace VIZ.H2V.Module
{
......@@ -13,13 +14,37 @@ namespace VIZ.H2V.Module
/// </summary>
public class TallyCamSignalModel : ModelBase
{
/// <summary>
/// Tally窗口信号模型
/// </summary>
/// <param name="viewKey">视图键<see cref="NDIViewKeys"/></param>
public TallyCamSignalModel(string viewKey)
{
this.ViewKey = viewKey;
}
#region ViewKey -- 视图键
private string vewKey;
/// <summary>
/// 视图键
/// <see cref="NDIViewKeys"/>
/// </summary>
public string ViewKey
{
get { return vewKey; }
set { vewKey = value; this.RaisePropertyChanged(nameof(ViewKey)); }
}
#endregion
#region PinIndex1 -- 信号1引脚索引
private int? pinIndex1;
private GPIOPinModel pinIndex1;
/// <summary>
/// 信号1引脚索引
/// </summary>
public int? PinIndex1
public GPIOPinModel PinIndex1
{
get { return pinIndex1; }
set { pinIndex1 = value; this.RaisePropertyChanged(nameof(PinIndex1)); }
......@@ -29,11 +54,11 @@ namespace VIZ.H2V.Module
#region PinIndex2 -- 信号2引脚索引
private int? pinIndex2;
private GPIOPinModel pinIndex2;
/// <summary>
/// 信号2引脚索引
/// </summary>
public int? PinIndex2
public GPIOPinModel PinIndex2
{
get { return pinIndex2; }
set { pinIndex2 = value; this.RaisePropertyChanged(nameof(PinIndex2)); }
......
......@@ -29,5 +29,13 @@ namespace VIZ.H2V.Module
{
return true;
}
/// <summary>
/// 取消
/// </summary>
public void Cancel()
{
}
}
}
......@@ -502,6 +502,14 @@ namespace VIZ.H2V.Module
return true;
}
/// <summary>
/// 取消
/// </summary>
public void Cancel()
{
}
// ======================================================================================
// === Prviate Function ===
// ======================================================================================
......
......@@ -22,5 +22,10 @@ namespace VIZ.H2V.Module
/// </summary>
/// <returns>是否成功保存</returns>
bool Save();
/// <summary>
/// 取消
/// </summary>
void Cancel();
}
}
......@@ -303,5 +303,13 @@ namespace VIZ.H2V.Module
// 返回
return true;
}
/// <summary>
/// 取消
/// </summary>
public void Cancel()
{
}
}
}
......@@ -141,6 +141,11 @@ namespace VIZ.H2V.Module
/// </summary>
private void Cancel()
{
foreach (ISystemSetting setting in this.Settings)
{
setting.Cancel();
}
this.GetWindow().Close();
}
......
......@@ -8,17 +8,21 @@ using System.Windows;
using VIZ.Framework.Core;
using VIZ.H2V.Domain;
using VIZ.H2V.Storage;
using VIZ.Framework.Common;
namespace VIZ.H2V.Module
{
/// <summary>
/// Tally设置面板视图模型
/// </summary>
public class TallySettingPanelViewModel : ViewModelBase, ISystemSetting
public class TallySettingPanelViewModel : ViewModelBase, ISystemSetting, IGpioSupport
{
public TallySettingPanelViewModel()
{
this.LoadedCommand = new VCommand(this.Loaded);
this.InitTallyCommand = new VCommand(this.InitTally);
this.GpioController = new GpioController(this);
}
// ======================================================================================
......@@ -30,13 +34,18 @@ namespace VIZ.H2V.Module
/// </summary>
private SystemConfig SystemConfig;
/// <summary>
/// GPIO控制器
/// </summary>
private GpioController GpioController;
// ======================================================================================
// === Property ===
// ======================================================================================
#region TallyInfo1 -- Tally信号 -- 窗口1
private TallyCamSignalModel tallyInfo1 = new TallyCamSignalModel();
private TallyCamSignalModel tallyInfo1 = new TallyCamSignalModel(NDIViewKeys.CAM_1);
/// <summary>
/// Tally信号 -- 窗口1
/// </summary>
......@@ -50,7 +59,7 @@ namespace VIZ.H2V.Module
#region TallyInfo2 -- Tally信号 -- 窗口2
private TallyCamSignalModel tallyInfo2 = new TallyCamSignalModel();
private TallyCamSignalModel tallyInfo2 = new TallyCamSignalModel(NDIViewKeys.CAM_2);
/// <summary>
/// Tally信号 -- 窗口2
/// </summary>
......@@ -64,7 +73,7 @@ namespace VIZ.H2V.Module
#region TallyInfo3 -- Tally信号 -- 窗口3
private TallyCamSignalModel tallyInfo3 = new TallyCamSignalModel();
private TallyCamSignalModel tallyInfo3 = new TallyCamSignalModel(NDIViewKeys.CAM_3);
/// <summary>
/// Tally信号 -- 窗口3
/// </summary>
......@@ -78,7 +87,7 @@ namespace VIZ.H2V.Module
#region TallyInfo4 -- Tally信号 -- 窗口4
private TallyCamSignalModel tallyInfo4 = new TallyCamSignalModel();
private TallyCamSignalModel tallyInfo4 = new TallyCamSignalModel(NDIViewKeys.CAM_4);
/// <summary>
/// Tally信号 -- 窗口4
/// </summary>
......@@ -90,41 +99,27 @@ namespace VIZ.H2V.Module
#endregion
#region GPIOModels -- GPIO模型集合
#region GPIOModel -- GPIO模型
private List<GPIOModel> gpioModels;
private GPIOModel gpioModel;
/// <summary>
/// GPIO模型集合
/// GPIO模型
/// </summary>
public List<GPIOModel> GPIOModels
public GPIOModel GPIOModel
{
get { return gpioModels; }
set { gpioModels = value; this.RaisePropertyChanged(nameof(GPIOModels)); }
}
#endregion
#region SelectedGPIOModel -- 选中的GPIO模型
private GPIOModel selectedGPIOModel;
/// <summary>
/// 选中的GPIO模型
/// </summary>
public GPIOModel SelectedGPIOModel
{
get { return selectedGPIOModel; }
set { selectedGPIOModel = value; this.RaisePropertyChanged(nameof(SelectedGPIOModel)); }
get { return gpioModel; }
set { gpioModel = value; this.RaisePropertyChanged(nameof(GPIOModel)); }
}
#endregion
#region GPIO_Pin_List -- GPIO引脚列表
private List<int?> gpio_pin_list;
private List<GPIOPinModel> gpio_pin_list;
/// <summary>
/// GPIO引脚列表
/// </summary>
public List<int?> GPIO_Pin_List
public List<GPIOPinModel> GPIO_Pin_List
{
get { return gpio_pin_list; }
set { gpio_pin_list = value; this.RaisePropertyChanged(nameof(GPIO_Pin_List)); }
......@@ -148,19 +143,17 @@ namespace VIZ.H2V.Module
/// </summary>
private void Loaded()
{
if (this.IsAlreadyLoaded)
return;
SystemSettingViewModel vm = WPFHelper.GetAncestorByType<SystemSettingView>(this.GetView<FrameworkElement>()).DataContext as SystemSettingViewModel;
vm.Settings.Add(this);
this.SystemConfig = vm.SystemConfig;
List<int?> pin_list = new List<int?>();
pin_list.Add(null);
for (int i = 0; i <= 15; i++)
{
pin_list.Add(i);
}
this.GPIO_Pin_List = pin_list;
List<GPIOPinModel> pinModels = GPIOManager.GetPinModels();
pinModels.Insert(0, new GPIOPinModel() { Index = null, PinMask = GPIOPin.PIN_DEFAULT_VALUE });
this.GPIO_Pin_List = pinModels;
this.loadTallyInfo(this.TallyInfo1, this.SystemConfig.TallyInfo1);
this.loadTallyInfo(this.TallyInfo2, this.SystemConfig.TallyInfo2);
......@@ -168,8 +161,27 @@ namespace VIZ.H2V.Module
this.loadTallyInfo(this.TallyInfo4, this.SystemConfig.TallyInfo4);
// GPIO模型
this.GPIOModels = GPIOManager.Models;
this.SelectedGPIOModel = this.GPIOModels?.FirstOrDefault();
this.GPIOModel = ApplicationDomainEx.GPIOModel;
this.IsAlreadyLoaded = true;
}
#endregion
#region ScanDeviceCommand -- 扫描设备命令
/// <summary>
/// 扫描设备命令
/// </summary>
public VCommand InitTallyCommand { get; set; }
/// <summary>
/// 扫描设备
/// </summary>
private void InitTally()
{
this.GpioController.Init();
this.GPIOModel = ApplicationDomainEx.GPIOModel;
}
#endregion
......@@ -211,17 +223,38 @@ namespace VIZ.H2V.Module
ApplicationDomainEx.LiteDbContext.SystemConfig.Update(this.SystemConfig);
// 应用
//ApplicationDomainEx.ServiceManager.GetServiceList<INDIViewService>().ForEach(p =>
//{
// p.LoadStyle();
// p.LoadClipBoxSmooth(this.ManualSmoothCoeff);
//});
ApplicationDomainEx.ServiceManager.GetServiceList<INDIViewService>().ForEach(p =>
{
switch (p.ViewConfig.ViewKey)
{
case NDIViewKeys.CAM_1:
p.UpdateTallyConfig(this.TallyInfo1, this.GPIOModel);
break;
case NDIViewKeys.CAM_2:
p.UpdateTallyConfig(this.TallyInfo2, this.GPIOModel);
break;
case NDIViewKeys.CAM_3:
p.UpdateTallyConfig(this.TallyInfo3, this.GPIOModel);
break;
case NDIViewKeys.CAM_4:
p.UpdateTallyConfig(this.TallyInfo4, this.GPIOModel);
break;
}
});
// 返回
return true;
}
/// <summary>
/// 取消
/// </summary>
public void Cancel()
{
}
/// <summary>
/// 加载Tally信息
/// </summary>
/// <param name="model">模型</param>
......@@ -229,8 +262,8 @@ namespace VIZ.H2V.Module
private void loadTallyInfo(TallyCamSignalModel model, TallyInfo entity)
{
// CAM 2
model.PinIndex1 = entity.PinIndex1;
model.PinIndex2 = entity.PinIndex2;
model.PinIndex1 = this.GPIO_Pin_List.FirstOrDefault(p => p.Index == entity.PinIndex1);
model.PinIndex2 = this.GPIO_Pin_List.FirstOrDefault(p => p.Index == entity.PinIndex2);
model.Color1 = (Color)ColorConverter.ConvertFromString(entity.Color1);
model.Color2 = (Color)ColorConverter.ConvertFromString(entity.Color2);
}
......@@ -243,9 +276,9 @@ namespace VIZ.H2V.Module
/// <returns>是否需要保存TallyInfo信息</returns>
private bool isTallyInfoNeedSave(TallyCamSignalModel model, TallyInfo entity)
{
if (model.PinIndex1 != entity.PinIndex1)
if (model.PinIndex1.Index != entity.PinIndex1)
return true;
if (model.PinIndex2 != entity.PinIndex2)
if (model.PinIndex2.Index != entity.PinIndex2)
return true;
if (model.Color1.ToString() != entity.Color1)
return true;
......@@ -262,8 +295,8 @@ namespace VIZ.H2V.Module
/// <param name="entity">实体</param>
private void saveTallyInfo(TallyCamSignalModel model, TallyInfo entity)
{
entity.PinIndex1 = model.PinIndex1;
entity.PinIndex2 = model.PinIndex2;
entity.PinIndex1 = model.PinIndex1.Index;
entity.PinIndex2 = model.PinIndex2.Index;
entity.Color1 = model.Color1.ToString();
entity.Color2 = model.Color2.ToString();
}
......
......@@ -252,7 +252,9 @@
<Compile Include="NDIView\VieweModel\NDIViewModel.Message.cs" />
<Compile Include="NDIView\VieweModel\NDIViewModel.Property.cs" />
<Compile Include="NDIView\VieweModel\NDIViewModel.cs" />
<Compile Include="NDIView\VieweModel\Part\NDIViewTallyPartViewModel.cs" />
<Compile Include="NDIView\VieweModel\Part\NDIViewToolPartViewModel.cs" />
<Compile Include="Setup\Provider\AppSetup_GPIO2USB.cs" />
<Compile Include="Setup\Provider\AppSetup_Navigation3DConfig.cs" />
<Compile Include="Setup\Provider\AppSetup_Algorithm.cs" />
<Compile Include="Setup\Provider\AppSetup_Recording.cs" />
......
......@@ -39,6 +39,8 @@ namespace VIZ.H2V
AppSetup.AppendLoad(new AppSetup_Monitor());
// 初始化3D鼠标
AppSetup.AppendLoad(new AppSetup_Navigation3D());
// 初始化Tally
AppSetup.AppendLoad(new AppSetup_GPIO2USB());
// 保存居中模式裁切框
AppSetup.AppendLoad(new AppSetup_SaveCenterClipBox());
// 调试窗口
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment