Commit 9fe41017 by liulongfei

1. Tally信号支持

parent 404f3805
File added
...@@ -28,5 +28,10 @@ namespace VIZ.H2V.Domain ...@@ -28,5 +28,10 @@ namespace VIZ.H2V.Domain
/// 3D鼠标映射配置 /// 3D鼠标映射配置
/// </summary> /// </summary>
public static Navigation3DMappingDomainModel Navigation3DMapping { get; private set; } = new Navigation3DMappingDomainModel(); public static Navigation3DMappingDomainModel Navigation3DMapping { get; private set; } = new Navigation3DMappingDomainModel();
/// <summary>
/// 当前使用的GPIO模型
/// </summary>
public static GPIOModel GPIOModel { get; set; }
} }
} }
...@@ -21,4 +21,25 @@ ...@@ -21,4 +21,25 @@
</Setter.Value> </Setter.Value>
</Setter> </Setter>
</Style> </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> </ResourceDictionary>
\ No newline at end of file
...@@ -212,5 +212,8 @@ ...@@ -212,5 +212,8 @@
<Resource Include="Icons\ai_close_24x24.png" /> <Resource Include="Icons\ai_close_24x24.png" />
<Resource Include="Icons\ai_refresh_24x24.png" /> <Resource Include="Icons\ai_refresh_24x24.png" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Resource Include="Icons\tally_24x24.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>
\ No newline at end of file
...@@ -4,6 +4,9 @@ using System.Collections.Generic; ...@@ -4,6 +4,9 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using VIZ.Framework.Common;
using VIZ.Framework.Core;
using VIZ.H2V.Domain;
namespace VIZ.H2V.Module namespace VIZ.H2V.Module
{ {
...@@ -36,7 +39,33 @@ namespace VIZ.H2V.Module ...@@ -36,7 +39,33 @@ namespace VIZ.H2V.Module
/// </summary> /// </summary>
public void Init() 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 @@ ...@@ -39,9 +39,11 @@
<Grid Background="#ff12202d"> <Grid Background="#ff12202d">
<TextBlock Text="横转竖智能裁切系统" FontSize="12" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock> <TextBlock Text="横转竖智能裁切系统" FontSize="12" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock>
<StackPanel Orientation="Horizontal" Grid.Column="2" HorizontalAlignment="Right" VerticalAlignment="Top"> <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="初始化摇杆" <Button Command="{Binding Path=InitNavigation3DCommand}" ToolTip="初始化摇杆"
Style="{StaticResource Button_Navigation3D}" Height="30"></Button> 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="系统设置" <Button Command="{Binding Path=SettingCommand}" ToolTip="系统设置"
Style="{StaticResource Button_Setting}" Height="30"></Button> Style="{StaticResource Button_Setting}" Height="30"></Button>
<Button Command="{Binding Path=MinCommand}" ToolTip="最小化" <Button Command="{Binding Path=MinCommand}" ToolTip="最小化"
......
...@@ -19,7 +19,7 @@ namespace VIZ.H2V.Module ...@@ -19,7 +19,7 @@ namespace VIZ.H2V.Module
/// <summary> /// <summary>
/// NDI主视图模型 /// NDI主视图模型
/// </summary> /// </summary>
public class NDIMainViewModel : ViewModelBase, INDIMainViewService, IHotkeySupport public class NDIMainViewModel : ViewModelBase, INDIMainViewService, IHotkeySupport, IGpioSupport
{ {
/// <summary> /// <summary>
/// NDI主视图模型 /// NDI主视图模型
...@@ -58,6 +58,7 @@ namespace VIZ.H2V.Module ...@@ -58,6 +58,7 @@ namespace VIZ.H2V.Module
this.CloseCommand = new VCommand(this.Close); this.CloseCommand = new VCommand(this.Close);
this.SettingCommand = new VCommand(this.Setting); this.SettingCommand = new VCommand(this.Setting);
this.InitNavigation3DCommand = new VCommand(this.InitNavigation3D); this.InitNavigation3DCommand = new VCommand(this.InitNavigation3D);
this.InitTallyCommand = new VCommand(this.InitTally);
} }
/// <summary> /// <summary>
...@@ -82,6 +83,7 @@ namespace VIZ.H2V.Module ...@@ -82,6 +83,7 @@ namespace VIZ.H2V.Module
private void InitController() private void InitController()
{ {
this.hotkeyController = new HotkeyController(this); this.hotkeyController = new HotkeyController(this);
this.gpioController = new GpioController(this);
} }
/// <summary> /// <summary>
...@@ -113,6 +115,11 @@ namespace VIZ.H2V.Module ...@@ -113,6 +115,11 @@ namespace VIZ.H2V.Module
/// </summary> /// </summary>
private HotkeyController hotkeyController; private HotkeyController hotkeyController;
/// <summary>
/// GPIO控制器
/// </summary>
private GpioController gpioController;
// ====================================================================================== // ======================================================================================
// === Property === // === Property ===
// ====================================================================================== // ======================================================================================
...@@ -247,6 +254,23 @@ namespace VIZ.H2V.Module ...@@ -247,6 +254,23 @@ namespace VIZ.H2V.Module
#endregion #endregion
#region InitTallyCommand -- 初始化Tally命令
/// <summary>
/// 初始化Tally命令
/// </summary>
public VCommand InitTallyCommand { get; set; }
/// <summary>
/// 初始化Tally
/// </summary>
private void InitTally()
{
this.gpioController.Init();
}
#endregion
// ====================================================================================== // ======================================================================================
// === Privatee Function === // === Privatee Function ===
// ====================================================================================== // ======================================================================================
......
...@@ -71,6 +71,26 @@ namespace VIZ.H2V.Module ...@@ -71,6 +71,26 @@ namespace VIZ.H2V.Module
void LoadClipBoxSmooth(double minCutoff); void LoadClipBoxSmooth(double minCutoff);
/// <summary> /// <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> /// </summary>
void SaveCenterClipBoxToAlgorithmConfig(); void SaveCenterClipBoxToAlgorithmConfig();
......
...@@ -23,6 +23,8 @@ ...@@ -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/CheckBox/CheckBox_NdiView.xaml"></ResourceDictionary>
<ResourceDictionary Source="/VIZ.H2V.Module.Resource;component/Style/RadioButton/RadioButton_NdiView.xaml"></ResourceDictionary> <ResourceDictionary Source="/VIZ.H2V.Module.Resource;component/Style/RadioButton/RadioButton_NdiView.xaml"></ResourceDictionary>
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
<fcore:Bool2VisibilityConverter x:Key="Bool2VisibilityConverter"></fcore:Bool2VisibilityConverter>
<fcore:Color2SolidColorBrushConverter x:Key="Color2SolidColorBrushConverter"></fcore:Color2SolidColorBrushConverter>
<fcore:Bool2BoolConverter x:Key="Bool2BoolConverter"></fcore:Bool2BoolConverter> <fcore:Bool2BoolConverter x:Key="Bool2BoolConverter"></fcore:Bool2BoolConverter>
<fcore:StringAppendConverter x:Key="StringAppendConverter"></fcore:StringAppendConverter> <fcore:StringAppendConverter x:Key="StringAppendConverter"></fcore:StringAppendConverter>
<resource:NDIViewStatus2BoolConverter x:Key="NDIViewStatus2IsEnabledConverter" TrueListString="Detect,CropRoi"></resource:NDIViewStatus2BoolConverter> <resource:NDIViewStatus2BoolConverter x:Key="NDIViewStatus2IsEnabledConverter" TrueListString="Detect,CropRoi"></resource:NDIViewStatus2BoolConverter>
...@@ -195,7 +197,7 @@ ...@@ -195,7 +197,7 @@
</RadioButton>--> </RadioButton>-->
<!-- 近景机位 & 16米机位 & 战术机位 ===== 边线检测选择面板 --> <!-- 近景机位 & 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}}"> Visibility="{Binding Path=AlgorithmConfig.IsShowBorder,Mode=OneWay,Converter={StaticResource Bool2VisibilityConverter}}">
<RadioButton Style="{StaticResource RadioButton_NdiView_None}" <RadioButton Style="{StaticResource RadioButton_NdiView_None}"
Height="{Binding ElementName=uc,Path=DataContext.StrategyType,Converter={StaticResource AlgorithmStrategyType2FootballFieldHeightConverter}}" Height="{Binding ElementName=uc,Path=DataContext.StrategyType,Converter={StaticResource AlgorithmStrategyType2FootballFieldHeightConverter}}"
...@@ -214,7 +216,7 @@ ...@@ -214,7 +216,7 @@
Orientation="{Binding ElementName=uc,Path=DataContext.StrategyType,Converter={StaticResource AlgorithmStrategyType2FootballFieldOrientationConverter}}"> Orientation="{Binding ElementName=uc,Path=DataContext.StrategyType,Converter={StaticResource AlgorithmStrategyType2FootballFieldOrientationConverter}}">
</common:FootballFieldPanel> </common:FootballFieldPanel>
</RadioButton> </RadioButton>
</Border> </Border>-->
<!-- 居中模式 按钮组--> <!-- 居中模式 按钮组-->
<Grid Grid.Row="1" Background="{x:Null}"> <Grid Grid.Row="1" Background="{x:Null}">
...@@ -239,9 +241,14 @@ ...@@ -239,9 +241,14 @@
<!-- Tally --> <!-- Tally -->
<StackPanel Grid.Row="0" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,0,5" Orientation="Horizontal"> <StackPanel Grid.Row="0" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,0,5" Orientation="Horizontal">
<!-- 信号2 -->
<Ellipse Width="24" Height="24" Fill="#DDFF0000" Margin="0,0,0,0"></Ellipse> <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> </StackPanel>
<!-- 功能区 --> <!-- 功能区 -->
...@@ -336,7 +343,7 @@ ...@@ -336,7 +343,7 @@
<!-- AI功能区 --> <!-- AI功能区 -->
<StackPanel Orientation="Vertical" VerticalAlignment="Bottom" Grid.Row="1"> <StackPanel Orientation="Vertical" VerticalAlignment="Bottom" Grid.Row="1">
<TextBlock Text="AI" Foreground="#AAFFFFFF" HorizontalAlignment="Center"></TextBlock> <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"> <Border Margin="0,10,0,0" ToolTip="重启算法" Background="Transparent">
<Button Width="32" Height="32" <Button Width="32" Height="32"
Style="{StaticResource Button_Function}" Style="{StaticResource Button_Function}"
......
...@@ -90,6 +90,7 @@ namespace VIZ.H2V.Module ...@@ -90,6 +90,7 @@ namespace VIZ.H2V.Module
/// </summary> /// </summary>
private void Loaded_Property() private void Loaded_Property()
{ {
SystemConfig systemConfig = ApplicationDomainEx.LiteDbContext.SystemConfig.FindAll().FirstOrDefault();
AlgorithmStrategy strategy = ApplicationDomainEx.CsvContext.AlgorithmStrategys.FirstOrDefault(p => p.ID == (int)this.ViewConfig.StrategyType); AlgorithmStrategy strategy = ApplicationDomainEx.CsvContext.AlgorithmStrategys.FirstOrDefault(p => p.ID == (int)this.ViewConfig.StrategyType);
// 算法ID // 算法ID
...@@ -105,6 +106,9 @@ namespace VIZ.H2V.Module ...@@ -105,6 +106,9 @@ namespace VIZ.H2V.Module
// 居中模式下的裁切框位置 // 居中模式下的裁切框位置
this.ClipBoxX_CenterMode = this.AlgorithmConfig.CenterClipBoxX; this.ClipBoxX_CenterMode = this.AlgorithmConfig.CenterClipBoxX;
// 初始化Tally
this.InitTally(systemConfig);
// 记录档期操作日志 // 记录档期操作日志
this.WriteLogOperation(this.StrategyMode); this.WriteLogOperation(this.StrategyMode);
} }
...@@ -130,7 +134,7 @@ namespace VIZ.H2V.Module ...@@ -130,7 +134,7 @@ namespace VIZ.H2V.Module
SideCheckPolygonPlugin sideCheckPolygonPlugin = new SideCheckPolygonPlugin(view.video); SideCheckPolygonPlugin sideCheckPolygonPlugin = new SideCheckPolygonPlugin(view.video);
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
// 新的边线检测算法不需要校准 <新算法暂未上线> // 新的边线检测算法不需要校准 <新算法暂未上线>
sideCheckPolygonPlugin.Click += SideCheckPolygonPlugin_Click; //sideCheckPolygonPlugin.Click += SideCheckPolygonPlugin_Click;
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
view.video.AttachPlugin(sideCheckPolygonPlugin); view.video.AttachPlugin(sideCheckPolygonPlugin);
...@@ -241,6 +245,33 @@ namespace VIZ.H2V.Module ...@@ -241,6 +245,33 @@ namespace VIZ.H2V.Module
view.video.UpdateManualCorrection(info); 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 #endregion
#region SettingCommand -- 设置命令 #region SettingCommand -- 设置命令
......
...@@ -161,11 +161,11 @@ namespace VIZ.H2V.Module ...@@ -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); this.OnAlgorithmMessage__crop_roi__correction_area(msg, renderInfo, view);
......
...@@ -563,6 +563,20 @@ namespace VIZ.H2V.Module ...@@ -563,6 +563,20 @@ namespace VIZ.H2V.Module
#endregion #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 -- 调试日志 #region DebugLog -- 调试日志
private string debugLog; private string debugLog;
......
...@@ -4,6 +4,7 @@ using System.Linq; ...@@ -4,6 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web.UI; using System.Web.UI;
using System.Windows.Media;
using log4net; using log4net;
using SharpDX.Mathematics.Interop; using SharpDX.Mathematics.Interop;
using VIZ.Framework.Common; using VIZ.Framework.Common;
...@@ -385,6 +386,49 @@ namespace VIZ.H2V.Module ...@@ -385,6 +386,49 @@ namespace VIZ.H2V.Module
} }
/// <summary> /// <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> /// </summary>
public void StopAlgorithm() 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; ...@@ -5,6 +5,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Media; using System.Windows.Media;
using VIZ.Framework.Core; using VIZ.Framework.Core;
using VIZ.H2V.Domain;
namespace VIZ.H2V.Module namespace VIZ.H2V.Module
{ {
...@@ -13,13 +14,37 @@ namespace VIZ.H2V.Module ...@@ -13,13 +14,37 @@ namespace VIZ.H2V.Module
/// </summary> /// </summary>
public class TallyCamSignalModel : ModelBase 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引脚索引 #region PinIndex1 -- 信号1引脚索引
private int? pinIndex1; private GPIOPinModel pinIndex1;
/// <summary> /// <summary>
/// 信号1引脚索引 /// 信号1引脚索引
/// </summary> /// </summary>
public int? PinIndex1 public GPIOPinModel PinIndex1
{ {
get { return pinIndex1; } get { return pinIndex1; }
set { pinIndex1 = value; this.RaisePropertyChanged(nameof(PinIndex1)); } set { pinIndex1 = value; this.RaisePropertyChanged(nameof(PinIndex1)); }
...@@ -29,11 +54,11 @@ namespace VIZ.H2V.Module ...@@ -29,11 +54,11 @@ namespace VIZ.H2V.Module
#region PinIndex2 -- 信号2引脚索引 #region PinIndex2 -- 信号2引脚索引
private int? pinIndex2; private GPIOPinModel pinIndex2;
/// <summary> /// <summary>
/// 信号2引脚索引 /// 信号2引脚索引
/// </summary> /// </summary>
public int? PinIndex2 public GPIOPinModel PinIndex2
{ {
get { return pinIndex2; } get { return pinIndex2; }
set { pinIndex2 = value; this.RaisePropertyChanged(nameof(PinIndex2)); } set { pinIndex2 = value; this.RaisePropertyChanged(nameof(PinIndex2)); }
......
...@@ -69,11 +69,23 @@ ...@@ -69,11 +69,23 @@
<ComboBox Grid.Row="0" Grid.Column="2" Style="{StaticResource ComboBox_Setting}" <ComboBox Grid.Row="0" Grid.Column="2" Style="{StaticResource ComboBox_Setting}"
Margin="10,0,10,0" Height="30" Margin="10,0,10,0" Height="30"
ItemsSource="{Binding Path=GPIO_Pin_List}" ItemsSource="{Binding Path=GPIO_Pin_List}"
SelectedValue="{Binding Path=TallyInfo1.PinIndex1,Mode=TwoWay}"></ComboBox> SelectedValue="{Binding Path=TallyInfo1.PinIndex1,Mode=TwoWay}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Index}" Foreground="White" FontSize="12"></TextBlock>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<ComboBox Grid.Row="1" Grid.Column="2" Style="{StaticResource ComboBox_Setting}" <ComboBox Grid.Row="1" Grid.Column="2" Style="{StaticResource ComboBox_Setting}"
Margin="10,0,10,0" Height="30" Margin="10,0,10,0" Height="30"
ItemsSource="{Binding Path=GPIO_Pin_List}" ItemsSource="{Binding Path=GPIO_Pin_List}"
SelectedValue="{Binding Path=TallyInfo1.PinIndex2,Mode=TwoWay}"></ComboBox> SelectedValue="{Binding Path=TallyInfo1.PinIndex2,Mode=TwoWay}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Index}" Foreground="White" FontSize="12"></TextBlock>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<fcommon:ColorPickButton Grid.Row="0" Grid.Column="4" Height="30" Width="60" <fcommon:ColorPickButton Grid.Row="0" Grid.Column="4" Height="30" Width="60"
Color="{Binding Path=TallyInfo1.Color1,Mode=TwoWay}"></fcommon:ColorPickButton> Color="{Binding Path=TallyInfo1.Color1,Mode=TwoWay}"></fcommon:ColorPickButton>
<fcommon:ColorPickButton Grid.Row="1" Grid.Column="4" Height="30" Width="60" <fcommon:ColorPickButton Grid.Row="1" Grid.Column="4" Height="30" Width="60"
...@@ -102,11 +114,23 @@ ...@@ -102,11 +114,23 @@
<ComboBox Grid.Row="0" Grid.Column="2" Style="{StaticResource ComboBox_Setting}" <ComboBox Grid.Row="0" Grid.Column="2" Style="{StaticResource ComboBox_Setting}"
Margin="10,0,10,0" Height="30" Margin="10,0,10,0" Height="30"
ItemsSource="{Binding Path=GPIO_Pin_List}" ItemsSource="{Binding Path=GPIO_Pin_List}"
SelectedValue="{Binding Path=TallyInfo2.PinIndex1,Mode=TwoWay}"></ComboBox> SelectedValue="{Binding Path=TallyInfo2.PinIndex1,Mode=TwoWay}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Index}" Foreground="White" FontSize="12"></TextBlock>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<ComboBox Grid.Row="1" Grid.Column="2" Style="{StaticResource ComboBox_Setting}" <ComboBox Grid.Row="1" Grid.Column="2" Style="{StaticResource ComboBox_Setting}"
Margin="10,0,10,0" Height="30" Margin="10,0,10,0" Height="30"
ItemsSource="{Binding Path=GPIO_Pin_List}" ItemsSource="{Binding Path=GPIO_Pin_List}"
SelectedValue="{Binding Path=TallyInfo2.PinIndex2,Mode=TwoWay}"></ComboBox> SelectedValue="{Binding Path=TallyInfo2.PinIndex2,Mode=TwoWay}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Index}" Foreground="White" FontSize="12"></TextBlock>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<fcommon:ColorPickButton Grid.Row="0" Grid.Column="4" Height="30" Width="60" <fcommon:ColorPickButton Grid.Row="0" Grid.Column="4" Height="30" Width="60"
Color="{Binding Path=TallyInfo2.Color1,Mode=TwoWay}"></fcommon:ColorPickButton> Color="{Binding Path=TallyInfo2.Color1,Mode=TwoWay}"></fcommon:ColorPickButton>
<fcommon:ColorPickButton Grid.Row="1" Grid.Column="4" Height="30" Width="60" <fcommon:ColorPickButton Grid.Row="1" Grid.Column="4" Height="30" Width="60"
...@@ -135,11 +159,23 @@ ...@@ -135,11 +159,23 @@
<ComboBox Grid.Row="0" Grid.Column="2" Style="{StaticResource ComboBox_Setting}" <ComboBox Grid.Row="0" Grid.Column="2" Style="{StaticResource ComboBox_Setting}"
Margin="10,0,10,0" Height="30" Margin="10,0,10,0" Height="30"
ItemsSource="{Binding Path=GPIO_Pin_List}" ItemsSource="{Binding Path=GPIO_Pin_List}"
SelectedValue="{Binding Path=TallyInfo3.PinIndex1,Mode=TwoWay}"></ComboBox> SelectedValue="{Binding Path=TallyInfo3.PinIndex1,Mode=TwoWay}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Index}" Foreground="White" FontSize="12"></TextBlock>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<ComboBox Grid.Row="1" Grid.Column="2" Style="{StaticResource ComboBox_Setting}" <ComboBox Grid.Row="1" Grid.Column="2" Style="{StaticResource ComboBox_Setting}"
Margin="10,0,10,0" Height="30" Margin="10,0,10,0" Height="30"
ItemsSource="{Binding Path=GPIO_Pin_List}" ItemsSource="{Binding Path=GPIO_Pin_List}"
SelectedValue="{Binding Path=TallyInfo3.PinIndex2,Mode=TwoWay}"></ComboBox> SelectedValue="{Binding Path=TallyInfo3.PinIndex2,Mode=TwoWay}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Index}" Foreground="White" FontSize="12"></TextBlock>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<fcommon:ColorPickButton Grid.Row="0" Grid.Column="4" Height="30" Width="60" <fcommon:ColorPickButton Grid.Row="0" Grid.Column="4" Height="30" Width="60"
Color="{Binding Path=TallyInfo3.Color1,Mode=TwoWay}"></fcommon:ColorPickButton> Color="{Binding Path=TallyInfo3.Color1,Mode=TwoWay}"></fcommon:ColorPickButton>
<fcommon:ColorPickButton Grid.Row="1" Grid.Column="4" Height="30" Width="60" <fcommon:ColorPickButton Grid.Row="1" Grid.Column="4" Height="30" Width="60"
...@@ -168,11 +204,23 @@ ...@@ -168,11 +204,23 @@
<ComboBox Grid.Row="0" Grid.Column="2" Style="{StaticResource ComboBox_Setting}" <ComboBox Grid.Row="0" Grid.Column="2" Style="{StaticResource ComboBox_Setting}"
Margin="10,0,10,0" Height="30" Margin="10,0,10,0" Height="30"
ItemsSource="{Binding Path=GPIO_Pin_List}" ItemsSource="{Binding Path=GPIO_Pin_List}"
SelectedValue="{Binding Path=TallyInfo4.PinIndex1,Mode=TwoWay}"></ComboBox> SelectedValue="{Binding Path=TallyInfo4.PinIndex1,Mode=TwoWay}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Index}" Foreground="White" FontSize="12"></TextBlock>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<ComboBox Grid.Row="1" Grid.Column="2" Style="{StaticResource ComboBox_Setting}" <ComboBox Grid.Row="1" Grid.Column="2" Style="{StaticResource ComboBox_Setting}"
Margin="10,0,10,0" Height="30" Margin="10,0,10,0" Height="30"
ItemsSource="{Binding Path=GPIO_Pin_List}" ItemsSource="{Binding Path=GPIO_Pin_List}"
SelectedValue="{Binding Path=TallyInfo4.PinIndex2,Mode=TwoWay}"></ComboBox> SelectedValue="{Binding Path=TallyInfo4.PinIndex2,Mode=TwoWay}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Index}" Foreground="White" FontSize="12"></TextBlock>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<fcommon:ColorPickButton Grid.Row="0" Grid.Column="4" Height="30" Width="60" <fcommon:ColorPickButton Grid.Row="0" Grid.Column="4" Height="30" Width="60"
Color="{Binding Path=TallyInfo4.Color1,Mode=TwoWay}"></fcommon:ColorPickButton> Color="{Binding Path=TallyInfo4.Color1,Mode=TwoWay}"></fcommon:ColorPickButton>
<fcommon:ColorPickButton Grid.Row="1" Grid.Column="4" Height="30" Width="60" <fcommon:ColorPickButton Grid.Row="1" Grid.Column="4" Height="30" Width="60"
...@@ -183,32 +231,10 @@ ...@@ -183,32 +231,10 @@
<!-- 引脚状态 --> <!-- 引脚状态 -->
<TextBlock Text="GPIO引脚状态" Grid.Row="2" Foreground="White" FontSize="20" VerticalAlignment="Center"></TextBlock> <TextBlock Text="GPIO引脚状态" Grid.Row="2" Foreground="White" FontSize="20" VerticalAlignment="Center"></TextBlock>
<Rectangle Grid.Row="2" Height="1" VerticalAlignment="Bottom" Fill="#ff3d4758"></Rectangle> <Rectangle Grid.Row="2" Height="1" VerticalAlignment="Bottom" Fill="#ff3d4758"></Rectangle>
<Grid Grid.Row="3"> <Button Grid.Column="2" Style="{StaticResource Button_Setting}" Width="140" Height="30"
<Grid.RowDefinitions> Grid.Row="3" HorizontalAlignment="Right" Content="初始化Tally"
<RowDefinition Height="60"></RowDefinition> Command="{Binding Path=InitTallyCommand,Mode=OneWay}"></Button>
<RowDefinition Height="60"></RowDefinition> <fcommon:GPIOPinTestControl Grid.Row="4" Height="140" GPIOModel="{Binding GPIOModel,Mode=OneWay}"></fcommon:GPIOPinTestControl>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="120"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Text="设备" Foreground="White" FontSize="18" VerticalAlignment="Center" Grid.Row="0"></TextBlock>
<ComboBox Style="{StaticResource ComboBox_Setting}" Grid.Column="1" Height="40" Margin="0,0,20,0"
ItemsSource="{Binding Path=GPIOModels,Mode=OneWay}"
SelectedValue="{Binding Path=SelectedGPIOModel,Mode=TwoWay}">
<ComboBox.ItemTemplate>
<DataTemplate>
<Border Background="Transparent" IsHitTestVisible="False">
<TextBlock Text="{Binding DeviceInfo.FirmwareName}" Foreground="White" FontSize="16"></TextBlock>
</Border>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<Button Grid.Column="2" Style="{StaticResource Button_Setting}" Width="100" Height="30"
Content="扫描设备"></Button>
</Grid>
<fcommon:GPIOPinTestControl Grid.Row="4" Height="140"></fcommon:GPIOPinTestControl>
</Grid> </Grid>
</Border> </Border>
</UserControl> </UserControl>
...@@ -29,5 +29,13 @@ namespace VIZ.H2V.Module ...@@ -29,5 +29,13 @@ namespace VIZ.H2V.Module
{ {
return true; return true;
} }
/// <summary>
/// 取消
/// </summary>
public void Cancel()
{
}
} }
} }
...@@ -502,6 +502,14 @@ namespace VIZ.H2V.Module ...@@ -502,6 +502,14 @@ namespace VIZ.H2V.Module
return true; return true;
} }
/// <summary>
/// 取消
/// </summary>
public void Cancel()
{
}
// ====================================================================================== // ======================================================================================
// === Prviate Function === // === Prviate Function ===
// ====================================================================================== // ======================================================================================
......
...@@ -22,5 +22,10 @@ namespace VIZ.H2V.Module ...@@ -22,5 +22,10 @@ namespace VIZ.H2V.Module
/// </summary> /// </summary>
/// <returns>是否成功保存</returns> /// <returns>是否成功保存</returns>
bool Save(); bool Save();
/// <summary>
/// 取消
/// </summary>
void Cancel();
} }
} }
...@@ -303,5 +303,13 @@ namespace VIZ.H2V.Module ...@@ -303,5 +303,13 @@ namespace VIZ.H2V.Module
// 返回 // 返回
return true; return true;
} }
/// <summary>
/// 取消
/// </summary>
public void Cancel()
{
}
} }
} }
...@@ -141,6 +141,11 @@ namespace VIZ.H2V.Module ...@@ -141,6 +141,11 @@ namespace VIZ.H2V.Module
/// </summary> /// </summary>
private void Cancel() private void Cancel()
{ {
foreach (ISystemSetting setting in this.Settings)
{
setting.Cancel();
}
this.GetWindow().Close(); this.GetWindow().Close();
} }
......
...@@ -8,17 +8,21 @@ using System.Windows; ...@@ -8,17 +8,21 @@ using System.Windows;
using VIZ.Framework.Core; using VIZ.Framework.Core;
using VIZ.H2V.Domain; using VIZ.H2V.Domain;
using VIZ.H2V.Storage; using VIZ.H2V.Storage;
using VIZ.Framework.Common;
namespace VIZ.H2V.Module namespace VIZ.H2V.Module
{ {
/// <summary> /// <summary>
/// Tally设置面板视图模型 /// Tally设置面板视图模型
/// </summary> /// </summary>
public class TallySettingPanelViewModel : ViewModelBase, ISystemSetting public class TallySettingPanelViewModel : ViewModelBase, ISystemSetting, IGpioSupport
{ {
public TallySettingPanelViewModel() public TallySettingPanelViewModel()
{ {
this.LoadedCommand = new VCommand(this.Loaded); 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 ...@@ -30,13 +34,18 @@ namespace VIZ.H2V.Module
/// </summary> /// </summary>
private SystemConfig SystemConfig; private SystemConfig SystemConfig;
/// <summary>
/// GPIO控制器
/// </summary>
private GpioController GpioController;
// ====================================================================================== // ======================================================================================
// === Property === // === Property ===
// ====================================================================================== // ======================================================================================
#region TallyInfo1 -- Tally信号 -- 窗口1 #region TallyInfo1 -- Tally信号 -- 窗口1
private TallyCamSignalModel tallyInfo1 = new TallyCamSignalModel(); private TallyCamSignalModel tallyInfo1 = new TallyCamSignalModel(NDIViewKeys.CAM_1);
/// <summary> /// <summary>
/// Tally信号 -- 窗口1 /// Tally信号 -- 窗口1
/// </summary> /// </summary>
...@@ -50,7 +59,7 @@ namespace VIZ.H2V.Module ...@@ -50,7 +59,7 @@ namespace VIZ.H2V.Module
#region TallyInfo2 -- Tally信号 -- 窗口2 #region TallyInfo2 -- Tally信号 -- 窗口2
private TallyCamSignalModel tallyInfo2 = new TallyCamSignalModel(); private TallyCamSignalModel tallyInfo2 = new TallyCamSignalModel(NDIViewKeys.CAM_2);
/// <summary> /// <summary>
/// Tally信号 -- 窗口2 /// Tally信号 -- 窗口2
/// </summary> /// </summary>
...@@ -64,7 +73,7 @@ namespace VIZ.H2V.Module ...@@ -64,7 +73,7 @@ namespace VIZ.H2V.Module
#region TallyInfo3 -- Tally信号 -- 窗口3 #region TallyInfo3 -- Tally信号 -- 窗口3
private TallyCamSignalModel tallyInfo3 = new TallyCamSignalModel(); private TallyCamSignalModel tallyInfo3 = new TallyCamSignalModel(NDIViewKeys.CAM_3);
/// <summary> /// <summary>
/// Tally信号 -- 窗口3 /// Tally信号 -- 窗口3
/// </summary> /// </summary>
...@@ -78,7 +87,7 @@ namespace VIZ.H2V.Module ...@@ -78,7 +87,7 @@ namespace VIZ.H2V.Module
#region TallyInfo4 -- Tally信号 -- 窗口4 #region TallyInfo4 -- Tally信号 -- 窗口4
private TallyCamSignalModel tallyInfo4 = new TallyCamSignalModel(); private TallyCamSignalModel tallyInfo4 = new TallyCamSignalModel(NDIViewKeys.CAM_4);
/// <summary> /// <summary>
/// Tally信号 -- 窗口4 /// Tally信号 -- 窗口4
/// </summary> /// </summary>
...@@ -90,41 +99,27 @@ namespace VIZ.H2V.Module ...@@ -90,41 +99,27 @@ namespace VIZ.H2V.Module
#endregion #endregion
#region GPIOModels -- GPIO模型集合 #region GPIOModel -- GPIO模型
private List<GPIOModel> gpioModels; private GPIOModel gpioModel;
/// <summary> /// <summary>
/// GPIO模型集合 /// GPIO模型
/// </summary> /// </summary>
public List<GPIOModel> GPIOModels public GPIOModel GPIOModel
{ {
get { return gpioModels; } get { return gpioModel; }
set { gpioModels = value; this.RaisePropertyChanged(nameof(GPIOModels)); } set { gpioModel = value; this.RaisePropertyChanged(nameof(GPIOModel)); }
}
#endregion
#region SelectedGPIOModel -- 选中的GPIO模型
private GPIOModel selectedGPIOModel;
/// <summary>
/// 选中的GPIO模型
/// </summary>
public GPIOModel SelectedGPIOModel
{
get { return selectedGPIOModel; }
set { selectedGPIOModel = value; this.RaisePropertyChanged(nameof(SelectedGPIOModel)); }
} }
#endregion #endregion
#region GPIO_Pin_List -- GPIO引脚列表 #region GPIO_Pin_List -- GPIO引脚列表
private List<int?> gpio_pin_list; private List<GPIOPinModel> gpio_pin_list;
/// <summary> /// <summary>
/// GPIO引脚列表 /// GPIO引脚列表
/// </summary> /// </summary>
public List<int?> GPIO_Pin_List public List<GPIOPinModel> GPIO_Pin_List
{ {
get { return gpio_pin_list; } get { return gpio_pin_list; }
set { gpio_pin_list = value; this.RaisePropertyChanged(nameof(GPIO_Pin_List)); } set { gpio_pin_list = value; this.RaisePropertyChanged(nameof(GPIO_Pin_List)); }
...@@ -148,19 +143,17 @@ namespace VIZ.H2V.Module ...@@ -148,19 +143,17 @@ namespace VIZ.H2V.Module
/// </summary> /// </summary>
private void Loaded() private void Loaded()
{ {
if (this.IsAlreadyLoaded)
return;
SystemSettingViewModel vm = WPFHelper.GetAncestorByType<SystemSettingView>(this.GetView<FrameworkElement>()).DataContext as SystemSettingViewModel; SystemSettingViewModel vm = WPFHelper.GetAncestorByType<SystemSettingView>(this.GetView<FrameworkElement>()).DataContext as SystemSettingViewModel;
vm.Settings.Add(this); vm.Settings.Add(this);
this.SystemConfig = vm.SystemConfig; this.SystemConfig = vm.SystemConfig;
List<int?> pin_list = new List<int?>(); List<GPIOPinModel> pinModels = GPIOManager.GetPinModels();
pin_list.Add(null); pinModels.Insert(0, new GPIOPinModel() { Index = null, PinMask = GPIOPin.PIN_DEFAULT_VALUE });
for (int i = 0; i <= 15; i++) this.GPIO_Pin_List = pinModels;
{
pin_list.Add(i);
}
this.GPIO_Pin_List = pin_list;
this.loadTallyInfo(this.TallyInfo1, this.SystemConfig.TallyInfo1); this.loadTallyInfo(this.TallyInfo1, this.SystemConfig.TallyInfo1);
this.loadTallyInfo(this.TallyInfo2, this.SystemConfig.TallyInfo2); this.loadTallyInfo(this.TallyInfo2, this.SystemConfig.TallyInfo2);
...@@ -168,8 +161,27 @@ namespace VIZ.H2V.Module ...@@ -168,8 +161,27 @@ namespace VIZ.H2V.Module
this.loadTallyInfo(this.TallyInfo4, this.SystemConfig.TallyInfo4); this.loadTallyInfo(this.TallyInfo4, this.SystemConfig.TallyInfo4);
// GPIO模型 // GPIO模型
this.GPIOModels = GPIOManager.Models; this.GPIOModel = ApplicationDomainEx.GPIOModel;
this.SelectedGPIOModel = this.GPIOModels?.FirstOrDefault();
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 #endregion
...@@ -211,17 +223,38 @@ namespace VIZ.H2V.Module ...@@ -211,17 +223,38 @@ namespace VIZ.H2V.Module
ApplicationDomainEx.LiteDbContext.SystemConfig.Update(this.SystemConfig); ApplicationDomainEx.LiteDbContext.SystemConfig.Update(this.SystemConfig);
// 应用 // 应用
//ApplicationDomainEx.ServiceManager.GetServiceList<INDIViewService>().ForEach(p => ApplicationDomainEx.ServiceManager.GetServiceList<INDIViewService>().ForEach(p =>
//{ {
// p.LoadStyle(); switch (p.ViewConfig.ViewKey)
// p.LoadClipBoxSmooth(this.ManualSmoothCoeff); {
//}); 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; return true;
} }
/// <summary> /// <summary>
/// 取消
/// </summary>
public void Cancel()
{
}
/// <summary>
/// 加载Tally信息 /// 加载Tally信息
/// </summary> /// </summary>
/// <param name="model">模型</param> /// <param name="model">模型</param>
...@@ -229,8 +262,8 @@ namespace VIZ.H2V.Module ...@@ -229,8 +262,8 @@ namespace VIZ.H2V.Module
private void loadTallyInfo(TallyCamSignalModel model, TallyInfo entity) private void loadTallyInfo(TallyCamSignalModel model, TallyInfo entity)
{ {
// CAM 2 // CAM 2
model.PinIndex1 = entity.PinIndex1; model.PinIndex1 = this.GPIO_Pin_List.FirstOrDefault(p => p.Index == entity.PinIndex1);
model.PinIndex2 = entity.PinIndex2; model.PinIndex2 = this.GPIO_Pin_List.FirstOrDefault(p => p.Index == entity.PinIndex2);
model.Color1 = (Color)ColorConverter.ConvertFromString(entity.Color1); model.Color1 = (Color)ColorConverter.ConvertFromString(entity.Color1);
model.Color2 = (Color)ColorConverter.ConvertFromString(entity.Color2); model.Color2 = (Color)ColorConverter.ConvertFromString(entity.Color2);
} }
...@@ -243,9 +276,9 @@ namespace VIZ.H2V.Module ...@@ -243,9 +276,9 @@ namespace VIZ.H2V.Module
/// <returns>是否需要保存TallyInfo信息</returns> /// <returns>是否需要保存TallyInfo信息</returns>
private bool isTallyInfoNeedSave(TallyCamSignalModel model, TallyInfo entity) private bool isTallyInfoNeedSave(TallyCamSignalModel model, TallyInfo entity)
{ {
if (model.PinIndex1 != entity.PinIndex1) if (model.PinIndex1.Index != entity.PinIndex1)
return true; return true;
if (model.PinIndex2 != entity.PinIndex2) if (model.PinIndex2.Index != entity.PinIndex2)
return true; return true;
if (model.Color1.ToString() != entity.Color1) if (model.Color1.ToString() != entity.Color1)
return true; return true;
...@@ -262,8 +295,8 @@ namespace VIZ.H2V.Module ...@@ -262,8 +295,8 @@ namespace VIZ.H2V.Module
/// <param name="entity">实体</param> /// <param name="entity">实体</param>
private void saveTallyInfo(TallyCamSignalModel model, TallyInfo entity) private void saveTallyInfo(TallyCamSignalModel model, TallyInfo entity)
{ {
entity.PinIndex1 = model.PinIndex1; entity.PinIndex1 = model.PinIndex1.Index;
entity.PinIndex2 = model.PinIndex2; entity.PinIndex2 = model.PinIndex2.Index;
entity.Color1 = model.Color1.ToString(); entity.Color1 = model.Color1.ToString();
entity.Color2 = model.Color2.ToString(); entity.Color2 = model.Color2.ToString();
} }
......
...@@ -252,7 +252,9 @@ ...@@ -252,7 +252,9 @@
<Compile Include="NDIView\VieweModel\NDIViewModel.Message.cs" /> <Compile Include="NDIView\VieweModel\NDIViewModel.Message.cs" />
<Compile Include="NDIView\VieweModel\NDIViewModel.Property.cs" /> <Compile Include="NDIView\VieweModel\NDIViewModel.Property.cs" />
<Compile Include="NDIView\VieweModel\NDIViewModel.cs" /> <Compile Include="NDIView\VieweModel\NDIViewModel.cs" />
<Compile Include="NDIView\VieweModel\Part\NDIViewTallyPartViewModel.cs" />
<Compile Include="NDIView\VieweModel\Part\NDIViewToolPartViewModel.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_Navigation3DConfig.cs" />
<Compile Include="Setup\Provider\AppSetup_Algorithm.cs" /> <Compile Include="Setup\Provider\AppSetup_Algorithm.cs" />
<Compile Include="Setup\Provider\AppSetup_Recording.cs" /> <Compile Include="Setup\Provider\AppSetup_Recording.cs" />
......
...@@ -39,6 +39,8 @@ namespace VIZ.H2V ...@@ -39,6 +39,8 @@ namespace VIZ.H2V
AppSetup.AppendLoad(new AppSetup_Monitor()); AppSetup.AppendLoad(new AppSetup_Monitor());
// 初始化3D鼠标 // 初始化3D鼠标
AppSetup.AppendLoad(new AppSetup_Navigation3D()); AppSetup.AppendLoad(new AppSetup_Navigation3D());
// 初始化Tally
AppSetup.AppendLoad(new AppSetup_GPIO2USB());
// 保存居中模式裁切框 // 保存居中模式裁切框
AppSetup.AppendLoad(new AppSetup_SaveCenterClipBox()); 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