SECI  1
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events
ComInterface.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections;
3 using System.Collections.Generic;
4 using System.Text;
5 using System.Runtime.Remoting;
6 using System.Runtime.Remoting.Channels;
7 using System.Runtime.Remoting.Channels.Tcp;
8 using System.Runtime.Remoting.Channels.Http;
9 using System.Runtime.InteropServices;
10 
11 namespace Seci.Remoting
12 {
19  [GuidAttribute("EF9F3E43-AE19-40ea-B7DE-F21813975B8E"), ComVisible(true)]
20  [ClassInterface(ClassInterfaceType.None)]
21  public class ComInterface : IComInterface
22  {
23  private RegistrationServices _regServices;
24  private int _cookie;
25 
29  public ComInterface()
30  {
31  }
32 
36  public void InitialiseCom()
37  {
38  _regServices = new RegistrationServices();
39  _cookie = _regServices.RegisterTypeForComClients(typeof(ComInterface),
40  RegistrationClassContext.LocalServer | RegistrationClassContext.RemoteServer,
41  RegistrationConnectionType.MultipleUse);
42  }
43 
47  public void DisposeCom()
48  {
49  _regServices.UnregisterTypeForComClients(_cookie);
50  _regServices = null;
51  }
52 
53  #region IComInterface Members
54 
59  int IComInterface.AreYouThere()
60  {
61  return 0;
62  }
63 
69  String IComInterface.GetBlockValueString(String blockName)
70  {
71  return Bridge.GetBlockValue(blockName);
72  }
73 
79  String[] IComInterface.GetBlockNames(Boolean includeHidden)
80  {
81  return Bridge.GetBlockNames(includeHidden, true);
82  }
83 
89  object IComInterface.GetRawBlockValue(String blockname)
90  {
91  return Bridge.GetRawBlockValue(blockname);
92  }
93 
99  object IComInterface.GetRawSetpoint(String blockname)
100  {
101  return Bridge.GetRawSetpoint(blockname);
102  }
103 
110  Boolean IComInterface.SetRawBlockValue(String blockName, Object value)
111  {
112  return Bridge.SetRawBlockValue(blockName, value);
113  }
114 
115  Boolean IComInterface.UnderRunControl(string blockName)
116  {
117  return Bridge.UnderRunControl(blockName);
118  }
119 
120  Boolean IComInterface.SetRunControl(string blockName, bool value)
121  {
122  //Temporary testing hack that will be removed once we can set run-control via the instapi
123  Object[,] vals = (Object[,])Bridge.GetLabViewValue(Seci.Standard.DaeMonitor.FilePath, "Parameter details");
124  if (vals != null)
125  {
126  for (int i = 0; i < vals.GetLength(0); ++i)
127  {
128  if (vals[i, 0].ToString().ToLower() == blockName.ToLower())
129  {
130  vals[i, 7] = Convert.ToInt16(value).ToString();
131  Bridge.SetLabViewValue(Seci.Standard.DaeMonitor.FilePath, "Parameter details", vals);
132  return true;
133  }
134  }
135  }
136 
137  return false;
138  }
139 
140  void IComInterface.ClearGraphs()
141  {
142  Bridge.ClearGraphs();
143  }
144 
145  int IComInterface.ChangeConfiguration(String configName)
146  {
147  return Bridge.ChangeConfig(configName);
148  }
149 
150  String[] IComInterface.GetVIsFullpath()
151  {
152  return Bridge.GetVIsFullpath();
153  }
154 
155  String[] IComInterface.GetConfigurations()
156  {
157  return Bridge.GetListOfConfigs();
158  }
159 
160  Boolean IComInterface.IsSeciBusy()
161  {
162  return Bridge.IsBusy();
163  }
164 
165  void IComInterface.EnableBlocksLogging(Boolean enable)
166  {
167  Bridge.EnableBlocksLogging(enable);
168  }
169 
170  Boolean IComInterface.BlocksLoggingStatus()
171  {
172  return Bridge.BlocksLoggingStatus();
173  }
174 
175  #endregion
176  }
177 
181  [ComVisible(true)]
182  [InterfaceType(ComInterfaceType.InterfaceIsDual)]
183  public interface IComInterface
184  {
185  int AreYouThere();
186  String GetBlockValueString(String blockName);
187  String[] GetBlockNames(Boolean includeHidden);
188  object GetRawBlockValue(String blockname);
189  object GetRawSetpoint(String blockname);
190  Boolean SetRawBlockValue(String blockName, Object value);
191  Boolean UnderRunControl(String blockName);
192  Boolean SetRunControl(String blockName, Boolean value);
193  void ClearGraphs();
194  int ChangeConfiguration(String configName);
195  Boolean IsSeciBusy();
196  String[] GetConfigurations();
197  String[] GetVIsFullpath();
198  void EnableBlocksLogging(Boolean enable);
199  Boolean BlocksLoggingStatus();
200  }
201 }
static Object GetLabViewValue(String vi, String control)
Get value directly from LabVIEW with no checks or conversions.
Definition: Bridge.cs:22
ComInterface()
The constructor
Definition: ComInterface.cs:29
This class is for accessing Seci from an external source. All the COM and Remoting calls go through t...
Definition: Bridge.cs:12
void InitialiseCom()
Registers the interface with COM.
Definition: ComInterface.cs:36
RegistrationServices _regServices
Definition: ComInterface.cs:23
The exposed COM interface
void DisposeCom()
Unregisters the interface from COM.
Definition: ComInterface.cs:47
This class is for accessing Seci via COM. The COM interface is registered when Seci starts and unregi...
Definition: ComInterface.cs:21