Commit e38b649c by liulongfei

命令测试

parent ff4e2d8b
...@@ -36,6 +36,11 @@ namespace VIZ.TVP.Domain ...@@ -36,6 +36,11 @@ namespace VIZ.TVP.Domain
public static TVPConnectionManager TVPConnectionManager { get; private set; } = new TVPConnectionManager(); public static TVPConnectionManager TVPConnectionManager { get; private set; } = new TVPConnectionManager();
/// <summary> /// <summary>
/// 选择管理器
/// </summary>
public static SelectionManager SelectionManager { get; private set; } = new SelectionManager();
/// <summary>
/// 当前项目领域 /// 当前项目领域
/// </summary> /// </summary>
public static ProjectDomain CurrentProjectDomain { get; set; } public static ProjectDomain CurrentProjectDomain { get; set; }
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.TVP.Domain
{
/// <summary>
/// 选择管理器
/// </summary>
public class SelectionManager
{
/// <summary>
/// 当前选中的节目单项目模型
/// </summary>
public ProgramListItemModel ProgramListItemModel { get; set; }
}
}
...@@ -13,6 +13,11 @@ namespace VIZ.TVP.Domain ...@@ -13,6 +13,11 @@ namespace VIZ.TVP.Domain
public class TVPConnectionManager : IDisposable public class TVPConnectionManager : IDisposable
{ {
/// <summary> /// <summary>
/// 本地连接
/// </summary>
public TVPConnectionModel LocalConnection { get; set; }
/// <summary>
/// 连接分组集合 /// 连接分组集合
/// </summary> /// </summary>
public ObservableCollection<TVPConnectionGroupModel> ConnectionGroups { get; set; } public ObservableCollection<TVPConnectionGroupModel> ConnectionGroups { get; set; }
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.TVP.Domain
{
/// <summary>
/// 节目单项改变消息
/// </summary>
public class ProgramListItemChangedMessage
{
/// <summary>
/// 节目单项模型
/// </summary>
public ProgramListItemModel ProgramListItemModel { get; set; }
}
}
...@@ -84,6 +84,31 @@ namespace VIZ.TVP.Domain ...@@ -84,6 +84,31 @@ namespace VIZ.TVP.Domain
#endregion #endregion
#region SelectedItem -- 当前选中的子项
private ProgramListItemModel selectedItem;
/// <summary>
/// 当前选中的子项
/// </summary>
public ProgramListItemModel SelectedItem
{
get { return selectedItem; }
set
{
selectedItem = value;
this.RaisePropertyChanged(nameof(SelectedItem));
ApplicationDomainEx.SelectionManager.ProgramListItemModel = value;
ProgramListItemChangedMessage msg = new ProgramListItemChangedMessage();
msg.ProgramListItemModel = value;
ApplicationDomainEx.MessageManager.Send(msg);
}
}
#endregion
/// <summary> /// <summary>
/// 从实体中获取属性 /// 从实体中获取属性
/// </summary> /// </summary>
......
...@@ -76,8 +76,10 @@ ...@@ -76,8 +76,10 @@
<Compile Include="Enum\ServiceKeys.cs" /> <Compile Include="Enum\ServiceKeys.cs" />
<Compile Include="Manager\DataBaseManager.cs" /> <Compile Include="Manager\DataBaseManager.cs" />
<Compile Include="Manager\PluginManager.cs" /> <Compile Include="Manager\PluginManager.cs" />
<Compile Include="Manager\SelectionManager.cs" />
<Compile Include="Manager\TVPConnectionManager.cs" /> <Compile Include="Manager\TVPConnectionManager.cs" />
<Compile Include="Manager\WindowManager.cs" /> <Compile Include="Manager\WindowManager.cs" />
<Compile Include="Message\Program\ProgramListItemChangedMessage.cs" />
<Compile Include="Message\Project\ProjectChangedMessage.cs" /> <Compile Include="Message\Project\ProjectChangedMessage.cs" />
<Compile Include="Message\Project\ProjectSaveMessage.cs" /> <Compile Include="Message\Project\ProjectSaveMessage.cs" />
<Compile Include="Model\Project\Program\ProgramListItemModel.cs" /> <Compile Include="Model\Project\Program\ProgramListItemModel.cs" />
......
...@@ -160,7 +160,8 @@ ...@@ -160,7 +160,8 @@
<Setter Property="ContentTemplate"> <Setter Property="ContentTemplate">
<Setter.Value> <Setter.Value>
<DataTemplate> <DataTemplate>
<dxg:GridControl ItemsSource="{Binding Items}" ShowBorder="False" IsFilterEnabled="False"> <dxg:GridControl ItemsSource="{Binding Items}" ShowBorder="False" IsFilterEnabled="False"
SelectedItem="{Binding Path=SelectedItem,Mode=TwoWay}">
<dxg:GridControl.Columns> <dxg:GridControl.Columns>
<dxg:GridColumn Header="序号" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False" Width="40" AllowResizing="False"> <dxg:GridColumn Header="序号" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False" Width="40" AllowResizing="False">
<dxg:GridColumn.CellTemplate> <dxg:GridColumn.CellTemplate>
......
...@@ -155,7 +155,18 @@ namespace VIZ.TVP.Module ...@@ -155,7 +155,18 @@ namespace VIZ.TVP.Module
public ProgramListModel SelectedProgramListModel public ProgramListModel SelectedProgramListModel
{ {
get { return selectedProgramListModel; } get { return selectedProgramListModel; }
set { selectedProgramListModel = value; this.RaisePropertyChanged(nameof(SelectedProgramListModel)); } set
{
selectedProgramListModel = value;
this.RaisePropertyChanged(nameof(SelectedProgramListModel));
ApplicationDomainEx.SelectionManager.ProgramListItemModel = value == null ? null : value.SelectedItem;
ProgramListItemChangedMessage msg = new ProgramListItemChangedMessage();
msg.ProgramListItemModel = value == null ? null : value.SelectedItem;
ApplicationDomainEx.MessageManager.Send(msg);
}
} }
#endregion #endregion
......
...@@ -47,9 +47,9 @@ namespace VIZ.TVP.Module ...@@ -47,9 +47,9 @@ namespace VIZ.TVP.Module
/// 启动VIZ引擎 /// 启动VIZ引擎
/// </summary> /// </summary>
/// <param name="view"></param> /// <param name="view"></param>
/// <param name="config">引擎配置</param> /// <param name="path">引擎路径</param>
/// <param name="connectionModel">连接模型</param> /// <param name="connectionModel">连接模型</param>
public void StartVizEngine(VizRenderView view, TVPEngineConfig config, TVPConnectionModel connectionModel) public void StartVizEngine(VizRenderView view, string path, TVPConnectionModel connectionModel)
{ {
this.Support.IsEngineReady = false; this.Support.IsEngineReady = false;
...@@ -63,11 +63,11 @@ namespace VIZ.TVP.Module ...@@ -63,11 +63,11 @@ namespace VIZ.TVP.Module
{ {
// Step 1. 启动进程 // Step 1. 启动进程
this.VizProcess = new Process(); this.VizProcess = new Process();
this.VizProcess.StartInfo.WorkingDirectory = System.IO.Path.GetDirectoryName(config.FullPath); this.VizProcess.StartInfo.WorkingDirectory = System.IO.Path.GetDirectoryName(path);
this.VizProcess.StartInfo.FileName = System.IO.Path.GetFileName(config.FullPath); this.VizProcess.StartInfo.FileName = System.IO.Path.GetFileName(path);
// " -o -P -db Guest:@localhost/VizDbServer:19396" // " -o -P -db Guest:@localhost/VizDbServer:19396"
LocalInfoEntity loginInfo = ApplicationDomainEx.DataBaseManager.LocalInfo; LocalInfoEntity loginInfo = ApplicationDomainEx.DataBaseManager.LocalInfo;
this.VizProcess.StartInfo.Arguments = $" -o -P -db {loginInfo.GH_UserName}:@{loginInfo.GH_IP}/{loginInfo.GH_ServerName}:{loginInfo.GH_Port}"; this.VizProcess.StartInfo.Arguments = $" -o -P -db {loginInfo.VIZ_UserName}:@{loginInfo.VIZ_IP}/{loginInfo.GH_ServerName}:{loginInfo.GH_Port}";
this.VizProcess.StartInfo.UseShellExecute = true; this.VizProcess.StartInfo.UseShellExecute = true;
this.VizProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal; this.VizProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
this.VizProcess.Start(); this.VizProcess.Start();
...@@ -93,6 +93,12 @@ namespace VIZ.TVP.Module ...@@ -93,6 +93,12 @@ namespace VIZ.TVP.Module
}); });
} while (vizHandle == IntPtr.Zero); } while (vizHandle == IntPtr.Zero);
// Step 4. 启动完成
WPFHelper.BeginInvoke(() =>
{
this.Support.IsEngineReady = true;
});
}); });
} }
} }
......
...@@ -19,9 +19,29 @@ ...@@ -19,9 +19,29 @@
<RowDefinition Height="*"></RowDefinition> <RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!-- 按钮组 --> <!-- 按钮组 -->
<Border Background="Red"> <Grid>
<Button Width="120" Height="30" Content="嵌入Viz" Command="{Binding Path=TestCommand}"></Button> <Grid.ColumnDefinitions>
</Border> <ColumnDefinition Width="auto"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center">
<Button Content="播放" Width="60" Height="30" Margin="10,0,0,0" Command="{Binding Path=PlayCommand}"></Button>
<Button Content="继续" Width="60" Height="30" Margin="10,0,0,0"></Button>
<Button Content="停止" Width="60" Height="30" Margin="10,0,0,0"></Button>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center">
<CheckBox Content="TA" Width="60" Height="30" Margin="10,0,0,0"></CheckBox>
<CheckBox Content="SA" Width="60" Height="30" Margin="10,0,0,0"></CheckBox>
<CheckBox Content="BB" Width="60" Height="30" Margin="10,0,0,0"></CheckBox>
<Rectangle Width="2" VerticalAlignment="Stretch" Fill="Red"></Rectangle>
<CheckBox Content="RGB" Width="60" Height="30" Margin="10,0,0,0"></CheckBox>
<CheckBox Content="Key" Width="60" Height="30" Margin="10,0,0,0"></CheckBox>
<CheckBox Content="KeyedPreveiew" Width="60" Height="30" Margin="10,0,0,0"></CheckBox>
</StackPanel>
</Grid>
<!-- VIZ引擎 --> <!-- VIZ引擎 -->
<fcommon:WindowHost x:Name="host" Grid.Row="1" Background="#ff252526" BackColor="#ff252526"> <fcommon:WindowHost x:Name="host" Grid.Row="1" Background="#ff252526" BackColor="#ff252526">
<dxmvvm:Interaction.Behaviors> <dxmvvm:Interaction.Behaviors>
......
...@@ -7,6 +7,7 @@ using VIZ.Framework.Core; ...@@ -7,6 +7,7 @@ using VIZ.Framework.Core;
using VIZ.Framework.Plugin; using VIZ.Framework.Plugin;
using VIZ.TVP.Connection; using VIZ.TVP.Connection;
using VIZ.TVP.Domain; using VIZ.TVP.Domain;
using VIZ.TVP.Service;
using VIZ.TVP.Storage; using VIZ.TVP.Storage;
using static VIZ.Framework.Core.WPFHelper; using static VIZ.Framework.Core.WPFHelper;
...@@ -33,8 +34,7 @@ namespace VIZ.TVP.Module ...@@ -33,8 +34,7 @@ namespace VIZ.TVP.Module
{ {
this.LoadedCommand = new VCommand(this.Loaded); this.LoadedCommand = new VCommand(this.Loaded);
this.WindowHostSizeChangedCommand = new VCommand<System.Windows.SizeChangedEventArgs>(this.WindowHostSizeChanged); this.WindowHostSizeChangedCommand = new VCommand<System.Windows.SizeChangedEventArgs>(this.WindowHostSizeChanged);
this.PlayCommand = new VCommand(this.Play);
this.TestCommand = new VCommand(this.Test);
} }
/// <summary> /// <summary>
...@@ -63,9 +63,8 @@ namespace VIZ.TVP.Module ...@@ -63,9 +63,8 @@ namespace VIZ.TVP.Module
#endregion #endregion
// ================================================================================ // ================================================================================
// Controller // Controller & Service
// ================================================================================ // ================================================================================
/// <summary> /// <summary>
...@@ -73,6 +72,11 @@ namespace VIZ.TVP.Module ...@@ -73,6 +72,11 @@ namespace VIZ.TVP.Module
/// </summary> /// </summary>
private VizController vizController; private VizController vizController;
/// <summary>
/// VIZ命令服务
/// </summary>
private IVizCommandService vizCommandService = new VizCommandService();
// ================================================================================ // ================================================================================
// Command // Command
// ================================================================================ // ================================================================================
...@@ -93,6 +97,26 @@ namespace VIZ.TVP.Module ...@@ -93,6 +97,26 @@ namespace VIZ.TVP.Module
return; return;
VizRenderView view = this.GetView<VizRenderView>(); VizRenderView view = this.GetView<VizRenderView>();
if (view == null)
return;
ThreadHelper.SafeRun(() =>
{
// 等待能正确获取到界面宽度时再嵌入VIZ引擎
double width = 0;
while (width == 0)
{
WPFHelper.Invoke(() =>
{
width = view.ActualWidth;
});
System.Threading.Thread.Sleep(500);
}
// 启动引擎
this.StartVizEngine();
});
this.IsAlreadyLoaded = true; this.IsAlreadyLoaded = true;
} }
...@@ -111,54 +135,42 @@ namespace VIZ.TVP.Module ...@@ -111,54 +135,42 @@ namespace VIZ.TVP.Module
/// </summary> /// </summary>
private void WindowHostSizeChanged(System.Windows.SizeChangedEventArgs e) private void WindowHostSizeChanged(System.Windows.SizeChangedEventArgs e)
{ {
if (this.connectionModel == null || !this.connectionModel.IsConnected) TVPConnectionModel local = ApplicationDomainEx.TVPConnectionManager.LocalConnection;
if (local == null || !local.IsConnected)
return; return;
var dpi = WPFHelper.GetDpiByGraphics(); var dpi = WPFHelper.GetDpiByGraphics();
int width = (int)(e.NewSize.Width * (dpi.X / 96d)); int width = (int)(e.NewSize.Width * (dpi.X / 96d));
int height = (int)(e.NewSize.Height * (dpi.Y / 96d)); int height = (int)(e.NewSize.Height * (dpi.Y / 96d));
this.connectionModel.EndpointManager.Send($"RENDERER WINDOW_RESIZE {width} {height}"); local.EndpointManager.Send($"RENDERER WINDOW_RESIZE {width} {height}");
} }
#endregion #endregion
#region TestCommand -- 测试命令 #region PlayCommand -- 播放命令
/// <summary> /// <summary>
/// 测试命令 /// 播放命令
/// </summary> /// </summary>
public VCommand TestCommand { get; set; } public VCommand PlayCommand { get; set; }
/// <summary> /// <summary>
/// 测试 /// 播放
/// </summary> /// </summary>
private void Test() private void Play()
{ {
VizRenderView view = this.GetView<VizRenderView>(); // 引擎未准备好 || 当前没有选中的节目单项目 则不处理
if (!this.IsEngineReady || ApplicationDomainEx.SelectionManager.ProgramListItemModel == null)
// -------------------------------------------------------------------- return;
// 测试代码
// --------------------------------------------------------------------
//TVPEngineConfig config = new TVPEngineConfig();
//config.Name = "测试VIZ引擎";
//config.EngineType = TVPEngineType.VIZ;
//config.FullPath = @"D:\Program Files (x86)\Vizrt\Viz3\viz.exe";
////config.FullPath = @"C:\Program Files\Vizrt\Viz3\viz.exe";
//// --------------------------------------------------------------------
//// Step 2. 等待发送命令
//this.connectionModel = new TVPConnectionModel();
//connectionModel.ID = "test";
//connectionModel.InitEndpointManager(new VizEndpointManager("test", "localhost", 6100));
//this.vizController.StartVizEngine(view, config, this.connectionModel); TVPConnectionModel conn = ApplicationDomainEx.TVPConnectionManager.LocalConnection;
ProgramListItemModel item = ApplicationDomainEx.SelectionManager.ProgramListItemModel;
this.vizCommandService.Start(conn, item.SceneName, VizLayerEnum.MAIN_LAYER);
} }
private TVPConnectionModel connectionModel;
#endregion #endregion
// ================================================================================ // ================================================================================
...@@ -166,6 +178,38 @@ namespace VIZ.TVP.Module ...@@ -166,6 +178,38 @@ namespace VIZ.TVP.Module
// ================================================================================ // ================================================================================
/// <summary> /// <summary>
/// 启动VIZ引擎
/// </summary>
public void StartVizEngine()
{
VizRenderView view = this.GetView<VizRenderView>();
if (view == null)
return;
LocalInfoEntity info = ApplicationDomainEx.DataBaseManager.LocalInfo;
TVPConnectionModel local = ApplicationDomainEx.TVPConnectionManager.LocalConnection;
if (local != null)
{
local.Dispose();
}
local = new TVPConnectionModel(new TVPConnectionEntity());
local.InitEndpointManager(new VizEndpointManager("local", info.VIZ_IP, info.VIZ_Port));
ApplicationDomainEx.TVPConnectionManager.LocalConnection = local;
string path = null;
switch (info.LocalEngineType)
{
case LocalEngineType.Eng3: path = info.VIZ_Eng3Path; break;
case LocalEngineType.Eng4: path = info.VIZ_Eng4Path; break;
}
this.vizController.StartVizEngine(view, path, local);
}
/// <summary>
/// 销毁 /// 销毁
/// </summary> /// </summary>
public override void Dispose() public override void Dispose()
......
...@@ -77,6 +77,8 @@ ...@@ -77,6 +77,8 @@
<Compile Include="Program\Implementation\ProgramService.cs" /> <Compile Include="Program\Implementation\ProgramService.cs" />
<Compile Include="Program\Interface\IProgramService.cs" /> <Compile Include="Program\Interface\IProgramService.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="VIZ\Implementation\VizCommandService.cs" />
<Compile Include="VIZ\Interface\IVizCommandService.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="packages.config" /> <None Include="packages.config" />
...@@ -103,9 +105,6 @@ ...@@ -103,9 +105,6 @@
<Name>VIZ.TVP.Storage</Name> <Name>VIZ.TVP.Storage</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup />
<Folder Include="VIZ\Implementation\" />
<Folder Include="VIZ\Interface\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.TVP.Domain;
using VIZ.TVP.Storage;
namespace VIZ.TVP.Service
{
/// <summary>
/// VIZ命令服务
/// </summary>
public class VizCommandService : IVizCommandService
{
/// <summary>
/// 播放
/// </summary>
/// <param name="connection">连接</param>
/// <param name="scene">场景</param>
/// <param name="layer">图层</param>
public void Start(TVPConnectionModel connection, string scene, VizLayerEnum layer)
{
if (connection == null)
throw new ArgumentNullException(nameof(connection));
if (layer == VizLayerEnum.RENDERER)
{
if (string.IsNullOrWhiteSpace(scene))
{
connection.EndpointManager.Send("RENDERER*STAGE START");
}
else
{
connection.EndpointManager.Send($"RENDERER*STAGE*DIRECTOR*{scene} START");
}
}
else
{
if (string.IsNullOrWhiteSpace(scene))
{
connection.EndpointManager.Send($"RENDERER*{layer}*STAGE START");
}
else
{
connection.EndpointManager.Send($"RENDERER SET_OBJECT SCENE*MyTestProject/Scenes/{scene}");
connection.EndpointManager.Send($"RENDERER*{layer}*STAGE*DIRECTOR*MyTestProject/Scenes/{scene} START");
//connection.EndpointManager.Send($"0 RENDERER*{layer}*STAGE*DIRECTOR*{scene} START");
}
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.TVP.Domain;
using VIZ.TVP.Storage;
namespace VIZ.TVP.Service
{
/// <summary>
/// VIZ命令服务
/// </summary>
public interface IVizCommandService
{
/// <summary>
/// 播放
/// </summary>
/// <param name="connection">连接</param>
/// <param name="scene">场景</param>
/// <param name="layer">图层</param>
void Start(TVPConnectionModel connection, string scene, VizLayerEnum layer);
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.TVP.Storage
{
/// <summary>
/// Viz引擎层
/// </summary>
public enum VizLayerEnum
{
/// <summary>
/// 前层
/// </summary>
[Description("前层")]
FRONT_LAYER,
/// <summary>
/// 主层
/// </summary>
[Description("主层")]
MAIN_LAYER,
/// <summary>
/// 背景层
/// </summary>
[Description("背景层")]
BACK_LAYER,
/// <summary>
/// 渲染层
/// </summary>
[Description("渲染层")]
RENDERER
}
}
...@@ -82,6 +82,7 @@ ...@@ -82,6 +82,7 @@
<Compile Include="LiteDB\Project\Program\ProgramListEntity.cs" /> <Compile Include="LiteDB\Project\Program\ProgramListEntity.cs" />
<Compile Include="LiteDB\Project\Program\ProgramTemplateEntity.cs" /> <Compile Include="LiteDB\Project\Program\ProgramTemplateEntity.cs" />
<Compile Include="LiteDB\Project\ProjectContext.cs" /> <Compile Include="LiteDB\Project\ProjectContext.cs" />
<Compile Include="LiteDB\VIZ\Enum\VizLayerEnum.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="XML\GH\Enum\GH_Category_Term_Enums.cs" /> <Compile Include="XML\GH\Enum\GH_Category_Term_Enums.cs" />
<Compile Include="XML\GH\Enum\GH_Content_Type_Enums.cs" /> <Compile Include="XML\GH\Enum\GH_Content_Type_Enums.cs" />
......
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