MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
MyCaffeGymUiProxy.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.ServiceModel;
5using System.ServiceModel.Description;
6using System.Text;
7using System.Threading.Tasks;
8
9namespace MyCaffe.gym
10{
14 public class MyCaffeGymUiProxy : DuplexClientBase<IXMyCaffeGymUiService>
15 {
16 object m_sync = new object();
17 bool m_bOpen = false;
18
24 public MyCaffeGymUiProxy(InstanceContext ctx, NetNamedPipeBinding binding = null)
25 : base(ctx, new ServiceEndpoint(ContractDescription.GetContract(typeof(IXMyCaffeGymUiService)),
26 (binding == null) ? new NetNamedPipeBinding() : binding, new EndpointAddress("net.pipe://localhost/MyCaffeGym/gymui")))
27 {
28 }
29
37 public int OpenUi(string strName, int nId, bool bStartRecording = false)
38 {
39 m_bOpen = true;
40 return Channel.OpenUi(strName, nId, bStartRecording);
41 }
42
47 public void CloseUi(int nId)
48 {
49 lock (m_sync)
50 {
51 Channel.CloseUi(nId);
52 m_bOpen = false;
53 }
54 }
55
61 public void Render(int nId, Observation obs)
62 {
63 try
64 {
65 lock (m_sync)
66 {
67 if (!m_bOpen)
68 return;
69
70 Channel.Render(nId, obs);
71 }
72 }
73 catch
74 {
75 }
76 }
77
83 public bool IsOpen(int nId)
84 {
85 return Channel.IsOpen(nId);
86 }
87 }
88}
The MyCaffeGymUiProxy is used to interact with the MyCaffeGymUiService.
int OpenUi(string strName, int nId, bool bStartRecording=false)
Open the Gym user interface.
void Render(int nId, Observation obs)
Render the observation of the Gym.
MyCaffeGymUiProxy(InstanceContext ctx, NetNamedPipeBinding binding=null)
The constructor.
bool IsOpen(int nId)
Returns whether or not the Gym user interface is visible or not.
void CloseUi(int nId)
Closes the Gym user interface.
The Observation contains data describing the Gym as it runs.
The IXMYCaffeGymUiService interface provides access to the MyCaffeGymUiService used to display the vi...
The MyCaffe.gym namespace contains all classes related to the Gym's supported by MyCaffe.