OTX-Runtime for C++  
Runtime API Sample Program

The Sample program demonstrates the main functionality of the OTX-Runtime API. It can be used as a reference for the expected runtime behavior of the API and the source code below is like a reference guide about the proper programming of the API.

Code Example CPP-File

Code example (.\otxruntime\ReferenceApplication\src\Gui\SampleForm.cpp) of the OTX-Runtime API Sample Program.

1 #include "SampleForm.h"
2 using namespace OpenTestSystem::Otx::Runtime2::Api::Sample;
3 
4 #include "HmiWindow.h"
5 #include "LicenseForm.h"
6 #include "SampleConstants.h"
7 #include "Util/LicenseUtil.h"
8 #include "Util/Util.h"
9 #include "CallbackToAction.h"
10 #include "Setting/UserSettings.h"
11 #include "IpcTypes.h"
12 #include "Util/OtxDiagUtil.h"
13 
14 #include "OutputCustomImplementation/BasicScreenOutputImpl.h"
15 #include "OutputCustomImplementation/CommonDialogsOutputImpl.h"
16 #include "OutputCustomImplementation/ContextVariableOutputImpl.h"
17 #include "OutputCustomImplementation/CustomScreenOutputImpl.h"
18 #include "OutputCustomImplementation/ExternalServiceProviderOutputImpl.h"
19 #include "OutputCustomImplementation/I18nOutputImpl.h"
20 #include "OutputCustomImplementation/LoggingOutputImpl.h"
21 #include "OutputCustomImplementation/MeasureOutputImpl.h"
22 #include "OutputCustomImplementation/SqlOutputImpl.h"
23 #include "OutputCustomImplementation/StateVariableOutputImpl.h"
24 using namespace OpenTestSystem::Otx::Runtime2::Api::Sample::OutputCustomImplementation;
25 
26 #include <RuntimeManagerFactory.h>
27 #include <RuntimeConfig.h>
28 #include <License/LicenseManager.h>
29 #include <Project/IProject.h>
30 #include <Project/IPlayerProject.h>
31 #include <IRuntimeContext.h>
32 #include <DiagConnectionState.h>
33 #include <Otx/IProcedureParameter.h>
34 #include <Otx/IProcedureInOutParameter.h>
35 #include <Otx/IProcedureInParameter.h>
36 #include <Otx/IProcedureOutParameter.h>
37 #include <DataTypes/ValueConverter.h>
38 #include <Otx/IContextVariable.h>
39 #include <Otx/IStateVariable.h>
40 
41 #include <Custom/ICustomScreenImplementation.h>
42 #include <DefaultCustomScreenImplementation.h>
43 #include <WpfKeyEventArgs.h>
44 #include <FormKeyEventArgs.h>
45 #include <ContextVariableImplementation.h>
46 
47 #include <StateVariableImplementation.h>
48 #include <DefaultMeasureImplementation.h>
49 #include <DefaultExternalServiceProviderImplementation.h>
50 
51 #include <DataTypes/TranslationKey.h>
52 #include <DataTypes/EnumerationElement.h>
53 #include "Otx/Signature/IEnumerationSignature.h"
54 
55 #include <IOtxDiag.h>
56 #include <IDiagConfiguration.h>
57 
58 #include <msclr/auto_gcroot.h>
59 #include <msclr/lock.h>
60 #include <vector>
61 #include <map>
62 #include <memory>
63 
64 struct OpenTestSystem::Otx::Runtime2::Api::Sample::SampleFormImpl
65 {
66 public:
67  SampleFormImpl(msclr::auto_gcroot<SampleForm^> owner)
68  {
69  Owner = owner;
70 
71  _ProcedurePending = nullptr;
72  _ProcedureStarted = nullptr;
73  _ProcedurePaused = nullptr;
74  _ProcedureContinued = nullptr;
75  _ProcedureFinished = nullptr;
76  _ProcedureStopped = nullptr;
77  _ProcedureAborted = nullptr;
78  _ProcedureTimeout = nullptr;
79  _DiagConnectionStateChanged = nullptr;
80  _InOutParameterValueChanged = nullptr;
81 
82  _KeyDown = nullptr;
83  _ContextVariableRead = nullptr;
84 
85  CreatorForm = nullptr;
86  HmiWindow = nullptr;
87  WebServerTimer = nullptr;
88 
89  GlobalRuntimeManager = nullptr;
90  RuntimeContexts.clear();
91  LockRuntimeContexts = gcnew System::Object();
92  EventListenerLock = gcnew System::Object();
93  PrintTextLock = gcnew System::Object();
94 
95  RuntimeContextIdsExecutionStartTick.clear();
96 
97  ErrorProvider = nullptr;
98 
99  Project = nullptr;
100  PlayerProject = nullptr;
101  ProcedureToExecute = nullptr;
102 
103  StartUpNode = nullptr;
104 
105  ProcedureExecutionCount = 0;
106 
107  LastTime = System::DateTime::Now;
108 
109  Title = SampleConstants::MAIN_INSTANCE_NAME;
110 
111  UseConnectionState = false;
112 
113  IsPathChanging = false;
114 
115  IsLoadding = false;
116 
117  DefaultDiagPort = SampleConstants::DEFAULT_DM_PORT;
118  DefaultRuntimePort = SampleConstants::DEFAULT_RT_PORT;
119  DefaultDiagPipeName = SampleConstants::DEFAULT_DM_PIPE_NAME;
120  DefaultRuntimePipeName = SampleConstants::DEFAULT_RT_PIPE_NAME;
121 
122  IsStartWebSever = -1;
123  RuntimeContextName = "";
124  CyclicExecutionCount = 0;
125  CyclicExecuteAsyncIsProcessing = false;
126  ExpectedConnectionState = ExpectedState::None;
127 
128  KL15State = -1;
129 
130  CustomScreenImplementation = nullptr;
131  ContextVariableImplementation = nullptr;
132 
133  StateVariableImplementation = nullptr;
134  MeasureImplementation = nullptr;
135  ServiceProviderImplementation = nullptr;
136 
137  _BasicScreenOutputImpl = nullptr;
138  _CommonDialogsOutputImpl = nullptr;
139  _ContextVariableOutputImpl = nullptr;
140  _CustomScreenOutputImpl = nullptr;
141  _ServiceProviderOutputImpl = nullptr;
142  _I18nOutputImpl = nullptr;
143  _LoggingOutputImpl = nullptr;
144  _MeasureOutputImpl = nullptr;
145  _SqlOutputImpl = nullptr;
146  _StateVariableOutputImpl = nullptr;
147 
148  WebServerTimer = gcnew System::Windows::Forms::Timer();
149  ErrorProvider = gcnew System::Windows::Forms::ErrorProvider();
150  }
151 
152  static bool IsRegistered;
153  static std::string FileVersion;
154  static std::vector<msclr::auto_gcroot<SampleForm^>> ListForms;
155 
156  msclr::auto_gcroot<SampleForm^> CreatorForm;
157  msclr::auto_gcroot<HmiWindow^> HmiWindow;
158  msclr::auto_gcroot<System::Windows::Forms::Timer^> WebServerTimer;
159  msclr::auto_gcroot<System::DateTime^> LastTime;
160  std::shared_ptr<IRuntimeManager> GlobalRuntimeManager;
161  std::vector<OpenTestSystem::Otx::Runtime::Api::IRuntimeContext*> RuntimeContexts;
162  msclr::auto_gcroot<System::Object^> LockRuntimeContexts;
163  msclr::auto_gcroot<System::Object^> EventListenerLock;
164  msclr::auto_gcroot<System::Object^> PrintTextLock;
165  std::map<long long, long long> RuntimeContextIdsExecutionStartTick;
166  msclr::auto_gcroot<System::Windows::Forms::ErrorProvider^> ErrorProvider;
167 
168  std::shared_ptr<OpenTestSystem::Otx::Runtime::Api::Project::IProject> Project;
169  std::shared_ptr<OpenTestSystem::Otx::Runtime::Api::Project::IPlayerProject> PlayerProject;
170  std::shared_ptr<OpenTestSystem::Otx::Runtime::Api::Otx::IProcedure> ProcedureToExecute;
171 
172  msclr::auto_gcroot<System::Windows::Forms::TreeNode^> StartUpNode;
173 
174  long ProcedureExecutionCount;
175 
176  std::string Title;
177 
178  bool IsPathChanging;
179 
180  bool UseConnectionState;
181 
182  bool IsLoadding;
183 
184  int DefaultDiagPort;
185  int DefaultRuntimePort;
186  std::string DefaultDiagPipeName;
187  std::string DefaultRuntimePipeName;
188 
189  int IsStartWebSever;
190  std::string RuntimeContextName;
191  int CyclicExecutionCount;
192  bool CyclicExecuteAsyncIsProcessing;
193  ExpectedState ExpectedConnectionState;
194 
195  int KL15State; // There are 3 states -1, 0 and 1 which correspond to NULL, false and true in C#
196 
197  std::shared_ptr<Custom::DefaultCustomScreenImplementation> CustomScreenImplementation;
198  std::shared_ptr<Custom::ContextVariableImplementation> ContextVariableImplementation;
199 
200  std::shared_ptr<Custom::StateVariableImplementation> StateVariableImplementation;
201  std::shared_ptr<Custom::DefaultMeasureImplementation> MeasureImplementation;
202  std::shared_ptr<Custom::DefaultExternalServiceProviderImplementation> ServiceProviderImplementation;
203 
204  std::shared_ptr<BasicScreenOutputImpl> _BasicScreenOutputImpl;
205  std::shared_ptr<CommonDialogsOutputImpl> _CommonDialogsOutputImpl;
206  std::shared_ptr<ContextVariableOutputImpl> _ContextVariableOutputImpl;
207  std::shared_ptr<CustomScreenOutputImpl> _CustomScreenOutputImpl;
208  std::shared_ptr<ExternalServiceProviderOutputImpl> _ServiceProviderOutputImpl;
209  std::shared_ptr<I18nOutputImpl> _I18nOutputImpl;
210  std::shared_ptr<LoggingOutputImpl> _LoggingOutputImpl;
211  std::shared_ptr<MeasureOutputImpl> _MeasureOutputImpl;
212  std::shared_ptr<SqlOutputImpl> _SqlOutputImpl;
213  std::shared_ptr<StateVariableOutputImpl> _StateVariableOutputImpl;
214 
215  const int VALUE_STRING_MAX_LENGTH = 1024;
216  const int FORM_OFFSET = 25;
217  const int DEFAULT_POLLING_TIME = 500;
218  const int DEFAULT_BATTERY_VOLTAGE_THRESHOLD = 6000;
219 
220  void InitializeRuntimeEvents(std::shared_ptr<IRuntimeManager> runtimeManager)
221  {
222  if (runtimeManager == nullptr)
223  {
224  return;
225  }
226 
227  RemoveRuntimeEvents(runtimeManager);
228 
229  _ProcedurePending = std::make_shared<std::function<void(const IRuntimeContext&)>>(std::bind(&SampleFormImpl::ProcedurePending, this, std::placeholders::_1));
230  _ProcedureStarted = std::make_shared<std::function<void(const IRuntimeContext&)>>(std::bind(&SampleFormImpl::ProcedureStarted, this, std::placeholders::_1));
231  _ProcedurePaused = std::make_shared<std::function<void(const IRuntimeContext&, ExecutionStateChangeReason)>>(std::bind(&SampleFormImpl::ProcedurePaused, this, std::placeholders::_1, std::placeholders::_2));
232  _ProcedureContinued = std::make_shared<std::function<void(const IRuntimeContext&)>>(std::bind(&SampleFormImpl::ProcedureContinued, this, std::placeholders::_1));
233  _ProcedureFinished = std::make_shared<std::function<void(const IRuntimeContext&)>>(std::bind(&SampleFormImpl::ProcedureFinished, this, std::placeholders::_1));
234  _ProcedureStopped = std::make_shared<std::function<void(const IRuntimeContext&)>>(std::bind(&SampleFormImpl::ProcedureStopped, this, std::placeholders::_1));
235  _ProcedureAborted = std::make_shared<std::function<void(const IRuntimeContext&)>>(std::bind(&SampleFormImpl::ProcedureAborted, this, std::placeholders::_1));
236  _ProcedureTimeout = std::make_shared<std::function<void(const IRuntimeContext&)>>(std::bind(&SampleFormImpl::ProcedureTimeout, this, std::placeholders::_1));
237  _DiagConnectionStateChanged = std::make_shared<std::function<void(ClampState, ClampState)>>(std::bind(&SampleFormImpl::DiagConnectionStateChanged, this, std::placeholders::_1, std::placeholders::_2));
238  _InOutParameterValueChanged = std::make_shared<std::function<void(const IRuntimeContext&, const IProcedureInOutParameter&)>>(std::bind(&SampleFormImpl::InOutParameterValueChanged, this, std::placeholders::_1, std::placeholders::_2));
239 
240  runtimeManager->AddProcedurePendingListener(_ProcedurePending);
241  runtimeManager->AddProcedureStartedListener(_ProcedureStarted);
242  runtimeManager->AddProcedurePausedListener(_ProcedurePaused);
243  runtimeManager->AddProcedureContinuedListener(_ProcedureContinued);
244  runtimeManager->AddProcedureFinishedListener(_ProcedureFinished);
245  runtimeManager->AddProcedureStoppedListener(_ProcedureStopped);
246  runtimeManager->AddProcedureAbortedListener(_ProcedureAborted);
247  runtimeManager->AddProcedureTimeoutListener(_ProcedureTimeout);
248  runtimeManager->AddDiagConnectionStateChangedListener(_DiagConnectionStateChanged);
249  runtimeManager->AddInOutParameterValueChangedListener(_InOutParameterValueChanged);
250  }
251 
252  void RemoveRuntimeEvents(std::shared_ptr<IRuntimeManager> runtimeManager)
253  {
254  if (_ProcedurePending != nullptr)
255  {
256  runtimeManager->RemoveProcedurePendingListener(_ProcedurePending);
257  }
258 
259  if (_ProcedureStarted != nullptr)
260  {
261  runtimeManager->RemoveProcedureStartedListener(_ProcedureStarted);
262  }
263 
264  if (_ProcedurePaused != nullptr)
265  {
266  runtimeManager->RemoveProcedurePausedListener(_ProcedurePaused);
267  }
268 
269  if (_ProcedureContinued != nullptr)
270  {
271  runtimeManager->RemoveProcedureContinuedListener(_ProcedureContinued);
272  }
273 
274  if (_ProcedureFinished != nullptr)
275  {
276  runtimeManager->RemoveProcedureFinishedListener(_ProcedureFinished);
277  }
278 
279  if (_ProcedureStopped != nullptr)
280  {
281  runtimeManager->RemoveProcedureStoppedListener(_ProcedureStopped);
282  }
283 
284  if (_ProcedureAborted != nullptr)
285  {
286  runtimeManager->RemoveProcedureAbortedListener(_ProcedureAborted);
287  }
288 
289  if (_ProcedureTimeout != nullptr)
290  {
291  runtimeManager->RemoveProcedureTimeoutListener(_ProcedureTimeout);
292  }
293 
294  if (_DiagConnectionStateChanged != nullptr)
295  {
296  runtimeManager->RemoveDiagConnectionStateChangedListener(_DiagConnectionStateChanged);
297  }
298 
299  if (_InOutParameterValueChanged != nullptr)
300  {
301  runtimeManager->RemoveInOutParameterValueChangedListener(_InOutParameterValueChanged);
302  }
303  }
304 
305  void ProcedurePending(const IRuntimeContext& context)
306  {
307  Owner->ProcedurePendingCallback(gcnew CLRWrapper<IRuntimeContext*>(const_cast<IRuntimeContext*>(&context)));
308  }
309 
310  void ProcedureStarted(const IRuntimeContext& context)
311  {
312  Owner->ProcedureStartedCallback(gcnew CLRWrapper<IRuntimeContext*>(const_cast<IRuntimeContext*>(&context)));
313  }
314 
315  void ProcedurePaused(const IRuntimeContext& context, ExecutionStateChangeReason reason)
316  {
317  IRuntimeContext* pContext = const_cast<IRuntimeContext*>(&context);
318  Owner->ProcedurePaused(pContext, reason);
319  }
320 
321  void ProcedureContinued(const IRuntimeContext& context)
322  {
323  Owner->ProcedureContinuedCallback(gcnew CLRWrapper<IRuntimeContext*>(const_cast<IRuntimeContext*>(&context)));
324  }
325 
326  void ProcedureFinished(const IRuntimeContext& context)
327  {
328  Owner->ProcedureFinishedCallback(gcnew CLRWrapper<IRuntimeContext*>(const_cast<IRuntimeContext*>(&context)));
329  }
330 
331  void ProcedureStopped(const IRuntimeContext& context)
332  {
333  Owner->ProcedureStoppedCallback(gcnew CLRWrapper<IRuntimeContext*>(const_cast<IRuntimeContext*>(&context)));
334  }
335 
336  void ProcedureAborted(const IRuntimeContext& context)
337  {
338  Owner->ProcedureAbortedCallback(gcnew CLRWrapper<IRuntimeContext*>(const_cast<IRuntimeContext*>(&context)));
339  }
340 
341  void ProcedureTimeout(const IRuntimeContext& context)
342  {
343  Owner->ProcedureTimeoutCallback(gcnew CLRWrapper<IRuntimeContext*>(const_cast<IRuntimeContext*>(&context)));
344  }
345 
346  void DiagConnectionStateChanged(ClampState batteryState, ClampState ignitionState)
347  {
348  Owner->DiagConnectionStateChanged(batteryState, ignitionState);
349  }
350 
351  void InOutParameterValueChanged(const IRuntimeContext& context, const IProcedureInOutParameter& parameter)
352  {
353  IRuntimeContext* pContext = const_cast<IRuntimeContext*>(&context);
354  IProcedureInOutParameter* pParameter = const_cast<IProcedureInOutParameter*>(&parameter);
355  Owner->InOutParameterValueChanged(pContext, pParameter);
356  }
357 
358  void SetDefaultCustomImplementation(std::shared_ptr<IRuntimeManager> runtimeManager)
359  {
360  if (runtimeManager == nullptr)
361  {
362  return;
363  }
364 
365  runtimeManager->SetCustomImplementation((std::shared_ptr<Custom::IBasicScreenImplementation>)nullptr);
366  runtimeManager->SetCustomImplementation(CustomScreenImplementation);
367  runtimeManager->SetCustomImplementation((std::shared_ptr<Custom::ILoggingImplementation>)nullptr);
368  runtimeManager->SetCustomImplementation(ContextVariableImplementation);
369 
370  runtimeManager->SetCustomImplementation(StateVariableImplementation);
371  runtimeManager->SetCustomImplementation(MeasureImplementation);
372  runtimeManager->SetCustomImplementation((std::shared_ptr<Custom::Ii18nImplementation>)nullptr);
373  runtimeManager->SetCustomImplementation(ServiceProviderImplementation);
374 
375  runtimeManager->SetCustomImplementation((std::shared_ptr<Custom::ISqlImplementation>)nullptr);
376  runtimeManager->SetCustomImplementation((std::shared_ptr<Custom::ICommonDialogsImplementation>)nullptr);
377  }
378 
379  void RemoveCustomImplementation(std::shared_ptr<IRuntimeManager> runtimeManager)
380  {
381  if (runtimeManager == nullptr)
382  {
383  return;
384  }
385 
386  runtimeManager->SetCustomImplementation((std::shared_ptr<Custom::IBasicScreenImplementation>)nullptr);
387  runtimeManager->SetCustomImplementation((std::shared_ptr<Custom::ICustomScreenImplementation>)nullptr);
388  runtimeManager->SetCustomImplementation((std::shared_ptr<Custom::ICommonDialogsImplementation>)nullptr);
389  runtimeManager->SetCustomImplementation((std::shared_ptr<Custom::IContextVariableImplementation>)nullptr);
390  runtimeManager->SetCustomImplementation((std::shared_ptr<Custom::IExternalServiceProviderImplementation>)nullptr);
391  runtimeManager->SetCustomImplementation((std::shared_ptr<Custom::Ii18nImplementation>)nullptr);
392  runtimeManager->SetCustomImplementation((std::shared_ptr<Custom::ILoggingImplementation>)nullptr);
393  runtimeManager->SetCustomImplementation((std::shared_ptr<Custom::IMeasureImplementation>)nullptr);
394  runtimeManager->SetCustomImplementation((std::shared_ptr<Custom::ISqlImplementation>)nullptr);
395  runtimeManager->SetCustomImplementation((std::shared_ptr<Custom::IStateVariableImplementation>)nullptr);
396  }
397 
398  void ClearCustomImplemetationCaches()
399  {
400  if (IS_NOT_NULL(ContextVariableImplementation))
401  {
402  ContextVariableImplementation->ResetAllValues();
403  }
404 
405  if (IS_NOT_NULL(_ContextVariableOutputImpl))
406  {
407  _ContextVariableOutputImpl->ResetAllValues();
408  }
409 
410  if (IS_NOT_NULL(StateVariableImplementation))
411  {
412  StateVariableImplementation->ResetAllValues();
413  }
414 
415  //TODO: if (StateVariableOutputImpl != null)
416  }
417 
418  void CreateDefaultCustomImpl()
419  {
420  CustomScreenImplementation = std::make_shared<Custom::DefaultCustomScreenImplementation>();
421  _KeyDown = std::make_shared<std::function<void(std::shared_ptr<Custom::KeyEventArgs>)>>(std::bind(&SampleFormImpl::CustomScreenImplementation_KeyDown, this, std::placeholders::_1));
422  CustomScreenImplementation->AddKeyDownListener(_KeyDown);
423 
424  ContextVariableImplementation = std::make_shared<Custom::ContextVariableImplementation>();
425  _ContextVariableRead = std::make_shared<std::function<void(std::shared_ptr<IContextVariable>, std::shared_ptr<DataTypes::Object>)>>(std::bind(&SampleFormImpl::ContextVariableRead, this, std::placeholders::_1, std::placeholders::_2));
426  ContextVariableImplementation->SetContextVariableReadHandler(_ContextVariableRead);
427 
428  StateVariableImplementation = std::make_shared<Custom::StateVariableImplementation>();
429  _StateVariableValueChanged = std::make_shared<std::function<void(std::shared_ptr<IStateVariable>, std::shared_ptr<DataTypes::Object>)>>(std::bind(&SampleFormImpl::StateVariableValueChanged, this, std::placeholders::_1, std::placeholders::_2));
430  StateVariableImplementation->SetStateVariableValueChangedHandler(_StateVariableValueChanged);
431 
432  MeasureImplementation = std::make_shared<Custom::DefaultMeasureImplementation>();
433  ServiceProviderImplementation = std::make_shared<Custom::DefaultExternalServiceProviderImplementation>();
434  }
435 
436  void CustomScreenImplementation_KeyDown(std::shared_ptr<Custom::KeyEventArgs> eventArgs)
437  {
438  Owner->CustomScreenImplementation_KeyDown(eventArgs);
439  }
440 
441  void ContextVariableRead(std::shared_ptr<IContextVariable> contextVariable, std::shared_ptr<DataTypes::Object> value)
442  {
443  Owner->ContextVariableRead(contextVariable, value);
444  }
445 
446  void StateVariableValueChanged(std::shared_ptr<IStateVariable> stateVariable, std::shared_ptr<DataTypes::Object> value)
447  {
448  Owner->StateVariableValueChanged(stateVariable, value);
449  }
450 
451  void CreateOutputWindowCustomImpl()
452  {
453  _BasicScreenOutputImpl = std::make_shared<BasicScreenOutputImpl>();
454  _CustomScreenOutputImpl = std::make_shared<CustomScreenOutputImpl>();
455  _LoggingOutputImpl = std::make_shared<LoggingOutputImpl>();
456  _ContextVariableOutputImpl = std::make_shared<ContextVariableOutputImpl>();
457 
458  _StateVariableOutputImpl = std::make_shared<StateVariableOutputImpl>();
459  _MeasureOutputImpl = std::make_shared<MeasureOutputImpl>();
460  _I18nOutputImpl = std::make_shared<I18nOutputImpl>();
461  _ServiceProviderOutputImpl = std::make_shared<ExternalServiceProviderOutputImpl>();
462 
463  _CommonDialogsOutputImpl = std::make_shared<CommonDialogsOutputImpl>();
464  _SqlOutputImpl = std::make_shared<SqlOutputImpl>();
465 
466  _BasicScreenOutputImpl->_logEventHandler = std::make_shared<std::function<void(const std::string&)>>(std::bind(&SampleFormImpl::WriteLogEvent, this, std::placeholders::_1));
467  _CustomScreenOutputImpl->_logEventHandler = std::make_shared<std::function<void(const std::string&)>>(std::bind(&SampleFormImpl::WriteLogEvent, this, std::placeholders::_1));
468  _LoggingOutputImpl->_logEventHandler = std::make_shared<std::function<void(const std::string&)>>(std::bind(&SampleFormImpl::WriteLogEvent, this, std::placeholders::_1));
469  _ContextVariableOutputImpl->_logEventHandler = std::make_shared<std::function<void(const std::string&)>>(std::bind(&SampleFormImpl::WriteLogEvent, this, std::placeholders::_1));
470 
471  _StateVariableOutputImpl->_logEventHandler = std::make_shared<std::function<void(const std::string&)>>(std::bind(&SampleFormImpl::WriteLogEvent, this, std::placeholders::_1));
472  _MeasureOutputImpl->_logEventHandler = std::make_shared<std::function<void(const std::string&)>>(std::bind(&SampleFormImpl::WriteLogEvent, this, std::placeholders::_1));
473  _I18nOutputImpl->_logEventHandler = std::make_shared<std::function<void(const std::string&)>>(std::bind(&SampleFormImpl::WriteLogEvent, this, std::placeholders::_1));
474  _ServiceProviderOutputImpl->_logEventHandler = std::make_shared<std::function<void(const std::string&)>>(std::bind(&SampleFormImpl::WriteLogEvent, this, std::placeholders::_1));
475 
476  _CommonDialogsOutputImpl->_logEventHandler = std::make_shared<std::function<void(const std::string&)>>(std::bind(&SampleFormImpl::WriteLogEvent, this, std::placeholders::_1));
477  _SqlOutputImpl->_logEventHandler = std::make_shared<std::function<void(const std::string&)>>(std::bind(&SampleFormImpl::WriteLogEvent, this, std::placeholders::_1));
478  }
479 
480  void RemoveOutputImplLogEventHandler()
481  {
482  if(_BasicScreenOutputImpl != nullptr)
483  _BasicScreenOutputImpl->_logEventHandler = nullptr;
484  if(_CustomScreenOutputImpl != nullptr)
485  _CustomScreenOutputImpl->_logEventHandler = nullptr;
486  if(_CustomScreenOutputImpl != nullptr)
487  _LoggingOutputImpl->_logEventHandler = nullptr;
488  if(_CustomScreenOutputImpl != nullptr)
489  _ContextVariableOutputImpl->_logEventHandler = nullptr;
490 
491  if(_CustomScreenOutputImpl != nullptr)
492  _StateVariableOutputImpl->_logEventHandler = nullptr;
493  if(_CustomScreenOutputImpl != nullptr)
494  _MeasureOutputImpl->_logEventHandler = nullptr;
495  if(_CustomScreenOutputImpl != nullptr)
496  _I18nOutputImpl->_logEventHandler = nullptr;
497  if(_CustomScreenOutputImpl != nullptr)
498  _ServiceProviderOutputImpl->_logEventHandler = nullptr;
499 
500  if(_CustomScreenOutputImpl != nullptr)
501  _CommonDialogsOutputImpl->_logEventHandler = nullptr;
502  if(_CustomScreenOutputImpl != nullptr)
503  _SqlOutputImpl->_logEventHandler = nullptr;
504 
505  _BasicScreenOutputImpl = nullptr;
506  _CustomScreenOutputImpl = nullptr;
507  _LoggingOutputImpl = nullptr;
508  _ContextVariableOutputImpl = nullptr;
509 
510  _StateVariableOutputImpl = nullptr;
511  _MeasureOutputImpl = nullptr;
512  _I18nOutputImpl = nullptr;
513  _ServiceProviderOutputImpl = nullptr;
514 
515  _CommonDialogsOutputImpl = nullptr;
516  _SqlOutputImpl = nullptr;
517  }
518 
519  void WriteLogEvent(const std::string& text)
520  {
521  Owner->PrintTextCallback(Util::Util::ToString(text));
522  }
523 
524  void SetOutputWindowImplementation(std::shared_ptr<IRuntimeManager> runtimeManager)
525  {
526  if (runtimeManager == nullptr)
527  {
528  return;
529  }
530 
531  runtimeManager->SetCustomImplementation(_BasicScreenOutputImpl);
532  runtimeManager->SetCustomImplementation(_CommonDialogsOutputImpl);
533  runtimeManager->SetCustomImplementation(_ContextVariableOutputImpl);
534  runtimeManager->SetCustomImplementation(_CustomScreenOutputImpl);
535  runtimeManager->SetCustomImplementation(_ServiceProviderOutputImpl);
536  runtimeManager->SetCustomImplementation(_I18nOutputImpl);
537  runtimeManager->SetCustomImplementation(_LoggingOutputImpl);
538  runtimeManager->SetCustomImplementation(_MeasureOutputImpl);
539  runtimeManager->SetCustomImplementation(_SqlOutputImpl);
540  runtimeManager->SetCustomImplementation(_StateVariableOutputImpl);
541  }
542 
543 private:
544  msclr::auto_gcroot<SampleForm^> Owner;
545  std::shared_ptr<std::function<void(const IRuntimeContext&)>> _ProcedurePending;
546  std::shared_ptr<std::function<void(const IRuntimeContext&)>> _ProcedureStarted;
547  std::shared_ptr<std::function<void(const IRuntimeContext&, ExecutionStateChangeReason)>> _ProcedurePaused;
548  std::shared_ptr<std::function<void(const IRuntimeContext&)>> _ProcedureContinued;
549  std::shared_ptr<std::function<void(const IRuntimeContext&)>> _ProcedureFinished;
550  std::shared_ptr<std::function<void(const IRuntimeContext&)>> _ProcedureStopped;
551  std::shared_ptr<std::function<void(const IRuntimeContext&)>> _ProcedureAborted;
552  std::shared_ptr<std::function<void(const IRuntimeContext&)>> _ProcedureTimeout;
553  std::shared_ptr<std::function<void(ClampState, ClampState)>> _DiagConnectionStateChanged;
554  std::shared_ptr<std::function<void(const IRuntimeContext&, const IProcedureInOutParameter&)>> _InOutParameterValueChanged;
555 
556  std::shared_ptr<std::function<void(std::shared_ptr<Custom::KeyEventArgs>)>> _KeyDown;
557  std::shared_ptr<std::function<void(std::shared_ptr<IContextVariable>, std::shared_ptr<DataTypes::Object>)>> _ContextVariableRead;
558  std::shared_ptr<std::function<void(std::shared_ptr<IStateVariable>, std::shared_ptr<DataTypes::Object>)>> _StateVariableValueChanged;
559 };
560 
561 bool SampleFormImpl::IsRegistered = false;
562 std::string SampleFormImpl::FileVersion = "";
563 std::vector<msclr::auto_gcroot<SampleForm^>> SampleFormImpl::ListForms;
564 
565 void SampleForm::RegisterSettingsEvent()
566 {
567  if (!SampleFormImpl::IsRegistered)
568  {
569  SampleFormImpl::IsRegistered = true;
570 
571  SampleFormImpl::FileVersion = RuntimeConfig::GetInstance().GetVersion();
572  // Reason: See #15223. Only implement at Sample Dotnet
573  //String^ licenseKeyFromOTForOTPLicense = OpenTestSystem::Common::LicensingV5::Util::CreateLicenseKeyFromOTForOTPLicense();
574  System::String^ licenseKeyFromOTForOTPLicense;
575  // isAcceptEmptyLicenseValue = licenseKeyFromOTForOTPLicense.Equals("") ? false : true;
576 
577  if (!System::String::IsNullOrEmpty(licenseKeyFromOTForOTPLicense) && Util::LicenseUtil::CheckLicenseFormat(Util::Util::ToString(licenseKeyFromOTForOTPLicense)))
578  {
579  OpenTestSystem::Otx::Runtime::Api::License::LicenseManager::SetLicenseKey(Util::Util::ToString(licenseKeyFromOTForOTPLicense));
580  }
581  else
582  {
583  std::string licenseKey = Setting::UserSettings::GetInstance().GetLicenseKey();
584  licenseKey = Util::LicenseUtil::Decrypt(licenseKey);
585  if (Util::LicenseUtil::CheckLicenseFormat(licenseKey))
586  {
588  }
589  else
590  {
591  System::Windows::Forms::MessageBox::Show("There is an invalid license key format. Please set your new key in license box.", "Warning!", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Warning);
592  }
593  }
594 
595  Microsoft::Win32::SystemEvents::DisplaySettingsChanged += gcnew System::EventHandler(this, &OpenTestSystem::Otx::Runtime2::Api::Sample::SampleForm::SystemEvents_DisplaySettingsChanged);
596  }
597 }
598 
599 void SampleForm::SystemEvents_DisplaySettingsChanged(System::Object^ sender, System::EventArgs^ e)
600 {
601  try
602  {
603  for (int i = 0; i < SampleFormImpl::ListForms.size(); i++)
604  {
605  msclr::auto_gcroot<SampleForm^> frm = SampleFormImpl::ListForms.at(i);
606  try
607  {
608  if (frm.get()->InvokeRequired)
609  {
610  frm.get()->Invoke(gcnew System::Action(frm.get(), &SampleForm::Refresh));
611  }
612  else
613  {
614  frm.get()->Refresh();
615  }
616  }
617  catch (...) {}
618  }
619  }
620  catch (...) {}
621 }
622 
623 void SampleForm::InitializeInternalComponent()
624 {
625  piml = new SampleFormImpl(this);
626  RegisterSettingsEvent();
627 }
628 
629 SampleForm::SampleForm(System::String^ title, SampleForm^ creatorForm)
630 {
631  ShowInTaskbar = false;
632  InitializeInternalComponent();
633 
634  piml->Title = System::String::IsNullOrEmpty(title) ? SampleConstants::MAIN_INSTANCE_NAME : Util::Util::ToString(title);
635  piml->CreatorForm = creatorForm;
636 
637  piml->WebServerTimer->Interval = 1000;
638  piml->WebServerTimer->Enabled = true;
639  piml->WebServerTimer->Tick += gcnew System::EventHandler(this, &SampleForm::WebServerTimer_Tick);
640 
641  InitializeComponent();
642 
643  piml->ListForms.push_back(this);
644 
645  PrintTextCallback("Application started");
646 }
647 
648 System::Void SampleForm::SampleForm_Load(System::Object^ sender, System::EventArgs^ e)
649 {
650  PrintTextCallback("Start Initialization...");
651 
652  CreateCustomImpl();
653  InitializeSampleDefaultValues();
654  UpdateWebServerButtonCallback();
655 
656  if (IS_NOT_NULL(piml->CreatorForm))
657  {
658  checkBoxStartAllParents->Visible = true;
659  checkBoxStartAllParents->Checked = piml->CreatorForm->checkBoxStartAllParents->Checked;
660  }
661 
662  SetRuntimeContextName();
663  SetTitle(Util::Util::ToString(piml->Title));
664  SetLocation(piml->CreatorForm.get());
665 
666  toolTip1->SetToolTip(labelProcedureExecutionTimes, "Total procedure execution time.");
667  toolTip1->SetToolTip(textBoxTimeout, "Timeout for procedure execution in milliseconds. The default value 0 means without timeout.");
668  toolTip1->SetToolTip(checkBoxUseConnectionState, "Use expected connection state during procedure execution.");
669  toolTip1->SetToolTip(labelBatteryState, "State of the battery (KL 30)");
670  toolTip1->SetToolTip(checkBoxIgnition, "Expected ignition (KL 15) state during procedure execution");
671  toolTip1->SetToolTip(labelIgnitionState, "State of the ignition (KL 15)");
672  toolTip1->SetToolTip(buttonCheckBatteryIgnition, "Check current battery (KL30) and ignition (KL15) state.");
673  toolTip1->SetToolTip(textBoxPollingTime, "Time in milliseconds between the next check of the connection state during the procedure execution (Polling). The default value is 500 ms.");
674  toolTip1->SetToolTip(textBoxVoltageThreshold, "Voltage threshold in millivolt from which the battery voltage, see GetBatteryVoltage is enough for KL30 = On. The default value is 6000 mV.");
675 
676  LoadContextFile(piml->GlobalRuntimeManager);
677 
678  PrintTextCallback("... Initialization finished.");
679  ShowInTaskbar = true;
680 #pragma region Only Cpp: See issue 15942 - bug 7
681  WindowState = System::Windows::Forms::FormWindowState::Normal;
682 #pragma endregion
683 }
684 
685 System::Void SampleForm::SampleForm_Shown(System::Object^ sender, System::EventArgs^ e)
686 {
687  cbFilePath->SelectionLength = 0;
688 }
689 
690 void SampleForm::SetRuntimeContextName()
691 {
692  if (IS_NOT_NULL(piml->CreatorForm) && !System::String::IsNullOrEmpty(Util::Util::ToString(piml->CreatorForm->piml->RuntimeContextName)))
693  {
694  System::String^ contextName = Util::Util::ToString(piml->CreatorForm->piml->RuntimeContextName);
695  System::Text::RegularExpressions::Match^ regExpMatch = System::Text::RegularExpressions::Regex::Match(contextName, "\d*$");
696  int number;
697  if (System::Int32::TryParse(regExpMatch->Value, number))
698  {
699  number++;
700  textBoxRuntimeContextName->Text = Util::Util::ToString(piml->CreatorForm->piml->RuntimeContextName.substr(0, regExpMatch->Index) + std::to_string(number));
701  }
702  }
703 }
704 
705 void SampleForm::SetTitle(System::String^ title)
706 {
707  if (System::String::IsNullOrWhiteSpace(title))
708  {
709  title = Util::Util::ToString(SampleConstants::MAIN_INSTANCE_NAME);
710  }
711 
712  bool runningAsAdmin = System::Security::Principal::WindowsIdentity::GetCurrent()->Owner->IsWellKnown(System::Security::Principal::WellKnownSidType::BuiltinAdministratorsSid);
713 
714  Text = System::String::Format(
715  "emotive OTX-Runtime API for Cpp - Reference Application - Version {0} - {1} Bit - {2} - Thread-ID {3}{4}",
716  Util::Util::ToString(piml->FileVersion),
717  System::Environment::Is64BitProcess ? "64" : "32",
718  Util::Util::ToString(piml->Title),
719  System::Threading::Thread::CurrentThread->ManagedThreadId,
720  runningAsAdmin ? " - Administrator" : System::String::Empty
721  );
722 
723  if (!System::String::IsNullOrEmpty(cbFilePath->Text))
724  {
725  Text = Text + " - " + System::IO::Path::GetFileName(cbFilePath->Text);
726  }
727 
728  System::String^ runtimeContextNameCliStr = Util::Util::ToString(piml->RuntimeContextName);
729  if (!System::String::IsNullOrEmpty(runtimeContextNameCliStr))
730  {
731  Text = Text + " - " + runtimeContextNameCliStr;
732  }
733 }
734 
735 void SampleForm::SetLocation(SampleForm^ creatorForm)
736 {
737  if (creatorForm != nullptr)
738  {
739  int xOffset = piml->FORM_OFFSET;
740  int yOffset = piml->FORM_OFFSET;
741 
742  if (IS_NOT_NULL(creatorForm->piml->CreatorForm))
743  {
744  xOffset = creatorForm->Location.X - creatorForm->piml->CreatorForm->Location.X;
745  yOffset = creatorForm->Location.Y - creatorForm->piml->CreatorForm->Location.Y;
746  }
747 
748  Location = Point(creatorForm->Location.X + xOffset, creatorForm->Location.Y + yOffset);
749  Size = creatorForm->Size;
750  }
751 }
752 
753 void SampleForm::CreateCustomImpl()
754 {
755  CreateDefaultCustomImpl();
756  CreateOutputWindowCustomImpl();
757 }
758 
759 void SampleForm::CreateDefaultCustomImpl()
760 {
761  PrintTextCallback("Create default custom implementation");
762 
763  piml->CreateDefaultCustomImpl();
764 }
765 
766 void SampleForm::CreateOutputWindowCustomImpl()
767 {
768  PrintTextCallback("Create output window custom implementation");
769 
770  piml->CreateOutputWindowCustomImpl();
771 }
772 
773 void SampleForm::InitializeSampleDefaultValues()
774 {
775  PrintTextCallback("Initialize default values");
776 
777  comboBoxTraceLevel->Items->AddRange(Util::Util::ArrayTraceLevels2String());
778 
779  // Avoid changing order
780  treeViewOtxProject->ImageList = imageList1;
781 
782  textBoxRtPortPipe->Name = Util::Util::ToString(SampleConstants::RT_PORT_PIPE_TEXT_BOX_NAME);
783  textBoxDiagPortPipe->Name = Util::Util::ToString(SampleConstants::DM_PORT_PIPE_TEXT_BOX_NAME);
784 
785  LoadSetting();
786 
787  EnableConnectionState();
788 }
789 
790 void SampleForm::LoadSetting()
791 {
792  Setting::UserSettings::GetInstance().Reload();
793  try
794  {
795  SetupTraceLevel();
796  SetupTraceFolder();
797  SetupTraceFileMaxCountAndSize();
798 
799  // Avoid changing order of the time
800  SetupDefaultPortAndPipeName();
801 
802  cbFilePath->Text = Util::Util::ToString(Setting::UserSettings::GetInstance().GetPtxPpxDirectory());
803  if (!Setting::UserSettings::GetInstance().GetPtxPpxDirectoryList().empty())
804  {
805  cbFilePath->Items->AddRange(Util::Util::ToString(Setting::UserSettings::GetInstance().GetPtxPpxDirectoryList())->Split(';'));
806  }
807  AddComboBoxFileOrPath(cbFilePath);
808 
809  SetupCustomImplType();
810  SetupWindowSize();
811  SetupWindowLocation();
812 
813  checkBoxAsyncExecution->Checked = Setting::UserSettings::GetInstance().GetAsynchron();
814  checkBoxCyclicExecution->Checked = Setting::UserSettings::GetInstance().GetCyclic();
815  checkBoxCyclicReload->Checked = Setting::UserSettings::GetInstance().GetCyclicReload();
816  checkBoxNewRuntimeManager->Checked = Setting::UserSettings::GetInstance().GetNewRuntimeManager();
817  checkBoxAdd2Output->Checked = Setting::UserSettings::GetInstance().GetAddMessageToOutput();
818  checkBoxStartAllParents->Checked = Setting::UserSettings::GetInstance().GetStartAllParents();
819 
820  SetupTimeOut();
821  checkBoxUseConnectionState->Checked = Setting::UserSettings::GetInstance().GetConnectionState();
822  checkBoxIgnition->CheckState = Setting::UserSettings::GetInstance().GetIgnition() == 1 ? System::Windows::Forms::CheckState::Checked
823  : (Setting::UserSettings::GetInstance().GetIgnition() == 0 ? System::Windows::Forms::CheckState::Unchecked
824  : System::Windows::Forms::CheckState::Indeterminate);
825  SetupPollingTime();
826  SetupVoltageThreshold();
827 
828  textBoxRuntimeContextName->Text = Util::Util::ToString(Setting::UserSettings::GetInstance().GetRuntimeContextName());
829 
830 #pragma region C++ for RAW-Mode
831  textBoxDiagManagerLicenseKey->Text = Util::Util::ToString(Util::LicenseUtil::Decrypt(Setting::UserSettings::GetInstance().GetDiagManagerLicenseKey()));
832  checkBoxIncludedDiagLogging->Checked = Setting::UserSettings::GetInstance().GetIncludeTraceDiagLogging();
833 
834  std::string traceFolder = Setting::UserSettings::GetInstance().GetDiagTraceDirectory();
835  textBoxDiagManagerTraceFolder->Text = Util::Util::ToString(traceFolder.empty() ? Util::OtxDiagUtil::GetPathLoggerDefault() : traceFolder);
836 #pragma endregion
837 
838  }
839  catch (const std::exception& e)
840  {
841  PrintTextCallback(Util::Util::ToString(e.what()));
842  Setting::UserSettings::GetInstance().Reset();
843  }
844  catch (System::Exception^ e)
845  {
846  PrintTextCallback(e->Message);
847  Setting::UserSettings::GetInstance().Reset();
848  }
849 }
850 
851 void SampleForm::AddComboBoxFileOrPath(System::Windows::Forms::ComboBox^ comboBox)
852 {
853  if (comboBox != nullptr && !piml->IsPathChanging)
854  {
855  piml->IsPathChanging = true;
856 
857  System::String^ path = comboBox->Text;
858 
859  if (System::IO::Directory::Exists(path) || System::IO::File::Exists(path))
860  {
861  while (comboBox->Items->Contains(path))
862  {
863  comboBox->Items->Remove(path);
864  }
865 
866  while (comboBox->Items->Contains(path->TrimEnd(gcnew cli::array<wchar_t>(2) { '/', '\\' })))
867  {
868  comboBox->Items->Remove(path->TrimEnd(gcnew cli::array<wchar_t>(2) { '/', '\\' }));
869  }
870 
871  path = path->TrimEnd(gcnew cli::array<wchar_t>(2) { '/', '\\' });
872 
873  comboBox->Items->Insert(0, path);
874  comboBox->Text = path;
875  comboBox->SelectAll();
876  }
877 
878  piml->IsPathChanging = false;
879  }
880 }
881 
882 void SampleForm::SetupTraceFileMaxCountAndSize()
883 {
884  textBoxTraceFileMaxCount->Text = Setting::UserSettings::GetInstance().GetTraceFileMaxCount().ToString();
885  textBoxTraceFileMaxSize->Text = Setting::UserSettings::GetInstance().GetTraceFileMaxSize().ToString();
886 }
887 
888 void SampleForm::SetupDefaultPortAndPipeName()
889 {
890  piml->DefaultDiagPort = Setting::UserSettings::GetInstance().GetDiagManagerPort();
891  piml->DefaultRuntimePort = Setting::UserSettings::GetInstance().GetRuntimePort();
892 
893  piml->DefaultDiagPipeName = Setting::UserSettings::GetInstance().GetDiagManagerPipeName();
894  piml->DefaultRuntimePipeName = Setting::UserSettings::GetInstance().GetRuntimePipeName();
895 
896  IpcTypes ipcType = IpcTypes::Socket;
897  ipcType = Setting::UserSettings::GetInstance().GetIpcType();
898 
899  if (comboBoxIpcType->Items->Count == 0)
900  {
901  // Mode: Raw (Only C++), Socket, Pipe
902  comboBoxIpcType->Items->AddRange(Util::Util::ArrayIpcTypes2String());
903  }
904 
905  comboBoxIpcType->SelectedItem = Util::Util::ToString(ipcType);
906 }
907 
908 void SampleForm::SetupTraceLevel()
909 {
910  TraceLevels traceLevels = Setting::UserSettings::GetInstance().GetTraceLevels();
912 
914  comboBoxTraceLevel->SelectedItem = Util::Util::ToString(traceLevels);
915 }
916 
917 void SampleForm::SetupTraceFolder()
918 {
919  if (Setting::UserSettings::GetInstance().GetTracingDirectory().empty() != true)
920  {
921  OpenTestSystem::Otx::Runtime::Api::RuntimeConfig::GetInstance().SetTraceFolder(Setting::UserSettings::GetInstance().GetTracingDirectory());
922  }
923 
924  textBoxTraceFolder->Text = Util::Util::ToString(RuntimeConfig::GetInstance().GetTraceFolder());
925 }
926 
927 void SampleForm::SetupCustomImplType()
928 {
929  if (Setting::UserSettings::GetInstance().GetCustomImplTypes() == CustomImplTypes::OutputImpl)
930  {
931  radioButtonOuputWindow->Checked = true;
932  }
933  else if (Setting::UserSettings::GetInstance().GetCustomImplTypes() == CustomImplTypes::NoCustom)
934  {
935  radioButtonNoCustomImplementation->Checked = true;
936  }
937  else
938  {
939  radioButtonDefaultImplementation->Checked = true;
940  }
941 }
942 
943 void SampleForm::SetupWindowSize()
944 {
945  int width = Setting::UserSettings::GetInstance().GetWindowWidth();
946  int height = Setting::UserSettings::GetInstance().GetWindowHeight();
947  Size = System::Drawing::Size(width, height);
948 }
949 
950 void SampleForm::SetupWindowLocation()
951 {
952  int locationX = Setting::UserSettings::GetInstance().GetWindowLocationX();
953  int locationY = Setting::UserSettings::GetInstance().GetWindowLocationY();
954  System::Drawing::Point location = System::Drawing::Point(locationX, locationY);
955 
956  if (CheckFormIsInBound(location))
957  {
958  Location = location;
959  return;
960  }
961 
962  CenterToScreen();
963 }
964 
965 bool SampleForm::CheckFormIsInBound(System::Drawing::Point location)
966 {
967  try
968  {
969 #pragma region C++ can not use Linq
970  cli::array<System::Windows::Forms::Screen^>^ formContainScreens = System::Windows::Forms::Screen::AllScreens;
971  for (int i = 0; i < formContainScreens->Length; i++)
972  {
973  if (formContainScreens[i]->Bounds.Contains(location))
974  {
975  return true;
976  }
977  }
978 
979  return false;
980 #pragma endregion
981  }
982  catch (...)
983  {
984  return false;
985  }
986 }
987 
988 void SampleForm::SetupTimeOut()
989 {
990  System::String^ timeOutString = Setting::UserSettings::GetInstance().GetTimeOut().ToString();
991  textBoxTimeout->Text = timeOutString;
992 }
993 
994 void SampleForm::SetupPollingTime()
995 {
996  std::string pollingTimeString = std::to_string(Setting::UserSettings::GetInstance().GetPollingTime());
997  textBoxPollingTime->Text = Util::Util::ToString(pollingTimeString);
998 }
999 
1000 void SampleForm::SetupVoltageThreshold()
1001 {
1002  std::string voltageThreshold = std::to_string(Setting::UserSettings::GetInstance().GetVoltageThreshold());
1003  textBoxVoltageThreshold->Text = Util::Util::ToString(voltageThreshold);
1004 }
1005 
1006 System::Void SampleForm::comboBoxIpcType_SelectedValueChanged(System::Object^ sender, System::EventArgs^ e)
1007 {
1008  // Avoid RuntimeManager creation on DiagManager's port changed in this method
1009  textBoxDiagPortPipe->TextChanged -= gcnew System::EventHandler(this, &SampleForm::textBoxPortPipe_TextChanged);
1010  IpcTypes ipcType = Util::Util::ToIpcType(comboBoxIpcType->SelectedItem->ToString());
1011 
1012 #pragma region C++ for design has RAW-mode
1013  // hide some input when initialize runtime manager
1014  textBoxDiagPortPipe->Hide();
1015  textBoxRtPortPipe->Hide();
1016  comboBoxODXProject->Hide();
1017  label13->Hide();
1018  comboBoxODXVehicle->Hide();
1019  portPipeLabel->Hide();
1020  labelOdxProject->Hide();
1021 
1022  // collapse content configuration DiagManager
1023  panel1->Size = System::Drawing::Size(panel1->Size.Width, 61);
1024  portPipeLabel->Location = System::Drawing::Point(portPipeLabel->Location.X, 34);
1025  textBoxDiagPortPipe->Location = System::Drawing::Point(Width - 95, 31);
1026  textBoxDiagPortPipe->Size = System::Drawing::Size(55, 22);
1027 #pragma endregion
1028 
1029  switch (ipcType)
1030  {
1031 #pragma region C++ for RAW-mode
1032  case IpcTypes::Raw:
1033  // expand content configuration DiagManager
1034  panel1->Size = System::Drawing::Size(panel1->Size.Width, 116);
1035 
1036  SetupDiagManagerControls();
1037 
1038  comboBoxDiagIpcType_SelectedValueChanged(comboBoxDiagIpcType, nullptr);
1039 
1040  break;
1041 #pragma endregion
1042 
1043  case IpcTypes::Socket:
1044 
1045  portPipeLabel->Show();
1046  portPipeLabel->Text = "Runner / DiagManager Ports";
1047 
1048 #pragma region C++ for design has RAW-mode
1049  textBoxRtPortPipe->Show();
1050  label13->Show();
1051  textBoxDiagPortPipe->Show();
1052 #pragma endregion
1053 
1054  textBoxDiagPortPipe->Text = piml->DefaultDiagPort.ToString();
1055  textBoxDiagPortPipe->TextChanged+= gcnew System::EventHandler(this, &SampleForm::textBoxPortPipe_TextChanged);
1056 
1057  textBoxRtPortPipe->Text = piml->DefaultRuntimePort.ToString();
1058  break;
1059 
1060  case IpcTypes::Pipe:
1061 
1062  portPipeLabel->Show();
1063  portPipeLabel->Text = "Runner / DiagManager Pipes";
1064 
1065 #pragma region C++ for design has RAW-mode
1066  textBoxRtPortPipe->Show();
1067  label13->Show();
1068  textBoxDiagPortPipe->Show();
1069 #pragma endregion
1070 
1071  textBoxDiagPortPipe->Text = Util::Util::ToString(piml->DefaultDiagPipeName);
1072  textBoxDiagPortPipe->TextChanged += gcnew System::EventHandler(this, &SampleForm::textBoxPortPipe_TextChanged);
1073 
1074  textBoxRtPortPipe->Text = Util::Util::ToString(piml->DefaultRuntimePipeName);
1075  break;
1076 
1077  default:
1078  break;
1079  }
1080 }
1081 
1082 System::Void SampleForm::textBoxPortPipe_TextChanged(System::Object^ sender, System::EventArgs^ e)
1083 {
1084  PrintTextCallback("Create RuntimeManager...");
1085 
1086  try
1087  {
1088  piml->GlobalRuntimeManager = CreateRuntimeManager();
1089  }
1090  catch (const std::exception& ex)
1091  {
1092  PrintException(ex);
1093  PrintTextCallback("No RuntimeManager created");
1094  }
1095  catch (System::Exception^ ex)
1096  {
1097  System::String^ senderName = (dynamic_cast<System::Windows::Forms::TextBox^>(sender))->Name;
1098  if (senderName->Equals(Util::Util::ToString(SampleConstants::RT_PORT_PIPE_TEXT_BOX_NAME)))
1099  {
1100  PrintTextCallback(System::String::Format("Invalid Otx Runtime {0}", IpcPortPipeString()));
1101  }
1102  else if (senderName->Equals(Util::Util::ToString(SampleConstants::DM_PORT_PIPE_TEXT_BOX_NAME)))
1103  {
1104  PrintTextCallback(System::String::Format("Invalid Diag Manager {0}", IpcPortPipeString()));
1105  }
1106 
1107  PrintException(ex);
1108  PrintTextCallback("No RuntimeManager created");
1109  }
1110  catch (...)
1111  {
1112  PrintTextCallback("No RuntimeManager created");
1113  }
1114 
1115  if (piml->GlobalRuntimeManager==nullptr)
1116  {
1117  PrintTextCallback("RuntimeManager is null.");
1118  }
1119 }
1120 
1121 std::shared_ptr<IRuntimeManager> SampleForm::CreateRuntimeManager()
1122 {
1123  std::shared_ptr<IRuntimeManager> runtimeManager = nullptr;
1124  try
1125  {
1126  System::String^ ipcType = "";
1127  switch (Util::Util::ToIpcType(comboBoxIpcType->SelectedItem->ToString()))
1128  {
1129 #pragma region C++ for RAW-mode
1130  case IpcTypes::Raw:
1131 
1132  runtimeManager = CreateRawRuntimeManager();
1133  ipcType = Util::Util::ToString(IpcTypes::Raw);
1134  break;
1135 #pragma endregion
1136 
1137  case IpcTypes::Socket:
1138 
1139  runtimeManager = CreateSocketRuntimeManager();
1140  ipcType = Util::Util::ToString(IpcTypes::Socket);
1141  break;
1142 
1143  case IpcTypes::Pipe:
1144 
1145  runtimeManager = CreatePipeRuntimeManager();
1146  ipcType = Util::Util::ToString(IpcTypes::Pipe);
1147  break;
1148  }
1149 
1150  PrintTextCallback(System::String::Format("... {0} RuntimeManager created (MinBinVersion: {1})", ipcType, Util::Util::ToString(RuntimeConfig::GetInstance().GetMinBinVersion())));
1151 
1152  InitializeRuntimeEvents(runtimeManager);
1153  SetCustomImplementation(runtimeManager);
1154  }
1155  catch (const std::exception& ex)
1156  {
1157  PrintException(ex);
1158  PrintTextCallback("... No RuntimeManager created.");
1159 
1160  return runtimeManager;
1161  }
1162  catch (System::Exception^ ex)
1163  {
1164  PrintException(ex);
1165  PrintTextCallback("... No RuntimeManager created.");
1166 
1167  return runtimeManager;
1168  }
1169  catch (...)
1170  {
1171  PrintTextCallback("... No RuntimeManager created.");
1172 
1173  return runtimeManager;
1174  }
1175 
1176  return runtimeManager;
1177 }
1178 
1179 System::String^ SampleForm::IpcPortPipeString()
1180 {
1181  IpcTypes ipcType = Util::Util::ToIpcType(comboBoxIpcType->SelectedItem->ToString());
1182  switch(ipcType)
1183  {
1184  case IpcTypes::Socket:
1185  return Util::Util::ToString(SampleConstants::PORT_STRING);
1186  case IpcTypes::Pipe:
1187  return Util::Util::ToString(SampleConstants::PIPE_STRING);
1188  default:
1189  // Should not reach here
1190  return System::String::Empty;
1191  }
1192 }
1193 
1194 std::shared_ptr<IRuntimeManager> SampleForm::CreateSocketRuntimeManager()
1195 {
1196  unsigned short rtPort = System::Convert::ToUInt16(textBoxRtPortPipe->Text);
1197 
1198  if (NoDiag())
1199  {
1200  return RuntimeManagerFactory::CreateSocketRuntimeManager(rtPort);
1201  }
1202  else
1203  {
1204  unsigned short diagPort = System::Convert::ToUInt16(textBoxDiagPortPipe->Text);
1205  return RuntimeManagerFactory::CreateSocketRuntimeManager(rtPort, diagPort);
1206  }
1207 }
1208 
1209 std::shared_ptr<IRuntimeManager> SampleForm::CreatePipeRuntimeManager()
1210 {
1211  if (NoDiag())
1212  {
1213  return RuntimeManagerFactory::CreatePipeRuntimeManager(Util::Util::ToString(textBoxRtPortPipe->Text));
1214  }
1215  else
1216  {
1217  return RuntimeManagerFactory::CreatePipeRuntimeManager(Util::Util::ToString(textBoxRtPortPipe->Text), Util::Util::ToString(textBoxDiagPortPipe->Text));
1218  }
1219 }
1220 
1221 bool SampleForm::NoDiag()
1222 {
1223  return System::String::IsNullOrWhiteSpace(textBoxDiagPortPipe->Text);
1224 }
1225 
1226 void SampleForm::InitializeRuntimeEvents(std::shared_ptr<IRuntimeManager> runtimeManager)
1227 {
1228  if (runtimeManager == nullptr)
1229  {
1230  return;
1231  }
1232 
1233  piml->InitializeRuntimeEvents(runtimeManager);
1234 
1235  PrintTextCallback("Initialization of runtime events finished");
1236 }
1237 
1238 System::Void SampleForm::radioButtonCustomImpl_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
1239 {
1240  if (piml->GlobalRuntimeManager == nullptr)
1241  {
1242  return;
1243  }
1244 
1245  if (sender != nullptr && (dynamic_cast<System::Windows::Forms::RadioButton^>(sender))->Checked == false)
1246  {
1247  return;
1248  }
1249 
1250  SetCustomImplementation(piml->GlobalRuntimeManager);
1251 }
1252 
1253 void SampleForm::SetCustomImplementation(std::shared_ptr<IRuntimeManager> runtimeManager)
1254 {
1255  if (runtimeManager == nullptr)
1256  {
1257  return;
1258  }
1259 
1260  System::String^ type = "";
1261  CustomImplTypes currentCustomImpl = GetCurrentCustomImpl();
1262  switch (currentCustomImpl)
1263  {
1264  case OutputImpl:
1265 
1266  SetOutputWindowImplementation(runtimeManager);
1267  type = "output ";
1268  break;
1269 
1270  case DefaultCustomImpl:
1271 
1272  SetDefaultCustomImplementation(runtimeManager);
1273  type = "default ";
1274  break;
1275 
1276  case NoCustom:
1277 
1278  RemoveCustomImplementation(runtimeManager);
1279  type = "no ";
1280  break;
1281 
1282  default:
1283  break;
1284  }
1285 
1286  if (currentCustomImpl != CustomImplTypes::None)
1287  {
1288  PrintTextCallback("Set up " + type + "custom implementation finished");
1289  }
1290 }
1291 
1292 CustomImplTypes SampleForm::GetCurrentCustomImpl()
1293 {
1294  if (radioButtonOuputWindow->Checked)
1295  {
1296  return CustomImplTypes::OutputImpl;
1297  }
1298  else if (radioButtonDefaultImplementation->Checked)
1299  {
1300  return CustomImplTypes::DefaultCustomImpl;
1301  }
1302  else if (radioButtonNoCustomImplementation->Checked)
1303  {
1304  return CustomImplTypes::NoCustom;
1305  }
1306 
1307  return CustomImplTypes::None;
1308 }
1309 
1310 void SampleForm::SetOutputWindowImplementation(std::shared_ptr<IRuntimeManager> runtimeManager)
1311 {
1312  if (runtimeManager == nullptr)
1313  {
1314  return;
1315  }
1316 
1317  piml->SetOutputWindowImplementation(runtimeManager);
1318 }
1319 
1320 void SampleForm::SetDefaultCustomImplementation(std::shared_ptr<IRuntimeManager> runtimeManager)
1321 {
1322  if (runtimeManager == nullptr)
1323  {
1324  return;
1325  }
1326 
1327  piml->SetDefaultCustomImplementation(runtimeManager);
1328 }
1329 
1330 void SampleForm::RemoveCustomImplementation(std::shared_ptr<IRuntimeManager> runtimeManager)
1331 {
1332  if (runtimeManager == nullptr)
1333  {
1334  return;
1335  }
1336 
1337  piml->RemoveCustomImplementation(runtimeManager);
1338 }
1339 
1340 void SampleForm::ProcedurePendingCallback(CLRWrapper<IRuntimeContext*>^ clrContext)
1341 {
1342  if (InvokeRequired)
1343  {
1344  Invoke(gcnew System::Action<CLRWrapper< IRuntimeContext*>^>(this, &SampleForm::ProcedurePendingCallback), clrContext);
1345  return;
1346  }
1347 
1348  msclr::lock l(piml->EventListenerLock.get());
1349  {
1350  IRuntimeContext* context = clrContext->GetPtr();
1351  PrintTextCallback(System::String::Format("Event ProcedurePending occurred - {0} - ExecutionState = {1}",
1352  Util::Util::ToString(context->GetProcedure()->GetFullName()),
1353  Util::Util::ToString(context->GetExecutionState())));
1354  UpdateExecutionState(context);
1355  ShowConnectionStateMessage(context);
1356  }
1357 }
1358 
1359 void SampleForm::ProcedureStartedCallback(CLRWrapper<IRuntimeContext*>^ clrContext)
1360 {
1361  if (InvokeRequired)
1362  {
1363  Invoke(gcnew System::Action<CLRWrapper<IRuntimeContext*>^>(this, &SampleForm::ProcedureStartedCallback), clrContext);
1364  return;
1365  }
1366 
1367  msclr::lock l(piml->EventListenerLock.get());
1368  {
1369  IRuntimeContext* context = clrContext->GetPtr();
1370  PrintTextCallback(System::String::Format("Event ProcedureStarted occurred - {0} - ExecutionState = {1} - RuntimeId = {2} - ProcessId = {3}",
1371  Util::Util::ToString(context->GetProcedure()->GetFullName()),
1372  Util::Util::ToString(context->GetExecutionState()),
1373  context->GetRuntimeId().ToString(),
1374  context->GetProcessId().ToString()));
1375  UpdateExecutionState(context);
1376  }
1377 }
1378 
1379 void SampleForm::ProcedurePaused(IRuntimeContext* context, ExecutionStateChangeReason reason)
1380 {
1381  cli::array<System::Object^>^ arr = gcnew cli::array<System::Object^>(2);
1382  arr[0] = gcnew CLRWrapper<IRuntimeContext*>(context);
1383  arr[1] = gcnew CLRWrapper<ExecutionStateChangeReason>(reason);
1384  if (InvokeRequired)
1385  {
1386  Invoke(gcnew System::Action<cli::array<System::Object^>^>(this, &SampleForm::ProcedurePausedCallback), gcnew cli::array<System::Object^>{arr});
1387  }
1388  else
1389  {
1390  ProcedurePausedCallback(arr);
1391  }
1392 }
1393 
1394 void SampleForm::ProcedurePausedCallback(cli::array<System::Object^>^ arr)
1395 {
1396  if (arr == nullptr || arr->Length != 2)
1397  {
1398  return;
1399  }
1400 
1401  IRuntimeContext* context = Util::Util::CastTo<IRuntimeContext*>(arr[0]);
1402  ExecutionStateChangeReason reason = Util::Util::CastToEnum<ExecutionStateChangeReason>(arr[1]);
1403 
1404  if (context == nullptr)
1405  {
1406  return;
1407  }
1408 
1409  msclr::lock l(piml->EventListenerLock.get());
1410  {
1411  PrintTextCallback(System::String::Format("Event ProcedurePaused occurred - {0} - ExecutionState = {1} - ExecutionStateChangeReason = {2}",
1412  Util::Util::ToString(context->GetProcedure()->GetFullName()),
1413  Util::Util::ToString(context->GetExecutionState()),
1414  Util::Util::ToString(reason)));
1415  UpdateExecutionState(context, reason);
1416  if (reason == ExecutionStateChangeReason::UnexpectedDiagConnectionState)
1417  {
1418  ShowConnectionStateMessage(context);
1419  }
1420  }
1421 }
1422 
1423 void SampleForm::ProcedureContinuedCallback(CLRWrapper<IRuntimeContext*>^ clrContext)
1424 {
1425  if (InvokeRequired)
1426  {
1427  Invoke(gcnew System::Action<CLRWrapper<IRuntimeContext*>^>(this, &SampleForm::ProcedureContinuedCallback), clrContext);
1428  return;
1429  }
1430 
1431  msclr::lock l(piml->EventListenerLock.get());
1432  {
1433  IRuntimeContext* context = clrContext->GetPtr();
1434  PrintTextCallback(System::String::Format("Event ProcedureContinued occurred - {0} - ExecutionState = {1}",
1435  Util::Util::ToString(context->GetProcedure()->GetFullName()),
1436  Util::Util::ToString(context->GetExecutionState())));
1437  UpdateExecutionState(context);
1438  }
1439 }
1440 
1441 void SampleForm::ProcedureStoppedCallback(CLRWrapper<IRuntimeContext*>^ clrContext)
1442 {
1443  if (InvokeRequired)
1444  {
1445  Invoke(gcnew System::Action<CLRWrapper<IRuntimeContext*>^>(this, &SampleForm::ProcedureStoppedCallback), clrContext);
1446  return;
1447  }
1448 
1449  msclr::lock l(piml->EventListenerLock.get());
1450  {
1451  IRuntimeContext* context = clrContext->GetPtr();
1452  PrintTextCallback(System::String::Format("Event ProcedureStopped occurred - {0} - ExecutionState = {1}",
1453  Util::Util::ToString(context->GetProcedure()->GetFullName()),
1454  Util::Util::ToString(context->GetExecutionState())));
1455  UpdateExecutionState(context);
1456  }
1457 }
1458 
1459 void SampleForm::ProcedureTimeoutCallback(CLRWrapper<IRuntimeContext*>^ clrContext)
1460 {
1461  if (InvokeRequired)
1462  {
1463  Invoke(gcnew System::Action<CLRWrapper<IRuntimeContext*>^>(this, &SampleForm::ProcedureTimeoutCallback), clrContext);
1464  return;
1465  }
1466 
1467  msclr::lock l(piml->EventListenerLock.get());
1468  {
1469  IRuntimeContext* context = clrContext->GetPtr();
1470  PrintTextCallback(System::String::Format("Event ProcedureTimeout occurred - {0} - ExecutionState = {1}",
1471  Util::Util::ToString(context->GetProcedure()->GetFullName()),
1472  Util::Util::ToString(context->GetExecutionState())));
1473 
1474  UpdateExecutionState(context);
1475  }
1476 }
1477 
1478 void SampleForm::DiagConnectionStateChanged(ClampState batteryState, ClampState ignitionState)
1479 {
1480  cli::array<System::Object^>^ arr = gcnew cli::array<System::Object^>(2);
1481  arr[0] = gcnew CLRWrapper<ClampState>(batteryState);
1482  arr[1] = gcnew CLRWrapper<ClampState>(ignitionState);
1483  if (InvokeRequired)
1484  {
1485  Invoke(gcnew System::Action<cli::array<System::Object^>^>(this, &SampleForm::DiagConnectionStateChangedCallback), gcnew cli::array<System::Object^>{arr});
1486  }
1487  else
1488  {
1489  DiagConnectionStateChangedCallback(arr);
1490  }
1491 }
1492 
1493 void SampleForm::DiagConnectionStateChangedCallback(cli::array<System::Object^>^ arr)
1494 {
1495  if (arr == nullptr || arr->Length != 2)
1496  {
1497  return;
1498  }
1499 
1500  ClampState batteryState = Util::Util::CastToEnum<ClampState>(arr[0]);
1501  ClampState ignitionState = Util::Util::CastToEnum<ClampState>(arr[1]);
1502 
1503 
1504  msclr::lock l(piml->EventListenerLock.get());
1505  {
1506  PrintTextCallback(System::String::Format("Event DiagConnectionStateChanged occurred - BatteryState = {0}, IgnitionState = {1}",
1507  Util::Util::ToString(batteryState),
1508  Util::Util::ToString(ignitionState)));
1509  System::Media::SystemSounds::Beep->Play();
1510 
1511  SetBatteryIgnitionState(batteryState, ignitionState);
1512  }
1513 }
1514 
1515 // TODO: refactor. handle multithread?
1516 void SampleForm::ProcedureFinishedCallback(CLRWrapper<IRuntimeContext*>^ clrContext)
1517 {
1518  if (InvokeRequired)
1519  {
1520  Invoke(gcnew System::Action<CLRWrapper<IRuntimeContext*>^>(this, &SampleForm::ProcedureFinishedCallback), clrContext);
1521  return;
1522  }
1523 
1524  msclr::lock l(piml->EventListenerLock.get());
1525  {
1526  IRuntimeContext* context = clrContext->GetPtr();
1527  std::shared_ptr<IProcedureParameter> procedureParameter;
1528  std::string procedureName = context->GetProcedure()->GetFullName();
1529  std::string parameterOutput;
1530 
1531  for (int i = 0; i < context->GetProcedure()->GetParameters().size(); i++)
1532  {
1533  procedureParameter = context->GetProcedure()->GetParameters().at(i);
1534  parameterOutput = "Parameter Changed - " + procedureParameter->GetName() + "(" + procedureParameter->GetDataType() + ") = ";
1535 
1536  if (IS_NOT_NULL(procedureParameter->GetValue()))
1537  {
1538  parameterOutput += ShortenedValueString(procedureParameter->GetValue());
1539  }
1540  else
1541  {
1542  parameterOutput += "";
1543  }
1544 
1545  PrintTextCallback(Util::Util::ToString(parameterOutput));
1546  }
1547  System::DateTime duration = System::DateTime::Now.Subtract(System::TimeSpan(piml->RuntimeContextIdsExecutionStartTick[context->GetRuntimeId()]));
1548  UpdateGridviewParameter(context->GetProcedure());
1549 
1550  PrintTextCallback(System::String::Format("ProcedureFinished({0}) ExecutionState({1}) - Execution duration {2} - Running time {3} - Used memory {4})",
1551  Util::Util::ToString(context->GetProcedure()->GetFullName()),
1552  Util::Util::ToString(context->GetExecutionState()),
1553  duration.ToString("hh':'mm':'ss','fff"),
1554  System::TimeSpan::FromMilliseconds(context->GetExecutionTime()).ToString("hh':'mm':'ss','fff"),
1555  System::String::Format("{0:0,0} kB", context->GetProcessMemory() / 1024))
1556  );
1557 
1558  UpdateExecutionState(context);
1559 
1560  piml->CyclicExecuteAsyncIsProcessing = false;
1561  }
1562 }
1563 
1564 void SampleForm::ProcedureAbortedCallback(CLRWrapper<IRuntimeContext*>^ clrContext)
1565 {
1566  if (InvokeRequired)
1567  {
1568  Invoke(gcnew System::Action<CLRWrapper<IRuntimeContext*>^>(this, &SampleForm::ProcedureAbortedCallback), clrContext);
1569  return;
1570  }
1571 
1572  IRuntimeContext* context = clrContext->GetPtr();
1573  PrintTextCallback(System::String::Format("ProcedureAborted({0}) ExecutionState({1})",
1574  Util::Util::ToString(context->GetProcedure()->GetFullName()),
1575  Util::Util::ToString(context->GetExecutionState())));
1576 
1577  if (context->HasRuntimeException())
1578  {
1579  PrintException(context->GetRuntimeException(), "Reason: API ");
1580  }
1581 
1582  if (context->HasOtxException())
1583  {
1584  PrintException(context->GetOtxException(), "Reason: OTX ");
1585  }
1586  piml->CyclicExecuteAsyncIsProcessing = false;
1587  UpdateExecutionState(context);
1588 }
1589 
1590 void SampleForm::UpdateExecutionState(IRuntimeContext* context, ExecutionStateChangeReason reason)
1591 {
1592  if (context->GetExecutionState() == OpenTestSystem::Otx::Runtime::Api::ExecutionState::Paused)
1593  {
1594  piml->ProcedureExecutionCount--;
1595  if (reason == ExecutionStateChangeReason::Explicit)
1596  {
1597  DisplayProcedureExecutionState(context);
1598  }
1599 
1600  UpdatePauseButton(false, reason == ExecutionStateChangeReason::Explicit);
1601  }
1602  else
1603  {
1604  UpdateExecutionState(context);
1605  }
1606 }
1607 
1608 void SampleForm::UpdateExecutionState(IRuntimeContext* context)
1609 {
1610  if (context != nullptr)
1611  {
1612  System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(SampleForm::typeid));
1613 
1614  switch (context->GetExecutionState())
1615  {
1616  case ExecutionState::Running:
1617 
1618  piml->ProcedureExecutionCount++;
1619 
1620  AddRuntimeContext(context);
1621  DisplayProcedureExecutionState(context);
1622 
1623  buttonExecuteMain->Enabled = checkBoxAsyncExecution->Checked;
1624  buttonExecuteSelectedProcedure->Enabled = checkBoxAsyncExecution->Checked;
1625 
1626  UpdateExecutionStateButtons(true);
1627  UpdatePauseButton(true);
1628 
1629  break;
1630 
1631  case ExecutionState::Paused:
1632 
1633  piml->ProcedureExecutionCount--;
1634  UpdatePauseButton(false);
1635 
1636  break;
1637 
1638  case ExecutionState::Pending:
1639 
1640  DisplayProcedureExecutionState(context);
1641  UpdateExecutionStateButtons(true);
1642  UpdatePauseButton(true, false);
1643 
1644  break;
1645 
1646  case ExecutionState::Finished:
1647 
1648  piml->ProcedureExecutionCount--;
1649 
1650  RemoveRuntimeContext(context);
1651  DisplayProcedureExecutionState(context);
1652 
1653  buttonExecuteMain->Enabled = !checkBoxCyclicExecution->Checked;
1654  buttonExecuteSelectedProcedure->Enabled = !checkBoxCyclicExecution->Checked;
1655 
1656  UpdateExecutionStateButtons(false);
1657  UpdatePauseButton(true, false);
1658 
1659  labelBatteryState->Image = cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"IconBattery16"));
1660  labelVoltageThreshold->Image = cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"IconIgnition16"));
1661 
1662  break;
1663 
1664  case ExecutionState::Stopped:
1665 
1666  piml->ProcedureExecutionCount--;
1667 
1668  RemoveRuntimeContext(context);
1669  DisplayProcedureExecutionState(context);
1670 
1671  buttonExecuteMain->Enabled = true;
1672  buttonExecuteSelectedProcedure->Enabled = true;
1673 
1674  UpdateExecutionStateButtons(false);
1675  UpdatePauseButton(true, false);
1676 
1677  labelBatteryState->Image = cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"IconBattery16"));
1678  labelVoltageThreshold->Image = cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"IconIgnition16"));
1679 
1680  break;
1681 
1682  case ExecutionState::Aborted:
1683 
1684  piml->ProcedureExecutionCount--;
1685 
1686  RemoveRuntimeContext(context);
1687  DisplayProcedureExecutionState(context);
1688 
1689  buttonExecuteMain->Enabled = true;
1690  buttonExecuteSelectedProcedure->Enabled = true;
1691 
1692  UpdateExecutionStateButtons(false);
1693  UpdatePauseButton(true, false);
1694 
1695  labelBatteryState->Image = cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"IconBattery16"));
1696  labelVoltageThreshold->Image = cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"IconIgnition16"));
1697 
1698  break;
1699  case ExecutionState::Timeout:
1700 
1701  System::Media::SystemSounds::Hand->Play();
1702 
1703  piml->ProcedureExecutionCount--;
1704 
1705  RemoveRuntimeContext(context);
1706  DisplayProcedureExecutionState(context);
1707 
1708  buttonExecuteMain->Enabled = true;
1709  buttonExecuteSelectedProcedure->Enabled = true;
1710 
1711  UpdateExecutionStateButtons(false);
1712  UpdatePauseButton(true, false);
1713 
1714  labelBatteryState->Image = cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"IconBattery16"));
1715  labelVoltageThreshold->Image = cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"IconIgnition16"));
1716 
1717  break;
1718  }
1719 
1720  StartStopUpdateGuiTimer();
1721  }
1722 }
1723 
1724 void SampleForm::StartStopUpdateGuiTimer()
1725 {
1726  if (piml->ProcedureExecutionCount <= 0)
1727  {
1728  updateGuiTimer->Enabled = false;
1729  labelSeparator1->Visible = false;
1730  labelProcedureExecutionTimes->Visible = false;
1731  }
1732  else if (!updateGuiTimer->Enabled)
1733  {
1734  updateGuiTimer->Enabled = true;
1735  }
1736 }
1737 
1738 System::Void SampleForm::updateGuiTimer_Tick(System::Object^ sender, System::EventArgs^ e)
1739 {
1740  DisplayProcedureExecutionTimes();
1741 }
1742 
1743 void SampleForm::DisplayProcedureExecutionTimes()
1744 {
1745  System::String^ text = System::String::Empty;
1746 
1747  if (piml->RuntimeContextIdsExecutionStartTick.size() > 0)
1748  {
1749  for (std::map<long long, long long>::iterator itr = piml->RuntimeContextIdsExecutionStartTick.begin();
1750  itr != piml->RuntimeContextIdsExecutionStartTick.end(); ++itr)
1751  {
1752  System::TimeSpan duration = System::TimeSpan(System::DateTime::Now.Ticks - itr->second);
1753  text += System::String::Format("{0}: {1} |",
1754  Util::Util::ToString(GetRuntimeContext(itr->first)->GetProcedure()->GetName()),
1755  duration.ToString("mm':'ss"));
1756  }
1757  text = text->TrimEnd(gcnew cli::array<wchar_t>{' ', '|'});
1758  }
1759 
1760  labelProcedureExecutionTimes->Text = text;
1761  labelSeparator1->Visible = true;
1762  labelProcedureExecutionTimes->Visible = true;
1763 }
1764 
1765 void SampleForm::InOutParameterValueChanged(IRuntimeContext* context, IProcedureInOutParameter* parameter)
1766 {
1767  cli::array<System::Object^>^ arr = gcnew cli::array<System::Object^>(2);
1768  arr[0] = gcnew CLRWrapper<IRuntimeContext*>(context);
1769  arr[1] = gcnew CLRWrapper<IProcedureInOutParameter*>(parameter);
1770  if (InvokeRequired)
1771  {
1772  Invoke(gcnew System::Action<cli::array<System::Object^>^>(this, &SampleForm::InOutParameterValueChangedCallback), gcnew cli::array<System::Object^>{arr});
1773  }
1774  else
1775  {
1776  InOutParameterValueChangedCallback(arr);
1777  }
1778 }
1779 
1780 void SampleForm::InOutParameterValueChangedCallback(cli::array<System::Object^>^ arr)
1781 {
1782  if (arr == nullptr || arr->Length != 2)
1783  {
1784  return;
1785  }
1786 
1787  IRuntimeContext* context = Util::Util::CastTo<IRuntimeContext*>(arr[0]);
1788  IProcedureInOutParameter* parameter = Util::Util::CastTo<IProcedureInOutParameter*>(arr[1]);
1789 
1790  if (context == nullptr || parameter == nullptr)
1791  {
1792  return;
1793  }
1794 
1795  msclr::lock l(piml->EventListenerLock.get());
1796  {
1797  try
1798  {
1799  std::string valueStr = ShortenedValueString(parameter->GetValue());
1800  System::String^ message = System::String::Format("Parameter '{0}' new value = {1}",
1801  Util::Util::ToString(parameter->GetName()),
1802  Util::Util::ToString(valueStr));
1803  PrintTextCallback(message);
1804  UpdateGridviewParameter(context->GetProcedure());
1805  }
1806  catch (const std::exception& ex)
1807  {
1808  PrintTextCallback(Util::Util::ToString(ex.what()));
1809  }
1810  catch (System::InvalidCastException^ ex)
1811  {
1812  PrintTextCallback(ex->Message);
1813  }
1814  }
1815 }
1816 
1817 std::string SampleForm::ShortenedValueString(std::shared_ptr<DataTypes::Object> value)
1818 {
1819  try
1820  {
1821  std::string valueStr = ValueConverter::Value2String(value);
1822  if (valueStr.size() > piml->VALUE_STRING_MAX_LENGTH)
1823  {
1824  return valueStr.substr(0, piml->VALUE_STRING_MAX_LENGTH) + "...";
1825  }
1826 
1827  return valueStr;
1828  }
1829  catch (...)
1830  {
1831  }
1832 
1833  return "";
1834 }
1835 
1836 void SampleForm::UpdatePauseButton(bool pauseAvailable)
1837 {
1838  UpdatePauseButton(pauseAvailable, true);
1839 }
1840 
1841 void SampleForm::UpdatePauseButton(bool pauseAvailable, bool enabled)
1842 {
1843 #pragma region C++ for initialize resources
1844  System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(SampleForm::typeid));
1845 #pragma endregion
1846 
1847  buttonPause->Enabled = enabled;
1848  buttonPause->Checked = !pauseAvailable;
1849  buttonPause->Image = pauseAvailable ?
1850  (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"buttonPause.Image"))) :
1851  (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"buttonContinue.Image")));
1852 }
1853 
1854 void SampleForm::UpdateExecutionStateButtons(bool wasExecuted)
1855 {
1856  if (piml->UseConnectionState)
1857  {
1858  labelTimeout->Enabled = !wasExecuted;
1859  textBoxTimeout->Enabled = !wasExecuted;
1860  checkBoxUseConnectionState->Enabled = !wasExecuted;
1861  labelExpectedState->Enabled = !wasExecuted;
1862  checkBoxIgnition->Enabled = !wasExecuted;
1863  labelPollingTime->Enabled = !wasExecuted;
1864  textBoxPollingTime->Enabled = !wasExecuted;
1865  labelVoltageThreshold->Enabled = !wasExecuted;
1866  textBoxVoltageThreshold->Enabled = !wasExecuted;
1867  }
1868 
1869  if (wasExecuted)
1870  {
1871  if (checkBoxAsyncExecution->Checked == false)
1872  {
1873  buttonExecuteMain->Enabled = false;
1874  buttonExecuteSelectedProcedure->Enabled = false;
1875  }
1876 
1877  buttonStop->Enabled = true;
1878  }
1879  else
1880  {
1881  if (IS_NOT_NULL(piml->Project) && IS_NOT_NULL(piml->Project->GetMainProcedure()))
1882  {
1883  buttonExecuteMain->Enabled = true;
1884  }
1885 
1886  buttonExecuteSelectedProcedure->Enabled = true;
1887 
1888  buttonStop->Enabled = false;
1889  }
1890 }
1891 
1892 void SampleForm::DisplayProcedureExecutionState(IRuntimeContext* context)
1893 {
1894  DisplayProcedureExecutionState(context, "");
1895 }
1896 
1897 void SampleForm::DisplayProcedureExecutionState(IRuntimeContext* context, System::String^ errorMessage)
1898 {
1899 #pragma region C++ for intialize resource
1900  System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(SampleForm::typeid));
1901 #pragma endregion
1902 
1903  if (System::String::IsNullOrEmpty(errorMessage))
1904  {
1905  labelIconProcedureExecutionState->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"Info16")));
1906 
1907  if (piml->ProcedureExecutionCount <= 0)
1908  {
1909  piml->ProcedureExecutionCount = 0;
1910  if (context->GetExecutionState() == ExecutionState::Paused)
1911  {
1912  labelProcedureExecutionState->Text = "Execution is paused, click \"Continue\"...";
1913  }
1914  else
1915  {
1916  labelProcedureExecutionState->Text = "Select a procedure and click \"Start\"...";
1917  }
1918  }
1919  else if (piml->ProcedureExecutionCount == 1)
1920  {
1921  labelProcedureExecutionState->Text = "1 Procedure is running";
1922  }
1923  else
1924  {
1925  labelProcedureExecutionState->Text = System::String::Format("{0} Procedures are running", piml->ProcedureExecutionCount);
1926  }
1927  }
1928  else
1929  {
1930  labelIconProcedureExecutionState->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"Error16")));
1931  labelProcedureExecutionState->Text = errorMessage;
1932  }
1933 }
1934 
1935 void SampleForm::SyncWithParent(System::Object^ parentControl)
1936 {
1937  SyncWithParent(parentControl, nullptr);
1938 }
1939 
1940 void SampleForm::SyncWithParent(System::Object^ parentControl, System::Object^ control)
1941 {
1942  SyncWithParent(parentControl, control, false);
1943 }
1944 
1945 void SampleForm::SyncWithParent(System::Object^ parentControl, System::Object^ control, bool newThread)
1946 {
1947  if (parentControl != nullptr)
1948  {
1949  if (IS_NOT_NULL(piml->CreatorForm) && checkBoxStartAllParents->Checked)
1950  {
1951  if (Util::Util::IsInstance<System::Windows::Forms::Button^>(parentControl))
1952  {
1953  if (newThread)
1954  {
1955  System::Threading::ThreadPool::QueueUserWorkItem(gcnew System::Threading::WaitCallback(this, &SampleForm::ParentButtonClickCallback), parentControl);
1956  }
1957  else
1958  {
1959  ParentButtonClickCallback(parentControl);
1960  }
1961  }
1962  else if (Util::Util::IsInstance<System::Windows::Forms::TextBox^>(parentControl) && control != nullptr)
1963  {
1964  cli::array<System::Object^>^ state = gcnew cli::array<System::Object^>(2);
1965  state[0] = parentControl;
1966  state[1] = (dynamic_cast<System::Windows::Forms::Button^>(control))->Text;
1967  if (newThread)
1968  {
1969  System::Threading::ThreadPool::QueueUserWorkItem(gcnew System::Threading::WaitCallback(this, &SampleForm::ParentTextBoxSetTextCallback), state);
1970  }
1971  else
1972  {
1973  ParentTextBoxSetTextCallback(state);
1974  }
1975  }
1976  else if (Util::Util::IsInstance<System::Windows::Forms::CheckBox^>(parentControl) && control != nullptr)
1977  {
1978  cli::array<System::Object^>^ state = gcnew cli::array<System::Object^>(2);
1979  state[0] = parentControl;
1980  state[1] = (dynamic_cast<System::Windows::Forms::CheckBox^> (control))->CheckState;
1981  if (newThread)
1982  {
1983  System::Threading::ThreadPool::QueueUserWorkItem(gcnew System::Threading::WaitCallback(this, &SampleForm::ParentCheckBoxSetCheckStateCallback), state);
1984  }
1985  else
1986  {
1987  ParentCheckBoxSetCheckStateCallback(state);
1988  }
1989  }
1990  else if (Util::Util::IsInstance<System::Windows::Forms::ComboBox^>(parentControl) && control != nullptr)
1991  {
1992  cli::array<System::Object^>^ state = gcnew cli::array<System::Object^>(2);
1993  state[0] = parentControl;
1994  state[1] = (dynamic_cast<System::Windows::Forms::ComboBox^>(control))->SelectedIndex;
1995  if (newThread)
1996  {
1997  System::Threading::ThreadPool::QueueUserWorkItem(gcnew System::Threading::WaitCallback(this, &SampleForm::ParentComboBoxSetIndexCallback), state);
1998  }
1999  else
2000  {
2001  ParentComboBoxSetIndexCallback(state);
2002  }
2003  }
2004  else if (Util::Util::IsInstance<System::Windows::Forms::NumericUpDown^>(parentControl) && control != nullptr)
2005  {
2006  cli::array<System::Object^>^ state = gcnew cli::array<System::Object^>(2);
2007  state[0] = parentControl;
2008  state[1] = System::Decimal::ToInt32((dynamic_cast<System::Windows::Forms::NumericUpDown^>(control))->Value);
2009  if (newThread)
2010  {
2011  System::Threading::ThreadPool::QueueUserWorkItem(gcnew System::Threading::WaitCallback(this, &SampleForm::ParentNumericUpDownSetValueCallback), state);
2012  }
2013  else
2014  {
2015  ParentNumericUpDownSetValueCallback(state);
2016  }
2017  }
2018  }
2019  }
2020 }
2021 
2022 void SampleForm::ParentButtonClickCallback(System::Object^ state)
2023 {
2024  System::Windows::Forms::Button^ parentButton = dynamic_cast<System::Windows::Forms::Button^> (state);
2025  if (parentButton == nullptr)
2026  {
2027  return;
2028  }
2029 
2030  if (parentButton->InvokeRequired)
2031  {
2032  piml->CreatorForm->Invoke(gcnew System::Action<System::Object^>(this, &SampleForm::ParentButtonClickCallback), parentButton);
2033  }
2034  else
2035  {
2036  parentButton->PerformClick();
2037  }
2038 }
2039 
2040 void SampleForm::TextBoxSetTextCallback(cli::array<System::Object^>^ arr)
2041 {
2042  if (arr == nullptr || arr->Length != 2) return;
2043 
2044  System::Windows::Forms::TextBox^ parentTextBox = dynamic_cast<System::Windows::Forms::TextBox^>(arr[0]);
2045  System::Windows::Forms::TextBox^ textBox = dynamic_cast<System::Windows::Forms::TextBox^>(arr[1]);
2046 
2047  if (parentTextBox == nullptr || textBox == nullptr)
2048  {
2049  return;
2050  }
2051 
2052  parentTextBox->Text = textBox->Text;
2053 }
2054 
2055 void SampleForm::ParentTextBoxSetTextCallback(System::Object^ state)
2056 {
2057  cli::array<System::Object^>^ arr = dynamic_cast<cli::array<System::Object^>^>(state);
2058  if (arr == nullptr || arr->Length != 2) return;
2059 
2060  System::Windows::Forms::TextBox^ parentTextBox = dynamic_cast<System::Windows::Forms::TextBox^>(arr[0]);
2061  System::Windows::Forms::TextBox^ textBox = dynamic_cast<System::Windows::Forms::TextBox^>(arr[1]);
2062 
2063  if (parentTextBox == nullptr || textBox == nullptr)
2064  {
2065  return;
2066  }
2067 
2068  if (parentTextBox->InvokeRequired)
2069  {
2070  piml->CreatorForm->Invoke(gcnew System::Action<cli::array<System::Object^>^>(this, &SampleForm::TextBoxSetTextCallback), gcnew cli::array<System::Object^>{arr});
2071  }
2072  else
2073  {
2074  TextBoxSetTextCallback(arr);
2075  }
2076 }
2077 
2078 void SampleForm::CheckBoxSetCheckStateCallback(cli::array<System::Object^>^ arr)
2079 {
2080  if (arr == nullptr || arr->Length != 2)
2081  {
2082  return;
2083  }
2084 
2085  System::Windows::Forms::CheckBox^ parentCheckBox = dynamic_cast<System::Windows::Forms::CheckBox^>(arr[0]);
2086  System::Windows::Forms::CheckBox^ checkBox = dynamic_cast<System::Windows::Forms::CheckBox^>(arr[1]);
2087  if (parentCheckBox == nullptr || checkBox == nullptr)
2088  {
2089  return;
2090  }
2091 
2092  parentCheckBox->CheckState = checkBox->CheckState;
2093 }
2094 
2095 void SampleForm::ParentCheckBoxSetCheckStateCallback(System::Object^ state)
2096 {
2097  cli::array<System::Object^>^ arr = dynamic_cast<cli::array<System::Object^>^>(state);
2098  if (arr == nullptr || arr->Length != 2) return;
2099 
2100  System::Windows::Forms::CheckBox^ parentCheckBox = dynamic_cast<System::Windows::Forms::CheckBox^>(arr[0]);
2101  System::Windows::Forms::CheckBox^ checkBox = dynamic_cast<System::Windows::Forms::CheckBox^>(arr[1]);
2102 
2103  if (parentCheckBox == nullptr || checkBox == nullptr)
2104  {
2105  return;
2106  }
2107 
2108  if (checkBox->InvokeRequired)
2109  {
2110  piml->CreatorForm->Invoke(gcnew System::Action<cli::array<System::Object^>^>(this, &SampleForm::CheckBoxSetCheckStateCallback), gcnew cli::array<System::Object^>{arr});
2111  }
2112  else
2113  {
2114  CheckBoxSetCheckStateCallback(arr);
2115  }
2116 }
2117 
2118 void SampleForm::ComboBoxSetIndexCallback(cli::array<System::Object^>^ arr)
2119 {
2120  if (arr == nullptr || arr->Length != 2) return;
2121 
2122  System::Windows::Forms::ComboBox^ parentComboBox = dynamic_cast<System::Windows::Forms::ComboBox^>(arr[0]);
2123  System::Windows::Forms::ComboBox^ comboBox = dynamic_cast<System::Windows::Forms::ComboBox^>(arr[1]);
2124 
2125  if (parentComboBox == nullptr || comboBox == nullptr)
2126  {
2127  return;
2128  }
2129 
2130  parentComboBox->SelectedIndex = comboBox->SelectedIndex;
2131 }
2132 
2133 void SampleForm::ParentComboBoxSetIndexCallback(System::Object^ state)
2134 {
2135  cli::array<System::Object^>^ arr = dynamic_cast<cli::array<System::Object^>^>(state);
2136  if (arr == nullptr || arr->Length != 2) return;
2137 
2138  System::Windows::Forms::ComboBox^ parentComboBox = dynamic_cast<System::Windows::Forms::ComboBox^>(arr[0]);
2139  System::Windows::Forms::ComboBox^ comboBox = dynamic_cast<System::Windows::Forms::ComboBox^>(arr[1]);
2140 
2141  if (parentComboBox == nullptr || comboBox == nullptr)
2142  {
2143  return;
2144  }
2145 
2146  if (parentComboBox->InvokeRequired)
2147  {
2148  piml->CreatorForm->Invoke(gcnew System::Action<cli::array<System::Object^>^>(this, &SampleForm::ComboBoxSetIndexCallback), gcnew cli::array<System::Object^>{arr});
2149  }
2150  else
2151  {
2152  ComboBoxSetIndexCallback(arr);
2153  }
2154 }
2155 
2156 System::Void SampleForm::buttonBrowseTraceFolder_Click(System::Object^ sender, System::EventArgs^ e)
2157 {
2158  folderBrowserDialog1->SelectedPath = textBoxTraceFolder->Text;
2159  folderBrowserDialog1->ShowNewFolderButton = true;
2160 
2161  System::Windows::Forms::DialogResult result = folderBrowserDialog1->ShowDialog();
2162  if (result == System::Windows::Forms::DialogResult::OK)
2163  {
2164  textBoxTraceFolder->Text = folderBrowserDialog1->SelectedPath;
2165  }
2166 }
2167 
2168 System::Void SampleForm::buttonOpenTraceFolder_Click(System::Object^ sender, System::EventArgs^ e)
2169 {
2170  System::String^ path = textBoxTraceFolder->Text;
2171  if (System::IO::Directory::Exists(path))
2172  {
2173  System::Diagnostics::Process::Start(path);
2174  }
2175 }
2176 
2177 // This will not automatically update GUI if it is modified internally
2178 System::Void SampleForm::textBoxTraceFolder_TextChanged(System::Object^ sender, System::EventArgs^ e)
2179 {
2180  if (piml == nullptr || piml->GlobalRuntimeManager == nullptr)
2181  {
2182  return;
2183  }
2184 
2185  std::string path = Util::Util::ToString(textBoxTraceFolder->Text);
2186 
2187  if (path._Equal(RuntimeConfig::GetInstance().GetTraceFolder()) == false)
2188  {
2189  if (System::IO::Directory::Exists(Util::Util::ToString(path)))
2190  {
2191  RuntimeConfig::GetInstance().SetTraceFolder(Util::Util::ToString(textBoxTraceFolder->Text));
2192  buttonOpenTraceFolder->Enabled = true;
2193 
2194  PrintTextCallback("Set trace folder to " + Util::Util::ToString(RuntimeConfig::GetInstance().GetTraceFolder()));
2195  }
2196  else
2197  {
2198  buttonOpenTraceFolder->Enabled = false;
2199  }
2200  }
2201  else
2202  {
2203  buttonOpenTraceFolder->Enabled = true;
2204  }
2205 
2206  SyncWithParent(IS_NOT_NULL(piml->CreatorForm) ? piml->CreatorForm.get()->textBoxTraceFolder : nullptr, textBoxTraceFolder);
2207 }
2208 
2209 // This will not automatically update GUI if it is modified internally
2210 System::Void SampleForm::comboBoxTraceLevel_SelectedValueChanged(System::Object^ sender, System::EventArgs^ e)
2211 {
2212  if (piml->GlobalRuntimeManager == nullptr)
2213  {
2214  return;
2215  }
2216 
2217  TraceLevels traceLevel = Util::Util::ToTraceLevel(comboBoxTraceLevel->SelectedItem->ToString());
2218  if (traceLevel == RuntimeConfig::GetInstance().GetTraceLevel())
2219  {
2220  return;
2221  }
2222 
2223  RuntimeConfig::GetInstance().SetTraceLevel(traceLevel);
2224  PrintTextCallback("Updated trace level");
2225 }
2226 
2227 System::Void SampleForm::buttonBrowseFile_Click(System::Object^ sender, System::EventArgs^ e)
2228 {
2229  System::Windows::Forms::DialogResult result = openFileDialog1->ShowDialog();
2230  if (result == System::Windows::Forms::DialogResult::OK)
2231  {
2232  cbFilePath->Text = openFileDialog1->FileName;
2233 
2234  buttonReload->PerformClick();
2235  }
2236 }
2237 
2238 System::Void SampleForm::cbFilePath_TextChanged(System::Object^ sender, System::EventArgs^ e)
2239 {
2240  AddComboBoxFileOrPath(cbFilePath);
2241 
2242  if (System::String::IsNullOrWhiteSpace(cbFilePath->Text) || !System::IO::File::Exists(cbFilePath->Text->Trim()))
2243  {
2244  buttonReload->Enabled = false;
2245  }
2246  else
2247  {
2248  buttonReload->Enabled = true;
2249  }
2250 
2251  SyncWithParent(IS_NOT_NULL(piml->CreatorForm) ? piml->CreatorForm->cbFilePath : nullptr, cbFilePath);
2252 }
2253 
2254 System::Void SampleForm::cbFilePath_SelectedValueChanged(System::Object^ sender, System::EventArgs^ e)
2255 {
2256  if (System::String::IsNullOrWhiteSpace(cbFilePath->Text) || !System::IO::File::Exists(cbFilePath->Text->Trim()))
2257  {
2258  buttonReload->Enabled = false;
2259  }
2260  else
2261  {
2262  buttonReload->Enabled = true;
2263  if (piml->IsPathChanging == false)
2264  {
2265  buttonReload->PerformClick();
2266  }
2267  }
2268 
2269  SyncWithParent(IS_NOT_NULL(piml->CreatorForm) ? piml->CreatorForm->cbFilePath : nullptr, cbFilePath);
2270 }
2271 
2272 System::Void SampleForm::buttonReload_Click(System::Object^ sender, System::EventArgs^ e)
2273 {
2274  LoadContextFile(piml->GlobalRuntimeManager);
2275 
2276  SyncWithParent(IS_NOT_NULL(piml->CreatorForm) ? piml->CreatorForm->buttonReload : nullptr);
2277 }
2278 
2279 void SampleForm::LoadContextFile(std::shared_ptr<IRuntimeManager> runtimeManager)
2280 {
2281  if(System::String::IsNullOrWhiteSpace(cbFilePath->Text))
2282  {
2283  return;
2284  }
2285 
2286  PrintTextCallback("Load '" + cbFilePath->Text + "'...");
2287 
2288  if (runtimeManager == nullptr)
2289  {
2290  PrintTextCallback("... No RuntimeManager exists!");
2291  return;
2292  }
2293 
2294  if (System::String::IsNullOrWhiteSpace(cbFilePath->Text->Trim()))
2295  {
2296  PrintTextCallback(".. wrong file name.");
2297  return;
2298  }
2299 
2300  SetTitle(Util::Util::ToString(piml->Title));
2301 
2302  try
2303  {
2304  // TODO: move these 3 set up away
2305  piml->IsLoadding = true;
2306  piml->PlayerProject = nullptr;
2307  piml->Project = nullptr;
2308  piml->ContextVariableImplementation->ResetAllValues();
2309  piml->StateVariableImplementation->ResetAllValues();
2310  ClearSampleGUI();
2311 
2312  System::String^ filePathExtension = System::IO::Path::GetExtension(cbFilePath->Text->Trim());
2313  if (filePathExtension->Contains("ptx"))
2314  {
2315  piml->Project = LoadPtx(runtimeManager);
2316 
2317  if (IS_NOT_NULL(piml->Project)) // TODO: might be obsolete in the future
2318  {
2319  PrintTextCallback("... Project '" + Util::Util::ToString(piml->Project->GetName()) + "' successfully loaded.");
2320 
2321  ClearCustomImplemetationCaches();
2322 
2323  LoadPackage(piml->Project);
2324 
2325  ReadSettings(piml->Project->GetSettings());
2326 
2327  piml->IsLoadding = false;
2328  return;
2329  }
2330  }
2331  else if (filePathExtension->Contains("ppx"))
2332  {
2333  piml->PlayerProject = LoadPpx(runtimeManager);
2334 
2335  if (IS_NOT_NULL(piml->PlayerProject)) // TODO: might be obsolete in the future
2336  {
2337  ClearCustomImplemetationCaches();
2338 
2339  PrintTextCallback("... Player '" + Util::Util::ToString(piml->PlayerProject->GetName()) + "' successfully loaded.");
2340 
2341  std::vector<std::shared_ptr<Project::IProject>> projects = piml->PlayerProject->GetProjects();
2342  for (int i = 0; i < projects.size(); i++)
2343  {
2344  piml->Project = projects[i]; // TODO: what is this?
2345  LoadPackage(projects[i]);
2346  }
2347 
2348  ReadSettings(piml->PlayerProject->GetSettings());
2349 
2350  piml->IsLoadding = false;
2351  return;
2352  }
2353  }
2354  }
2355  catch (const std::exception& ex)
2356  {
2357  PrintException(ex);
2358  }
2359  catch (System::Exception^ ex)
2360  {
2361  PrintException(ex);
2362  }
2363 
2364  piml->IsLoadding = false;
2365 }
2366 
2367 void SampleForm::ClearSampleGUI()
2368 {
2369  treeViewOtxProject->Nodes->Clear();
2370  gridViewParameter->Rows->Clear();
2371  gridViewContext->Rows->Clear();
2372  gridViewState->Rows->Clear();
2373  gridViewSettings->Rows->Clear();
2374 }
2375 
2376 void SampleForm::ClearCustomImplemetationCaches()
2377 {
2378  piml->ClearCustomImplemetationCaches();
2379 }
2380 
2381 // TODO: refactor
2382 std::shared_ptr<Project::IProject> SampleForm::LoadPtx(std::shared_ptr<IRuntimeManager> runtimeManager)
2383 {
2384  std::shared_ptr<Project::IProject> project = nullptr;
2385 
2386  if (runtimeManager->IsProtected(Util::Util::ToString(cbFilePath->Text)))
2387  {
2388  project = runtimeManager->LoadPtx(Util::Util::ToString(cbFilePath->Text),
2389  Util::Util::ToString(txtPassword->Text->Trim()));
2390  }
2391  else
2392  {
2393  project = runtimeManager->LoadPtx(Util::Util::ToString(cbFilePath->Text));
2394  }
2395 
2396  if (project->GetMainProcedure()!=nullptr)
2397  {
2398  buttonExecuteMain->Enabled = true;
2399  }
2400 
2401  return project;
2402 }
2403 
2404 // TODO: refactor
2405 std::shared_ptr<Project::IPlayerProject> SampleForm::LoadPpx(std::shared_ptr<IRuntimeManager> runtimeManager)
2406 {
2407  std::shared_ptr<Project::IPlayerProject> playerProject = nullptr;
2408 
2409  if (runtimeManager->IsProtected(Util::Util::ToString(cbFilePath->Text)))
2410  {
2411  playerProject = runtimeManager->LoadPpx(
2412  Util::Util::ToString(cbFilePath->Text),
2413  Util::Util::ToString(txtPassword->Text->Trim()));
2414  }
2415  else
2416  {
2417  playerProject = runtimeManager->LoadPpx(
2418  Util::Util::ToString(cbFilePath->Text));
2419  }
2420 
2421  return playerProject;
2422 }
2423 
2424 // TODO: refactor
2425 void SampleForm::LoadPackage(std::shared_ptr<Project::IProject> project)
2426 {
2427  PrintTextCallback("Browse project...");
2428 
2429  std::vector<std::shared_ptr<Otx::Runtime::Api::Otx::IPackage>> packages = project->GetPackages();
2430  if (packages.size() == 0)
2431  {
2432  std::shared_ptr<IDocument> document = project->GetStartupDocument();
2433  treeViewOtxProject->Nodes->Add(CreateDocumentNode(document));
2434  }
2435  else
2436  {
2437  System::String^ treeNodeText = Util::Util::ToString(project->GetName());
2438  if (!System::String::IsNullOrWhiteSpace(Util::Util::ToString(piml->Project->GetVersion())))
2439  {
2440  treeNodeText = System::String::Format("{0} ({1})", treeNodeText, Util::Util::ToString(project->GetVersion()));
2441  }
2442 
2443  System::Windows::Forms::TreeNode^ root = gcnew System::Windows::Forms::TreeNode(treeNodeText);
2444  root->ImageKey = "ODFProject.bmp"; // TODO: move
2445  root->SelectedImageKey = "Package.bmp"; // TODO: move
2446  for (int i = 0; i < packages.size(); i++)
2447  {
2448  root->Nodes->Add(CreatePackageNode(packages[i]));
2449  }
2450 
2451  treeViewOtxProject->Nodes->Add(root);
2452  }
2453 
2454  treeViewOtxProject->Enabled = true;
2455  gridViewParameter->Enabled = true;
2456  treeViewOtxProject->ExpandAll();
2457  treeViewOtxProject->SelectedNode = piml->StartUpNode.get();
2458  treeViewOtxProject->Focus();
2459 
2460  PrintTextCallback("... project browsing finished.");
2461 }
2462 
2463 // TODO: refactor
2464 System::Windows::Forms::TreeNode^ SampleForm::CreateDocumentNode(std::shared_ptr<Otx::Runtime::Api::Otx::IDocument> doc)
2465 {
2466  System::Windows::Forms::TreeNode^ documentNode = gcnew System::Windows::Forms::TreeNode(Util::Util::ToString(doc->GetName()));
2467  documentNode->Tag = gcnew CLRWrapper<std::shared_ptr<Otx::Runtime::Api::Otx::IDocument>>(doc);
2468  documentNode->ImageKey = "DocumentOTX16.bmp";
2469  documentNode->SelectedImageKey = "DocumentOTX16.bmp";
2470  if (doc->IsStartup())
2471  {
2472  documentNode->Text += " (StartUp)";
2473  }
2474 
2475  std::vector<std::shared_ptr<Otx::Runtime::Api::Otx::IProcedure>> procedures = doc->GetProcedures();
2476  for (int i = 0; i < procedures.size(); i++)
2477  {
2478  System::Windows::Forms::TreeNode^ procedureNode = CreateProcedureName(procedures[i]);
2479  documentNode->Nodes->Add(procedureNode);
2480  if (doc->IsStartup() && procedures[i]->GetName()._Equal("main"))
2481  {
2482  piml->StartUpNode = procedureNode;
2483  buttonExecuteMain->Enabled = true;
2484  }
2485  else if (piml->StartUpNode.get() == nullptr)
2486  {
2487  piml->StartUpNode = procedureNode;
2488  }
2489  }
2490 
2491  return documentNode;
2492 }
2493 
2494 // TODO: refactor
2495 System::Windows::Forms::TreeNode ^ SampleForm::CreateProcedureName(std::shared_ptr<Otx::Runtime::Api::Otx::IProcedure> proc)
2496 {
2497  if (checkBoxCyclicReload->Checked &&
2498  IS_NOT_NULL(piml->ProcedureToExecute) &&
2499  piml->ProcedureToExecute->GetFullName()._Equal(proc->GetFullName()))
2500  {
2501  piml->ProcedureToExecute = proc;
2502  }
2503 
2504  System::Windows::Forms::TreeNode^ procedureNode = gcnew System::Windows::Forms::TreeNode(Util::Util::ToString(proc->GetName()));
2505  procedureNode->ImageKey= "Procedure.bmp"; // TODO: move
2506  procedureNode->SelectedImageKey= "Procedure.bmp"; // TODO: move
2507  procedureNode->Tag = gcnew CLRWrapper<std::shared_ptr<Otx::Runtime::Api::Otx::IProcedure>>(proc);
2508  return procedureNode;
2509 }
2510 
2511 System::Windows::Forms::TreeNode^ SampleForm::CreatePackageNode(std::shared_ptr<Otx::Runtime::Api::Otx::IPackage> pack)
2512 {
2513  System::Windows::Forms::TreeNode^ packageNode = gcnew System::Windows::Forms::TreeNode(Util::Util::ToString(pack->GetName()));
2514  packageNode->Tag = gcnew CLRWrapper<std::shared_ptr<Otx::Runtime::Api::Otx::IPackage>>(pack);
2515  packageNode->ImageKey = "Package.bmp"; // TODO: move
2516  packageNode->SelectedImageKey = "Package.bmp"; // TODO: move
2517 
2518  std::vector<std::shared_ptr<Otx::Runtime::Api::Otx::IDocument>> documents = pack->GetDocuments();
2519  for (int i = 0; i < documents.size(); i++)
2520  {
2521  packageNode->Nodes->Add(CreateDocumentNode(documents[i]));
2522  }
2523 
2524  std::vector<std::shared_ptr<IPackage>> packages = pack->GetPackages();
2525  for (int i = 0; i < packages.size(); i++)
2526  {
2527  packageNode->Nodes->Add(CreatePackageNode(packages[i]));
2528  }
2529 
2530  return packageNode;
2531 }
2532 
2533 System::Void SampleForm::gridView_CellContentClick(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e)
2534 {
2535  try
2536  {
2537  if (e != nullptr)
2538  {
2539  System::Windows::Forms::DataGridView^ gridView = dynamic_cast<System::Windows::Forms::DataGridView^>(sender);
2540  System::Windows::Forms::DataGridViewComboBoxCell^ comboBoxCell = dynamic_cast<System::Windows::Forms::DataGridViewComboBoxCell^>(gridView->Rows[e->RowIndex]->Cells[e->ColumnIndex]);
2541  if (comboBoxCell != nullptr)
2542  {
2543  gridView->BeginEdit(true);
2544  dynamic_cast<System::Windows::Forms::DataGridViewComboBoxEditingControl^>(gridView->EditingControl)->DroppedDown = true;
2545  return;
2546  }
2547  }
2548  }
2549  catch (...) {}
2550 
2551  gridView_CellValueChanged(sender, e);
2552 }
2553 
2554 // Commit new value for gridView's data source (only apply for DataGridViewCheckBoxCell and DataGridViewComboBoxCell)
2555 System::Void SampleForm::gridView_CellValueChanged(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e)
2556 {
2557  System::Windows::Forms::DataGridView^ gridView = dynamic_cast<System::Windows::Forms::DataGridView^>(sender);
2558  System::String^ columnName;
2559 
2560  if (gridView == gridViewParameter)
2561  {
2562  columnName = dataGridViewTextBoxColumnValue->Name;
2563  }
2564  else if (gridView == gridViewContext)
2565  {
2566  columnName = dataGridViewTextBoxColumnContextValue->Name;
2567  }
2568  else
2569  {
2570  return;
2571  }
2572 
2573  if (piml != nullptr &&
2574  !piml->IsLoadding &&
2575  e->RowIndex >= 0 &&
2576  gridView->Columns[e->ColumnIndex]->Name == columnName &&
2577  (
2578  Util::Util::IsInstance<System::Windows::Forms::DataGridViewCheckBoxCell^>(gridView->Rows[e->RowIndex]->Cells[columnName]) ||
2579  Util::Util::IsInstance<System::Windows::Forms::DataGridViewComboBoxCell^>(gridView->Rows[e->RowIndex]->Cells[columnName])
2580  )
2581  )
2582  {
2583  // Force a validation to set the value after CheckBox click
2584  Validate(false);
2585  }
2586 }
2587 
2588 // Convert parameter's value into valid string then display it on gridview
2589 System::Void SampleForm::gridViewParameter_CellValidated(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e)
2590 {
2591  System::Windows::Forms::DataGridView^ gridView = dynamic_cast<System::Windows::Forms::DataGridView^>(sender);
2592  if (piml != nullptr &&
2593  !piml->IsLoadding &&
2594  gridView != nullptr &&
2595  e->RowIndex >= 0 &&
2596  gridView->Columns[e->ColumnIndex]->Name == dataGridViewTextBoxColumnValue->Name)
2597  {
2598  std::shared_ptr<IProcedureParameter> parameter = Util::Util::CastTo<std::shared_ptr<IProcedureParameter>>(gridView->Rows[e->RowIndex]->Tag);
2599 
2600  if (parameter->GetValue() != nullptr)
2601  {
2602  gridView->Rows[e->RowIndex]->Cells[dataGridViewTextBoxColumnValue->Name]->Value = ConvertValue2String(parameter->GetValue());
2603  gridView->Rows[e->RowIndex]->Cells[dataGridViewTextBoxColumnDetails->Name]->Value = GetDetails(parameter->GetValue());
2604  }
2605  }
2606 }
2607 
2608 // Trigger if the "value" cell is changed, convert new string into new value,
2609 // then set into corresponding parameter (only apply for IProcedureInParameter and IProcedureInOutParameter)
2610 System::Void SampleForm::gridViewParameter_CellValidating(System::Object^ sender, System::Windows::Forms::DataGridViewCellValidatingEventArgs^ e)
2611 {
2612  System::Windows::Forms::DataGridView^ gridView = dynamic_cast<System::Windows::Forms::DataGridView^>(sender);
2613  if (piml != nullptr &&
2614  !piml->IsLoadding &&
2615  gridView != nullptr &&
2616  e->RowIndex >= 0 &&
2617  gridView->Columns[e->ColumnIndex]->Name == dataGridViewTextBoxColumnValue->Name &&
2618  !gridView->Rows[e->RowIndex]->ReadOnly &&
2619  e->FormattedValue != nullptr)
2620  {
2621  std::shared_ptr<IProcedureParameter> parameter = Util::Util::CastTo<std::shared_ptr<IProcedureParameter>>(gridView->Rows[e->RowIndex]->Tag);
2622  if (e->FormattedValue->ToString() == Util::Util::ToString(DataTypes::ValueConverter::Value2String(parameter->GetValue())) ||
2623  e->FormattedValue->ToString() == ConvertValue2String(parameter->GetValue()))
2624  {
2625  return;
2626  }
2627 
2628  std::shared_ptr<DataTypes::Object> value = nullptr;
2629 
2630  try
2631  {
2632  value = DataTypes::ValueConverter::String2Value(Util::Util::ToString(e->FormattedValue->ToString()), parameter->GetDataType());
2633  }
2634  catch (const std::exception& ex)
2635  {
2636  //string errorMsg = ex.GetType().FullName;
2637  //errorMsg += Environment.NewLine;
2638  //errorMsg += ex.Message;
2639  //gridView.Rows[e.RowIndex].Cells[1].ErrorText = errorMsg;
2640  PrintException(ex);
2641  // e.Cancel = true;
2642  return;
2643  }
2644  catch (System::Exception^ ex)
2645  {
2646  //string errorMsg = ex.GetType().FullName;
2647  //errorMsg += Environment.NewLine;
2648  //errorMsg += ex.Message;
2649  //gridView.Rows[e.RowIndex].Cells[1].ErrorText = errorMsg;
2650  PrintException(ex);
2651  // e.Cancel = true;
2652  return;
2653  }
2654 
2655  if (value == nullptr)
2656  {
2657  System::Media::SystemSounds::Exclamation->Play();
2658  }
2659  else
2660  {
2661  gridView->Rows[e->RowIndex]->Cells[dataGridViewTextBoxColumnDataType->Name]->ErrorText = System::String::Empty;
2662  if (std::shared_ptr<IProcedureInParameter> inParam = std::dynamic_pointer_cast<IProcedureInParameter>(parameter))
2663  {
2664  inParam->SetValue(value);
2665  }
2666  else if (std::shared_ptr<IProcedureInOutParameter> inOutParam = std::dynamic_pointer_cast<IProcedureInOutParameter>(parameter))
2667  {
2668  inOutParam->SetValue(value);
2669  }
2670  }
2671  }
2672 }
2673 
2674 System::Void SampleForm::gridViewContextVariable_CellValidated(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e)
2675 {
2676  System::Windows::Forms::DataGridView^ gridView = dynamic_cast<System::Windows::Forms::DataGridView^>(sender);
2677  if (piml != nullptr &&
2678  !piml->IsLoadding &&
2679  gridView != nullptr &&
2680  e->RowIndex >= 0 &&
2681  gridView->Columns[e->ColumnIndex]->Name == dataGridViewTextBoxColumnContextValue->Name)
2682  {
2683  std::shared_ptr<IContextVariable> context = Util::Util::CastTo<std::shared_ptr<IContextVariable>>(gridView->Rows[e->RowIndex]->Tag);
2684  if (gridView->Rows[e->RowIndex]->Cells[dataGridViewTextBoxColumnContextValue->Name]->Tag != nullptr)
2685  {
2686  gridView->Rows[e->RowIndex]->Cells[dataGridViewTextBoxColumnContextValue->Name]->Value = ConvertValue2String(Util::Util::CastTo<std::shared_ptr<DataTypes::Object>>(gridView->Rows[e->RowIndex]->Cells[dataGridViewTextBoxColumnContextValue->Name]->Tag));
2687  gridView->Rows[e->RowIndex]->Cells[dataGridViewTextBoxColumnContextDetails->Name]->Value = GetDetails(Util::Util::CastTo<std::shared_ptr<DataTypes::Object>>(gridView->Rows[e->RowIndex]->Cells[dataGridViewTextBoxColumnContextValue->Name]->Tag));
2688  }
2689  }
2690 }
2691 
2692 // TODO: refactor. consider update to use together with Parameter validating?
2693 System::Void SampleForm::gridViewContextVariable_CellValidating(System::Object^ sender, System::Windows::Forms::DataGridViewCellValidatingEventArgs^ e)
2694 {
2695  System::Windows::Forms::DataGridView^ gridView = dynamic_cast<System::Windows::Forms::DataGridView^>(sender);
2696  if (piml!=nullptr&&
2697  !piml->IsLoadding &&
2698  gridView != nullptr &&
2699  e->RowIndex >= 0 &&
2700  gridView->Columns[e->ColumnIndex]->Name == dataGridViewTextBoxColumnContextValue->Name &&
2701  !gridView->Rows[e->RowIndex]->ReadOnly &&
2702  e->FormattedValue != nullptr)
2703  {
2704  std::shared_ptr<IContextVariable> context = Util::Util::CastTo<std::shared_ptr<IContextVariable>>(gridView->Rows[e->RowIndex]->Tag);
2705 
2706  if (e->FormattedValue->ToString() == Util::Util::ToString(DataTypes::ValueConverter::Value2String(Util::Util::CastTo<std::shared_ptr<DataTypes::Object>>(gridView->Rows[e->RowIndex]->Cells[dataGridViewTextBoxColumnContextValue->Name]->Tag))) ||
2707  e->FormattedValue->ToString() == ConvertValue2String(Util::Util::CastTo<std::shared_ptr<DataTypes::Object>>(gridView->Rows[e->RowIndex]->Cells[dataGridViewTextBoxColumnContextValue->Name]->Tag)))
2708  {
2709  return;
2710  }
2711 
2712  std::shared_ptr<DataTypes::Object> value = nullptr;
2713 
2714  try
2715  {
2716  value = DataTypes::ValueConverter::String2Value(Util::Util::ToString(e->FormattedValue->ToString()), context->GetDataType());
2717  }
2718  catch (System::Exception^ ex)
2719  {
2720  //string errorMsg = ex.GetType().FullName;
2721  //errorMsg += Environment.NewLine;
2722  //errorMsg += ex.Message;
2723  //gridView.Rows[e.RowIndex].Cells[1].ErrorText = errorMsg;
2724  PrintException(ex);
2725  // e.Cancel = true;
2726  return;
2727  }
2728 
2729  if (value == nullptr)
2730  {
2731  System::Media::SystemSounds::Exclamation->Play();
2732  }
2733  else
2734  {
2735  //we will save value with fullName of context, if not the bug of #10798 occurs.
2736  //Because the name of context variable in imported document may have the same name.
2737  std::string fullNameContextVariable = context->GetDocument()->GetFullName() + "." + context->GetName();
2738  piml->ContextVariableImplementation->SetValue(fullNameContextVariable, value);
2739  piml->_ContextVariableOutputImpl->SetValue(fullNameContextVariable, value);
2740  gridView->Rows[e->RowIndex]->Cells[dataGridViewTextBoxColumnContextValue->Name]->Tag = gcnew CLRWrapper<std::shared_ptr<DataTypes::Object>>(value); // used at gridViewContextVariable_CellValidated
2741  gridView->Rows[e->RowIndex]->Cells[dataGridViewTextBoxColumnContextDataType->Name]->ErrorText = System::String::Empty; //refresh error text
2742  }
2743  }
2744 }
2745 
2746 System::Void SampleForm::treeViewOtxProject_AfterSelect(System::Object^ sender, System::Windows::Forms::TreeViewEventArgs^ e)
2747 {
2748  System::Windows::Forms::TreeNode^ node = e->Node;
2749  if (node != nullptr)
2750  {
2751  // TODO: move to different method
2752  gridViewParameter->Rows->Clear();
2753  gridViewContext->Rows->Clear();
2754  gridViewState->Rows->Clear();
2755 
2756  if (Util::Util::IsInstance<CLRWrapper<std::shared_ptr<IProcedure>>^>(node->Tag))
2757  {
2758  std::shared_ptr<IProcedure> procedure = Util::Util::CastTo<std::shared_ptr<IProcedure>>(node->Tag);
2759  ClearCustomImplemetationCaches();
2760  UpdateGridView(procedure);
2761 
2762  buttonExecuteSelectedProcedure->Enabled = true;
2763  piml->Project = GetProject(procedure); // TODO: why update this???
2764  return;
2765  }
2766  }
2767 
2768  buttonExecuteSelectedProcedure->Enabled = false;
2769 }
2770 
2771 // TODO: refactor
2772 std::shared_ptr<Project::IProject> SampleForm::GetProject(std::shared_ptr<IProcedure> procedure)
2773 {
2774  if (procedure != nullptr)
2775  {
2776  std::shared_ptr<IPackage> package = procedure->GetDocument()->GetPackage();
2777  if (package != nullptr)
2778  {
2779  while(package->GetParent() != nullptr)
2780  {
2781  package = package->GetParent();
2782  }
2783  return package->GetProject();
2784  }
2785  }
2786  return nullptr;
2787 }
2788 
2789 System::Void SampleForm::treeViewOtxProject_DrawNode(System::Object^ sender, System::Windows::Forms::DrawTreeNodeEventArgs^ e)
2790 {
2791  e->DrawDefault = true;
2792 }
2793 
2794 System::Void SampleForm::buttonReadSettings_Click(System::Object^ sender, System::EventArgs^ e)
2795 {
2796  std::map<std::string, std::string> settings;
2797  if (piml->PlayerProject!=nullptr)
2798  {
2799  settings = piml->PlayerProject->GetSettings();
2800  }
2801  else
2802  {
2803  settings = piml->Project->GetSettings();
2804  }
2805  ReadSettings(settings);
2806 }
2807 
2808 void SampleForm::ReadSettings(std::map<std::string, std::string> settings)
2809 {
2810  PrintTextCallback("Read settings");
2811 
2812  gridViewSettings->Rows->Clear();
2813 
2814  for(std::pair<std::string, std::string> it : settings)
2815  {
2816  cli::array<System::String^>^ values = {
2817  Util::Util::ToString(it.first),
2818  Util::Util::ToString(it.second)
2819  };
2820  gridViewSettings->Rows->Add(values);
2821  }
2822 }
2823 
2824 // TODO: refactor
2825 System::Void SampleForm::buttonWriteSettings_Click(System::Object^ sender, System::EventArgs^ e)
2826 {
2827  System::String^ nameSetting;
2828  System::String^ valueSetting;
2829  int selectedSettingPosition = 0;
2830  std::map<std::string, std::string> newSettings;
2831 
2832  if (gridViewSettings->SelectedRows->Count != 0)
2833  {
2834  selectedSettingPosition = gridViewSettings->SelectedRows[0]->Index;
2835  }
2836 
2837  try
2838  {
2839  if (IS_NOT_NULL(piml->Project) || IS_NOT_NULL(piml->PlayerProject))
2840  {
2841  for (int i = 0; i < gridViewSettings->Rows->Count; i++)
2842  {
2843  nameSetting = gridViewSettings->Rows[i]->Cells[dataGridViewTextBoxColumnSettingName->Name]->Value->ToString();
2844 
2845  System::Object^ cellSettingValueValue = gridViewSettings->Rows[i]->Cells[dataGridViewTextBoxColumnSettingValue->Name]->Value;
2846  valueSetting = cellSettingValueValue == nullptr ? nullptr : cellSettingValueValue->ToString();
2847 
2848  newSettings.insert({Util::Util::ToString(nameSetting),Util::Util::ToString(valueSetting)});
2849  }
2850 
2851  if (piml->PlayerProject != nullptr)
2852  {
2853  piml->PlayerProject->SetSettings(newSettings);
2854  ReadSettings(piml->PlayerProject->GetSettings()); //Refresh gridViewSettings
2855  }
2856  else
2857  {
2858  piml->Project->SetSettings(newSettings);
2859  ReadSettings(piml->Project->GetSettings()); //Refresh gridViewSettings
2860  }
2861  // focus on previous selected row
2862  gridViewSettings->Rows[selectedSettingPosition]->Selected = true;
2863  gridViewSettings->Rows[selectedSettingPosition]->Cells[dataGridViewTextBoxColumnSettingValue->Name]->Selected = true;
2864 
2865  PrintTextCallback("Write setting finished");
2866  }
2867  }
2868  catch (const std::exception& ex)
2869  {
2870  PrintException(ex);
2871  }
2872  catch (System::Exception^ ex)
2873  {
2874  PrintException(ex);
2875  }
2876 }
2877 
2878 System::Void SampleForm::checkBoxCyclicExecution_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
2879 {
2880  checkBoxCyclicReload->Enabled = checkBoxCyclicExecution->Checked;
2881  checkBoxNewRuntimeManager->Enabled = checkBoxCyclicExecution->Checked;
2882 
2883  if (!checkBoxCyclicExecution->Checked)
2884  {
2885  checkBoxCyclicReload->Checked = false;
2886  checkBoxNewRuntimeManager->Checked = false;
2887  }
2888 
2889  SyncWithParent(IS_NOT_NULL(piml->CreatorForm) ? piml->CreatorForm->checkBoxCyclicExecution : nullptr, checkBoxCyclicExecution);
2890 }
2891 
2892 System::Void SampleForm::checkBoxAsyncExecution_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
2893 {
2894  SyncWithParent(IS_NOT_NULL(piml->CreatorForm) ? piml->CreatorForm->checkBoxAsyncExecution : nullptr, checkBoxAsyncExecution);
2895 }
2896 
2897 System::Void SampleForm::checkBoxNewRuntimeManager_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
2898 {
2899  if (checkBoxNewRuntimeManager->Checked)
2900  {
2901  checkBoxCyclicReload->Checked = true;
2902  }
2903 
2904  SyncWithParent(IS_NOT_NULL(piml->CreatorForm) ? piml->CreatorForm->checkBoxNewRuntimeManager : nullptr, checkBoxNewRuntimeManager);
2905 }
2906 
2907 System::Void SampleForm::checkBoxCyclicReload_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
2908 {
2909  SyncWithParent(IS_NOT_NULL(piml->CreatorForm) ? piml->CreatorForm->checkBoxCyclicReload : nullptr, checkBoxCyclicReload);
2910 }
2911 
2912 System::Void SampleForm::buttonExecuteSelectedProcedure_Click(System::Object^ sender, System::EventArgs^ e)
2913 {
2914  try
2915  {
2916  if (treeViewOtxProject->SelectedNode != nullptr && Util::Util::IsInstance<CLRWrapper<std::shared_ptr<IProcedure>>^>(treeViewOtxProject->SelectedNode->Tag))
2917  {
2918  std::shared_ptr<IDocument> document = Util::Util::CastTo<std::shared_ptr<IDocument>>(treeViewOtxProject->SelectedNode->Parent->Tag);
2919 
2920  piml->ProcedureToExecute = Util::Util::CastTo<std::shared_ptr<IProcedure>>(treeViewOtxProject->SelectedNode->Tag);
2921  ExecuteProcedure();
2922  }
2923  else
2924  {
2925  PrintTextCallback("Please select Procedure to execute");
2926  }
2927  }
2928  catch (const std::exception& ex)
2929  {
2930  PrintException(ex);
2931  }
2932  catch (System::Exception^ ex)
2933  {
2934  PrintException(ex);
2935  }
2936 
2937  SyncWithParent(IS_NOT_NULL(piml->CreatorForm) ? piml->CreatorForm->buttonExecuteSelectedProcedure : nullptr, NULL, true);
2938 }
2939 
2940 // TODO: refactor
2941 System::Void SampleForm::buttonExecuteMain_Click(System::Object^ sender, System::EventArgs^ e)
2942 {
2943  try
2944  {
2945  if (IS_NOT_NULL(piml->Project))
2946  {
2947  treeViewOtxProject->SelectedNode = piml->StartUpNode.get();
2948  piml->ProcedureToExecute = piml->Project->GetMainProcedure();
2949  ExecuteProcedure();
2950  }
2951  else
2952  {
2953  PrintTextCallback("There is no project has been loaded. Please reload the project");
2954  }
2955  }
2956  catch (const std::exception& ex)
2957  {
2958  PrintException(ex);
2959  }
2960  catch (System::Exception^ ex)
2961  {
2962  PrintException(ex);
2963  }
2964 
2965  SyncWithParent(IS_NOT_NULL(piml->CreatorForm) ? piml->CreatorForm->buttonExecuteMain : nullptr, NULL, true);
2966 }
2967 
2968 // TODO: refactor
2969 void SampleForm::ExecuteProcedure()
2970 {
2971  PrintTextCallback("Start procedure execution...");
2972 
2973  if (checkBoxAsyncExecution->Checked == false)
2974  {
2975  buttonExecuteMain->Enabled = false;
2976  buttonExecuteSelectedProcedure->Enabled = false;
2977  }
2978 
2979  try
2980  {
2981  if (IS_NOT_NULL(piml->GlobalRuntimeManager) && IS_NOT_NULL(piml->ProcedureToExecute))
2982  {
2983  buttonStop->Enabled = true;
2984 
2985  CheckBatteryIgnitionState(piml->GlobalRuntimeManager);
2986 
2987  if (checkBoxCyclicExecution->Checked)
2988  {
2989  System::Threading::ThreadPool::QueueUserWorkItem(gcnew System::Threading::WaitCallback(this, &SampleForm::DoCyclic), nullptr);
2990  }
2991  else
2992  {
2993  //OtxDiagManager.OtxDiagApi.License.LicenseManager.SetLicenseKey(SampleConstants.LICENSE_KEY);
2994  if (checkBoxAsyncExecution->Checked)
2995  {
2996  piml->GlobalRuntimeManager->ExecuteAsync(
2997  Util::Util::ToString(textBoxRuntimeContextName->Text->Trim()),
2998  piml->ProcedureToExecute,
2999  piml->ExpectedConnectionState,
3000  System::Convert::ToUInt64(textBoxTimeout->Text->Trim())
3001  );
3002  }
3003  else
3004  {
3005  cli::array<System::Object^>^ args = gcnew cli::array<System::Object^>(4);
3006  args[0] = textBoxRuntimeContextName->Text->Trim();
3007  args[1] = gcnew CLRWrapper<std::shared_ptr<IProcedure>>(piml->ProcedureToExecute);
3008  args[2] = (int)piml->ExpectedConnectionState;
3009  args[3] = System::Convert::ToUInt64(textBoxTimeout->Text->Trim());
3010 
3011  System::Threading::Tasks::Task::Factory->StartNew(
3012  CallbackToAction::Convert(gcnew System::Action<cli::array<System::Object^>^>(this, &SampleForm::ExecuteProcedureSync),
3013  args));
3014  }
3015  }
3016  }
3017  else
3018  {
3019  PrintTextCallback("RuntimeManager is null or no Procedure is selected to run.");
3020  }
3021  }
3022  catch (System::Exception^ ex)
3023  {
3024  PrintException(ex);
3025 
3026  UpdateButtonStateAfterThrowException();
3027  }
3028 }
3029 
3030 void SampleForm::ExecuteProcedureSync(cli::array<System::Object^>^ args)
3031 {
3032  if (args->Length != 4)
3033  {
3034  return;
3035  }
3036 
3037  System::String^ runtimeContextName = dynamic_cast<System::String^>(args[0]);
3038  std::shared_ptr<IProcedure> procedureWrapper = Util::Util::CastTo<std::shared_ptr<IProcedure>>(args[1]);
3039  int expectedState = safe_cast<int>(args[2]);
3040  unsigned long long timeout = safe_cast<unsigned long long>(args[3]);
3041 
3042  if (procedureWrapper == nullptr)
3043  {
3044  return;
3045  }
3046 
3047  piml->GlobalRuntimeManager->Execute(
3048  Util::Util::ToString(runtimeContextName),
3049  procedureWrapper,
3050  (ExpectedState)expectedState,
3051  timeout);
3052 }
3053 
3054 void SampleForm::UpdateButtonStateAfterThrowException()
3055 {
3056 #pragma region C++ for initialize resource
3057  System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(SampleForm::typeid));
3058 #pragma endregion
3059 
3060  buttonExecuteMain->Enabled = !checkBoxAsyncExecution->Checked;
3061  buttonExecuteSelectedProcedure->Enabled = !checkBoxAsyncExecution->Checked;
3062 
3063  UpdateExecutionStateButtons(false);
3064  UpdatePauseButton(true, false);
3065 
3066  labelBatteryState->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"IconBattery16")));
3067  labelIgnitionState->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"IconIgnition16")));
3068 }
3069 
3070 // TODO: refactor
3071 void SampleForm::DoCyclic(System::Object^ args)
3072 {
3073  System::DateTime^ startTime = System::DateTime::Now;
3074 
3075  int cyclic = 0;
3076  try
3077  {
3078  while(checkBoxCyclicExecution->Checked)
3079  {
3080  std::shared_ptr<IRuntimeManager> runtimeManager = nullptr;
3081  std::shared_ptr<IRuntimeContext> runtimeContext = nullptr;
3082 
3083  cyclic++;
3084  piml->CyclicExecutionCount++;
3085 
3086  if (checkBoxNewRuntimeManager->Checked)
3087  {
3088  runtimeManager = CreateRuntimeManager();
3089  }
3090  else
3091  {
3092  runtimeManager = piml->GlobalRuntimeManager;
3093  }
3094 
3095  CheckCyclicReloadOrNewRuntimeManager(runtimeManager);
3096 
3097  piml->CyclicExecuteAsyncIsProcessing = true;
3098  CheckBatteryIgnitionState(piml->GlobalRuntimeManager);
3099 
3100  if (checkBoxAsyncExecution->Checked)
3101  {
3102  runtimeContext = runtimeManager->ExecuteAsync(
3103  Util::Util::ToString(textBoxRuntimeContextName->Text->Trim()),
3104  piml->ProcedureToExecute,
3105  piml->ExpectedConnectionState,
3106  safe_cast<unsigned long long>(System::Convert::ToInt32(textBoxTimeout->Text))
3107  );
3108  if (runtimeContext != nullptr)
3109  {
3110  //Let it break for a little bit to avoid freezing the GUI
3111  System::Windows::Forms::Application::DoEvents();
3112  System::Threading::Thread::Sleep(50);
3113  }
3114  }
3115  else
3116  {
3117  runtimeContext = runtimeManager->Execute(
3118  Util::Util::ToString(textBoxRuntimeContextName->Text->Trim()),
3119  piml->ProcedureToExecute,
3120  piml->ExpectedConnectionState,
3121  safe_cast<unsigned long long>(System::Convert::ToInt32(textBoxTimeout->Text))
3122  );
3123  }
3124 
3125  if (runtimeContext->GetExecutionState() == ExecutionState::Stopped)
3126  {
3127  piml->CyclicExecutionCount = 0;
3128  break;
3129  }
3130  }
3131  }
3132  catch (System::Exception^ ex)
3133  {
3134  PrintException(ex);
3135 
3136  UpdateButtonStateAfterThrowException();
3137  }
3138 
3139  //TODO: Do we need to load this again?
3140  Invoke(gcnew System::Action<CLRWrapper<std::shared_ptr<IRuntimeManager>>^>(this, &SampleForm::ReloadContextFileCallback), gcnew CLRWrapper<std::shared_ptr<IRuntimeManager>>(piml->GlobalRuntimeManager));
3141 
3142  PrintTextCallback("Cyclic execution finished");
3143 
3144  System::TimeSpan duration = System::TimeSpan(System::DateTime::Now.Ticks - startTime->Ticks);
3145  System::String^ text = System::String::Format("Execution Statistics: Duration {0} (hh:mm:ss) with {1} cycles and {2:0} ms per cycle",
3146  duration.ToString("hh':'mm':'ss"), cyclic, duration.TotalMilliseconds / cyclic);
3147 
3148  piml->CyclicExecutionCount -= cyclic;
3149  if (piml->CyclicExecutionCount < 0)
3150  {
3151  piml->CyclicExecutionCount = 0;
3152  }
3153 
3154  if (checkBoxAdd2Output->Checked)
3155  {
3156  PrintTextCallback(text);
3157  }
3158  else
3159  {
3160  System::Windows::Forms::MessageBox::Show(text);
3161  }
3162 }
3163 
3164 void SampleForm::WaitCyclicExecuteAsyncIsProcessing()
3165 {
3166  if (checkBoxCyclicReload->Checked || checkBoxNewRuntimeManager->Checked)
3167  {
3168  // OR while(!piml->RuntimeContext->IsFinished() || piml->RuntimeContext->IsStopped())
3169  while(piml->CyclicExecuteAsyncIsProcessing)
3170  {
3171  //detail in #10461
3172  System::Windows::Forms::Application::DoEvents();
3173  System::Threading::Thread::Sleep(50);
3174  }
3175  }
3176 }
3177 
3178 void SampleForm::CheckCyclicReloadOrNewRuntimeManager(std::shared_ptr<IRuntimeManager> runtimeManager)
3179 {
3180  CheckCyclicReloadOrNewRuntimeManager(runtimeManager, true);
3181 }
3182 
3183 void SampleForm::CheckCyclicReloadOrNewRuntimeManager(std::shared_ptr<IRuntimeManager> runtimeManager, bool waitCyclic)
3184 {
3185  if (waitCyclic)
3186  {
3187  WaitCyclicExecuteAsyncIsProcessing();
3188  }
3189 
3190  cli::array<System::Object^>^ arr = gcnew cli::array<System::Object^>(2);
3191  arr[0] = gcnew CLRWrapper<std::shared_ptr<IRuntimeManager>>(runtimeManager);
3192  arr[1] = waitCyclic;
3193 
3194  if (InvokeRequired)
3195  {
3196  Invoke(gcnew System::Action<cli::array<System::Object^>^>(this, &SampleForm::CheckCyclicReloadOrNewRuntimeManagerCallback), gcnew cli::array<System::Object^>{arr});
3197  }
3198  else
3199  {
3200  CheckCyclicReloadOrNewRuntimeManagerCallback(arr);
3201  }
3202 }
3203 
3204 void SampleForm::CheckCyclicReloadOrNewRuntimeManagerCallback(cli::array<System::Object^>^ arr)
3205 {
3206  if (arr == nullptr || arr->Length != 2)
3207  {
3208  return;
3209  }
3210 
3211  std::shared_ptr<IRuntimeManager> runtimeManager = Util::Util::CastTo<std::shared_ptr<IRuntimeManager>>(arr[0]);
3212  System::Boolean^ waitCyclic = dynamic_cast<System::Boolean^>(arr[1]);
3213 
3214  if (runtimeManager == nullptr || waitCyclic == nullptr)
3215  {
3216  return;
3217  }
3218 
3219  if (checkBoxCyclicReload->Checked || checkBoxNewRuntimeManager->Checked)
3220  {
3221  LoadContextFile(runtimeManager);
3222  }
3223 
3224  if (checkBoxCyclicExecution->Checked)
3225  {
3226  checkBoxCyclicExecution->Text = "Cyclic (" + piml->CyclicExecutionCount.ToString() + ")";
3227  }
3228  else
3229  {
3230  checkBoxCyclicExecution->Text = "Cyclic";
3231  }
3232 }
3233 
3234 // TODO: refactor
3235 System::Void SampleForm::buttonStop_Click(System::Object^ sender, System::EventArgs^ e)
3236 {
3237  if (piml->GlobalRuntimeManager != nullptr)
3238  {
3239  PrintTextCallback("Try to stop all running procedures...");
3240  piml->GlobalRuntimeManager->StopAll();
3241  piml->ProcedureExecutionCount = 0;
3242  }
3243 
3244  // To make sure that cyclic execution will stop in some cases
3245  checkBoxCyclicExecution->Checked = false;
3246 
3247  SyncWithParent(IS_NOT_NULL(piml->CreatorForm) ? piml->CreatorForm->buttonStop : nullptr);
3248 }
3249 
3250 void SampleForm::PrintException(System::Exception^ ex)
3251 {
3252  PrintException(ex, "");
3253 }
3254 
3255 void SampleForm::PrintException(System::Exception^ ex, System::String^ additionalText)
3256 {
3257  PrintTextCallback(System::String::Format("!!! {2}{0}: {1}", ex->GetType()->Name, ex->Message, additionalText));
3258  System::Media::SystemSounds::Hand->Play();
3259 }
3260 
3261 void SampleForm::PrintException(const std::exception& ex)
3262 {
3263  PrintException(ex, "");
3264 }
3265 
3266 void SampleForm::PrintException(const std::exception& ex, System::String^ additionalText)
3267 {
3268  PrintTextCallback(System::String::Format("!!! {2}{0}: {1}",
3269  "Exception",
3270  Util::Util::ToString(ex.what()),
3271  additionalText));
3272  System::Media::SystemSounds::Hand->Play();
3273 }
3274 
3275 void SampleForm::PrintTextCallback(System::String^ text)
3276 {
3277  if (InvokeRequired)
3278  {
3279  Invoke(gcnew System::Action<System::String^>(this, &SampleForm::PrintTextCallback), text);
3280  return;
3281  }
3282 
3283  if (!checkBoxAdd2Output->Checked)
3284  {
3285  return;
3286  }
3287 
3288  // TODO: handle multithreading?
3289  msclr::lock l(piml->PrintTextLock.get());
3290  {
3291  if (listBoxOuput->Items->Count >= 10000)
3292  {
3293  buttonClearOutput_Click(nullptr, nullptr);
3294  }
3295 
3296  System::String^ prefixString = GetTimeAndDurationStringSinceLastTimeAndUpdateLastTime();
3297  System::String^ itemToAdd = prefixString + text + "\t\t";
3298 
3299  listBoxOuput->Items->Add(itemToAdd);
3300  listBoxOuput->SelectedItems->Clear();
3301  listBoxOuput->TopIndex = listBoxOuput->Items->Count - 1;
3302 
3303  if (listBoxOuput->Items->Count >= 7500)
3304  {
3305  labelOutputOverflow->Visible = true;
3306  }
3307 
3308  // If many procedures are running simultaneously,
3309  // Stop button or other controls cannot receive events. This code allows controls to receive events.
3310  System::Windows::Forms::Application::DoEvents();
3311  }
3312 }
3313 
3314 System::String^ SampleForm::GetTimeAndDurationStringSinceLastTimeAndUpdateLastTime()
3315 {
3316  System::DateTime^ now = System::DateTime::Now;
3317  System::TimeSpan duration = System::TimeSpan(now->Ticks - piml->LastTime.get()->Ticks);
3318 
3319  piml->LastTime = now;
3320 
3321  System::String^ timeDurationString = System::String::Format("{0:HH:mm:ss.fff} {1,6:#,##0} ms ", now, duration.TotalMilliseconds);
3322  return timeDurationString;
3323 }
3324 
3325 System::Void SampleForm::buttonCopyRow_Click(System::Object^ sender, System::EventArgs^ e)
3326 {
3327  if (listBoxOuput->SelectedItems != nullptr)
3328  {
3329  System::String^ text = System::String::Empty;
3330  for (int i = 0; i < listBoxOuput->SelectedItems->Count; i++)
3331  {
3332  text += listBoxOuput->SelectedItems[i]->ToString()->Trim('\t') + "\n";
3333  }
3334 
3335  System::Windows::Forms::Clipboard::SetText(text);
3336  }
3337 }
3338 
3339 System::Void SampleForm::buttonClearOutput_Click(System::Object^ sender, System::EventArgs^ e)
3340 {
3341  listBoxOuput->Items->Clear();
3342  labelOutputOverflow->Visible = false;
3343  buttonCopyRow->Enabled = false;
3344 }
3345 
3346 void SampleForm::UpdateGridView(std::shared_ptr<IProcedure> procedure)
3347 {
3348  // || procedure->GetParameters() != nullptr
3349  if (procedure == nullptr)
3350  {
3351  return;
3352  }
3353 
3354  UpdateGridviewParameter(procedure);
3355 
3356  std::shared_ptr<Otx::Runtime::Api::Otx::IDocument> document = procedure->GetDocument();
3357  if (IS_NOT_NULL(document))
3358  {
3359  std::vector<std::string> listItemReviewed;
3360  UpdateGridViewContextVariable(document, false, listItemReviewed);
3361 
3362  listItemReviewed.clear();
3363  UpdateGridViewStateVariable(document, false, listItemReviewed);
3364  }
3365 }
3366 
3367 void SampleForm::UpdateGridviewParameter(std::shared_ptr<IProcedure> procedure)
3368 {
3369  std::vector<std::shared_ptr<IProcedureParameter>> parameters = procedure->GetParameters();
3370  for (int i = 0; i < parameters.size(); i++)
3371  {
3372  UpdateGridviewParameter(parameters[i]);
3373  }
3374 }
3375 
3376 // TODO: refactor
3377 void SampleForm::UpdateGridviewParameter(std::shared_ptr<IProcedureParameter> parameter)
3378 {
3379  if (IS_NOT_NULL(parameter) == false)
3380  {
3381  return;
3382  }
3383 
3384  bool bValueWasSet = false;
3385 
3386  // Update existing value
3387  System::String^ collumnName = dataGridViewTextBoxColumnName->Name;
3388  System::String^ collumnValue = dataGridViewTextBoxColumnValue->Name;
3389  System::String^ collumnDetails = dataGridViewTextBoxColumnDetails->Name;
3390  System::Windows::Forms::DataGridViewRowCollection^ rows = gridViewParameter->Rows;
3391  for (int i = 0; i < rows->Count; i++)
3392  {
3393  System::Windows::Forms::DataGridViewRow^ row = rows[i];
3394  if (row->Cells[collumnName]->Value->Equals(Util::Util::ToString(parameter->GetName())))
3395  {
3396  try
3397  {
3398  if (parameter->GetValue() != nullptr)
3399  {
3400  row->Cells[collumnValue]->Value = Util::Util::ToString(ValueConverter::Value2String(parameter->GetValue()));
3401  }
3402  }
3403  catch (System::Exception^ ex)
3404  {
3405  row->Cells[collumnName]->ErrorText = ex->Message;
3406  }
3407 
3408  bValueWasSet = true;
3409  break;
3410  }
3411  }
3412 
3413  // Add value if not exist
3414  if (!bValueWasSet)
3415  {
3416  System::String^ directory = std::dynamic_pointer_cast<IProcedureInParameter>(parameter) ? "In" :
3417  (std::dynamic_pointer_cast<IProcedureInOutParameter>(parameter) ?
3418  "InOut" : "Out");
3419 
3420  cli::array<System::Object^>^ values = {
3421  Util::Util::ToString(parameter->GetName()),
3422  directory,
3423  Util::Util::ToString(parameter->GetDataType())
3424  };
3425  int index = gridViewParameter->Rows->Add(values);
3426 
3427  gridViewParameter->Rows[index]->Tag = gcnew CLRWrapper<std::shared_ptr<Otx::Runtime::Api::Otx::IProcedureParameter>>(parameter);
3428 
3429  gridViewParameter->Rows[index]->ReadOnly = std::dynamic_pointer_cast<IProcedureOutParameter>(parameter) != nullptr || parameter->GetInitValue() == nullptr;
3430 
3431  if(parameter->GetDataType()._Equal("Boolean"))
3432  {
3433  System::Windows::Forms::DataGridViewCheckBoxCell^ cell = gcnew System::Windows::Forms::DataGridViewCheckBoxCell();
3434  cell->Value = ConvertValue2String(parameter->GetValue());
3435  cell->Tag = gcnew CLRWrapper<std::shared_ptr<Otx::Runtime::Api::DataTypes::Object>>(parameter->GetValue());
3436  cell->Style->NullValue = false;
3437  cell->TrueValue = true;
3438  cell->FalseValue = false;
3439  gridViewParameter->Rows[index]->Cells[collumnValue] = cell;
3440  }
3441  else if (std::shared_ptr<DataTypes::EnumerationElement> enumerationElement = std::dynamic_pointer_cast<DataTypes::EnumerationElement>(parameter->GetValue())) // Enumeration type
3442  {
3443  gridViewParameter->Rows[index]->Cells[collumnValue] = gcnew System::Windows::Forms::DataGridViewComboBoxCell();
3444  System::Windows::Forms::DataGridViewComboBoxCell^ cell = dynamic_cast<System::Windows::Forms::DataGridViewComboBoxCell^>(gridViewParameter->Rows[index]->Cells[collumnValue]);
3445  cell->DisplayStyle = System::Windows::Forms::DataGridViewComboBoxDisplayStyle::ComboBox;
3446  cell->FlatStyle = System::Windows::Forms::FlatStyle::Flat;
3447  cell->DisplayMember = "Name";
3448  cell->ValueMember = "Name";
3449  cell->DataSource = Util::Util::ArrayEnumerationElements2String(enumerationElement->GetEnumeration()->GetElements());
3450  cell->Value = ConvertValue2String(parameter->GetValue());
3451  cell->Tag = gcnew CLRWrapper<std::shared_ptr<DataTypes::Object>>(parameter->GetValue());
3452  }
3453  else
3454  {
3455  try
3456  {
3457  if (parameter->GetValue() != nullptr)
3458  {
3459  gridViewParameter->Rows[index]->Cells[collumnValue]->Value = ConvertValue2String(parameter->GetValue());
3460  }
3461  }
3462  catch (System::Exception^ ex)
3463  {
3464  gridViewParameter->Rows[index]->Cells[collumnValue]->ErrorText = ex->Message;
3465  }
3466  }
3467 
3468  gridViewParameter->Rows[index]->Cells[collumnDetails]->Value = GetDetails(parameter->GetValue());
3469  }
3470 }
3471 
3472 System::String^ SampleForm::ConvertValue2String(std::shared_ptr<DataTypes::Object> value)
3473 {
3474  if (value==nullptr)
3475  {
3476  return System::String::Empty;
3477  }
3478 
3479  return Util::Util::ToString(ValueConverter::Value2String(value));
3480 }
3481 
3482 System::String^ SampleForm::GetDetails(std::shared_ptr<DataTypes::Object> value)
3483 {
3484  if (value == nullptr)
3485  {
3486  return System::String::Empty;
3487  }
3488 
3489  if (std::shared_ptr<DataTypes::TranslationKey> translationKey = std::dynamic_pointer_cast<DataTypes::TranslationKey>(value))
3490  {
3491  if (!translationKey->GetTextIdMappingName().empty())
3492  {
3493  return System::String::Format("MappingName: {0}", Util::Util::ToString(translationKey->GetTextIdMappingName()));
3494  }
3495  }
3496  else if (std::shared_ptr<DataTypes::EnumerationElement> enumerationElement = std::dynamic_pointer_cast<DataTypes::EnumerationElement>(value))
3497  {
3498  if (IS_NOT_NULL(enumerationElement->GetTranslationKey()))
3499  {
3500  if (!enumerationElement->GetTranslationKey()->GetTextId().empty() && !enumerationElement->GetTranslationKey()->GetTextIdMappingName().empty())
3501  {
3502  return System::String::Format("TextId: {0}, MappingName: {1}",
3503  Util::Util::ToString(enumerationElement->GetTranslationKey()->GetTextId()),
3504  Util::Util::ToString(enumerationElement->GetTranslationKey()->GetTextIdMappingName()));
3505  }
3506  else if (!enumerationElement->GetTranslationKey()->GetTextId().empty())
3507  {
3508  return System::String::Format("TextId: {0}",
3509  Util::Util::ToString(enumerationElement->GetTranslationKey()->GetTextId()));
3510  }
3511 
3512  return System::String::Format("MappingName: {0}",
3513  Util::Util::ToString(enumerationElement->GetTranslationKey()->GetTextIdMappingName()));
3514  }
3515  }
3516 
3517  return System::String::Empty;
3518 }
3519 
3520 // TODO: refactor
3521 void SampleForm::UpdateGridViewContextVariable(std::shared_ptr<IDocument> document, bool withPrefix, std::vector<std::string>& listItemReviewed)
3522 {
3523  std::string documentFullName = document->GetPackage()->GetName() + "." + document->GetName();
3524  if (std::find(listItemReviewed.begin(), listItemReviewed.end(), documentFullName) != listItemReviewed.end())
3525  {
3526  return;
3527  }
3528 
3529  listItemReviewed.push_back(documentFullName);
3530  for (int i = 0; i < document->GetContextVariables().size(); i++)
3531  {
3532  std::shared_ptr<IContextVariable> contextVariable = document->GetContextVariables().at(i);
3533 
3534  if (contextVariable == nullptr)
3535  {
3536  return;
3537  }
3538 
3539  bool bValueWasSet = false;
3540 
3541  // Update existing value
3542  for (int i = 0; i < gridViewContext->Rows->Count; i++)
3543  {
3544  System::Windows::Forms::DataGridViewRow^ row = gridViewContext->Rows[i];
3545 
3546  if (row->Cells[dataGridViewTextBoxColumnContextName->Name]->Value != nullptr &&
3547  row->Cells[dataGridViewTextBoxColumnContextName->Name]->Value->Equals(withPrefix ?
3548  Util::Util::ToString(document->GetPackage()->GetFullName() + "." + document->GetName() + "." + contextVariable->GetName()) :
3549  Util::Util::ToString(contextVariable->GetName())))
3550  {
3551  if (radioButtonDefaultImplementation->Checked)
3552  {
3553  std::shared_ptr<DataTypes::Object> contextVariableValue = piml->ContextVariableImplementation->GetValue(nullptr, contextVariable, nullptr);
3554  row->Cells[dataGridViewTextBoxColumnContextValue->Name]->Value = IS_NOT_NULL(contextVariableValue) ?
3555  ConvertValue2String(contextVariableValue) :
3556  nullptr;
3557  }
3558  else
3559  {
3560  row->Cells[dataGridViewTextBoxColumnContextValue->Name]->Value = IS_NOT_NULL(contextVariable->GetInitValue()) ?
3561  ConvertValue2String(contextVariable->GetInitValue()) :
3562  nullptr;
3563  }
3564 
3565  bValueWasSet = true;
3566  break;
3567  }
3568  }
3569 
3570  // Add value if not exist
3571  if (!bValueWasSet)
3572  {
3573  cli::array<System::String^>^ values = nullptr;
3574  values = gcnew cli::array<System::String^>{
3575  withPrefix ? Util::Util::ToString(document->GetPackage()->GetFullName() + "." + document->GetName() + "." + contextVariable->GetName()) :
3576  Util::Util::ToString(contextVariable->GetName()),
3577  Util::Util::ToString(contextVariable->GetDataType())
3578  };
3579  int index = gridViewContext->Rows->Add(values);
3580 
3581  std::shared_ptr<DataTypes::Object> contextVariableValue = contextVariable->GetInitValue();
3582 
3583  gridViewContext->Rows[index]->Tag = gcnew CLRWrapper<std::shared_ptr<Otx::Runtime::Api::Otx::IContextVariable>>(contextVariable);
3584  gridViewContext->Rows[index]->ReadOnly = contextVariable->GetInitValue() == nullptr;
3585  gridViewContext->Rows[index]->Cells[dataGridViewTextBoxColumnContextValue->Name]->Tag = gcnew CLRWrapper<std::shared_ptr<Otx::Runtime::Api::DataTypes::Object>>(contextVariable->GetInitValue());
3586  if (contextVariable->GetDataType()._Equal("Boolean"))
3587  {
3588  System::Windows::Forms::DataGridViewCheckBoxCell^ cell = gcnew System::Windows::Forms::DataGridViewCheckBoxCell();
3589  cell->Value = ConvertValue2String(contextVariableValue);
3590  gridViewContext->Rows[index]->Cells[dataGridViewTextBoxColumnContextValue->Name] = cell;
3591  cell->Tag = gcnew CLRWrapper<std::shared_ptr<DataTypes::Object>>(contextVariableValue);
3592  cell->Style->NullValue = false;
3593  cell->TrueValue = true;
3594  cell->FalseValue = false;
3595  }
3596  else if (std::shared_ptr<DataTypes::EnumerationElement> enumerationElement = std::dynamic_pointer_cast<DataTypes::EnumerationElement>(contextVariableValue)) // Enumeration type
3597  {
3598  gridViewContext->Rows[index]->Cells[dataGridViewTextBoxColumnContextValue->Name] = gcnew System::Windows::Forms::DataGridViewComboBoxCell();
3599  System::Windows::Forms::DataGridViewComboBoxCell^ cell = dynamic_cast<System::Windows::Forms::DataGridViewComboBoxCell^>(gridViewContext->Rows[index]->Cells[dataGridViewTextBoxColumnContextValue->Name]);
3600  cell->DisplayStyle = System::Windows::Forms::DataGridViewComboBoxDisplayStyle::ComboBox;
3601  cell->FlatStyle = System::Windows::Forms::FlatStyle::Flat;
3602  cell->DisplayMember = "Name";
3603  cell->ValueMember = "Name";
3604  cell->DataSource = Util::Util::ArrayEnumerationElements2String(enumerationElement->GetEnumeration()->GetElements());;
3605  cell->Value = ConvertValue2String(contextVariableValue);
3606  cell->Tag = gcnew CLRWrapper<std::shared_ptr<DataTypes::Object>>(contextVariableValue);
3607  }
3608  else
3609  {
3610  try
3611  {
3612  if (IS_NOT_NULL(contextVariableValue))
3613  {
3614  gridViewContext->Rows[index]->Cells[dataGridViewTextBoxColumnContextValue->Name]->Value = ConvertValue2String(contextVariableValue);
3615  }
3616  else
3617  {
3618  gridViewContext->Rows[index]->Cells[dataGridViewTextBoxColumnContextValue->Name]->Value = nullptr;
3619  }
3620  }
3621  catch (System::Exception^ ex)
3622  {
3623  gridViewContext->Rows[index]->Cells[dataGridViewTextBoxColumnContextValue->Name]->ErrorText = ex->Message;
3624  }
3625  }
3626 
3627  gridViewContext->Rows[index]->Cells[dataGridViewTextBoxColumnContextDetails->Name]->Value = GetDetails(contextVariableValue);
3628  }
3629  }
3630 
3631  try
3632  {
3633  std::vector<std::shared_ptr<IDocument>> importDocs = document->GetImports();
3634  for (int i = 0; i < importDocs.size(); i++)
3635  {
3636  UpdateGridViewContextVariable(importDocs[i], true, listItemReviewed);
3637  }
3638  }
3639  catch (System::Exception^ ex)
3640  {
3641  PrintException(ex);
3642  }
3643 }
3644 
3645 // TODO: refactor this
3646 void SampleForm::StateVariableValueChanged(std::shared_ptr<IStateVariable> stateVariable, std::shared_ptr<DataTypes::Object> value)
3647 {
3648  cli::array<System::Object^>^ arr = gcnew cli::array<System::Object^>(2);
3649  arr[0] = gcnew CLRWrapper<std::shared_ptr<IStateVariable>>(stateVariable);
3650  arr[1] = gcnew CLRWrapper<std::shared_ptr<DataTypes::Object>>(value);
3651 
3652  if (InvokeRequired)
3653  {
3654  Invoke(gcnew System::Action<cli::array<System::Object^>^>(this, &SampleForm::StateVariableValueChangedCallback), gcnew cli::array<System::Object^>{arr});
3655  }
3656  else
3657  {
3658  StateVariableValueChangedCallback(arr);
3659  }
3660 }
3661 
3662 // TODO: refactor this
3663 void SampleForm::StateVariableValueChangedCallback(cli::array<System::Object^>^ arr)
3664 {
3665  if (arr == nullptr || arr->Length != 2) return;
3666 
3667  std::shared_ptr<IStateVariable> stateVariable = Util::Util::CastTo<std::shared_ptr<IStateVariable>>(arr[0]);
3668  std::shared_ptr<DataTypes::Object> value = Util::Util::CastTo<std::shared_ptr<DataTypes::Object>>(arr[1]);
3669 
3670  if (stateVariable == nullptr || value == nullptr)
3671  {
3672  return;
3673  }
3674 
3675  System::String^ mappingStr = System::String::Format("[MappedTo: {0}{1}",
3676  Util::Util::ToString(stateVariable->GetMappingName()),
3677  stateVariable->GetMappingIndex() > -1 ? ("[" + stateVariable->GetMappingIndex() + "]") : System::String::Empty);
3678  System::String^ strValue = "null";
3679  try
3680  {
3681  strValue = Util::Util::ToString(ValueConverter::Value2String(value));
3682  }
3683  catch (...)
3684  {
3685  }
3686 
3687  System::String^ outputLog = System::String::Format("StateVariableChanged({0} {1}.{2}{3} = {4})",
3688  Util::Util::ToString(stateVariable->GetDataType()),
3689  Util::Util::ToString(stateVariable->GetDocument()->GetFullName()),
3690  Util::Util::ToString(stateVariable->GetName()),
3691  mappingStr,
3692  strValue);
3693  PrintTextCallback(outputLog);
3694  UpdateGridViewStateVariable(stateVariable);
3695 }
3696 
3697 void SampleForm::ContextVariableRead(std::shared_ptr<IContextVariable> contextVariable, std::shared_ptr<DataTypes::Object> value)
3698 {
3699  cli::array<System::Object^>^ arr = gcnew cli::array<System::Object^>(2);
3700  arr[0] = gcnew CLRWrapper<std::shared_ptr<IContextVariable>>(contextVariable);
3701  arr[1] = gcnew CLRWrapper<std::shared_ptr<DataTypes::Object>>(value);
3702 
3703  if (InvokeRequired)
3704  {
3705  Invoke(gcnew System::Action<cli::array<System::Object^>^>(this, &SampleForm::ContextVariableReadCallback), gcnew cli::array<System::Object^>{arr});
3706  }
3707  else
3708  {
3709  ContextVariableReadCallback(arr);
3710  }
3711 }
3712 
3713 void SampleForm::ContextVariableReadCallback(cli::array<System::Object^>^ arr)
3714 {
3715  if (arr == nullptr || arr->Length != 2) return;
3716 
3717  std::shared_ptr<IContextVariable> contextVariable = Util::Util::CastTo<std::shared_ptr<IContextVariable>>(arr[0]);
3718  std::shared_ptr<DataTypes::Object> value = Util::Util::CastTo<std::shared_ptr<DataTypes::Object>>(arr[1]);
3719 
3720  if (contextVariable == nullptr || value == nullptr)
3721  {
3722  return;
3723  }
3724 
3725  System::String^ mappingStr = System::String::Format("[MappedTo: {0}{1}",
3726  Util::Util::ToString(contextVariable->GetMappingName()),
3727  (contextVariable->GetMappingIndex() > -1 ? ("[" + contextVariable->GetMappingIndex() + "]") : System::String::Empty));
3728  System::String^ strValue = "null";
3729  try
3730  {
3731  strValue = Util::Util::ToString(ValueConverter::Value2String(value));
3732  }
3733  catch (...)
3734  {
3735  }
3736  System::String^ outputLog = System::String::Format("ContextVariableRead({0} {1}.{2}{3} = {4})",
3737  Util::Util::ToString(contextVariable->GetDataType()),
3738  Util::Util::ToString(contextVariable->GetDocument()->GetFullName()),
3739  Util::Util::ToString(contextVariable->GetName()),
3740  mappingStr,
3741  strValue);
3742 
3743  PrintTextCallback(outputLog);
3744 }
3745 
3746 void SampleForm::UpdateGridViewStateVariable(std::shared_ptr<IDocument> document, bool withPrefix, std::vector<std::string>& listItemReviewed)
3747 {
3748  std::string documentFullName = document->GetPackage()->GetName() + "." + document->GetName();
3749  if (std::find(listItemReviewed.begin(), listItemReviewed.end(), documentFullName) != listItemReviewed.end())
3750  {
3751  return;
3752  }
3753 
3754  listItemReviewed.push_back(documentFullName);
3755  std::vector<std::shared_ptr<IStateVariable>> stateVariables = document->GetStateVariables();
3756  for (int i = 0; i < stateVariables.size(); i++)
3757  {
3758  std::shared_ptr<IStateVariable> stateVariable = stateVariables[i];
3759  cli::array<System::String^>^ values = nullptr;
3760  values = gcnew cli::array<System::String^>{
3761  withPrefix ? Util::Util::ToString(document->GetPackage()->GetFullName() + "." + document->GetName() + "." + stateVariable->GetName()) :
3762  Util::Util::ToString(stateVariable->GetName()),
3763  Util::Util::ToString(stateVariable->GetDataType())
3764  };
3765  int index = gridViewState->Rows->Add(values);
3766 
3767  gridViewState->Rows[index]->Tag = gcnew CLRWrapper<std::shared_ptr<Otx::Runtime::Api::Otx::IStateVariable>>(stateVariable);
3768 
3769  if (stateVariable->GetDataType()._Equal("Boolean"))
3770  {
3771  gridViewState->Rows[index]->Cells[dataGridViewTextBoxColumnStateValue->Name] = gcnew System::Windows::Forms::DataGridViewCheckBoxCell();
3772  System::Windows::Forms::DataGridViewCheckBoxCell^ cell = dynamic_cast<System::Windows::Forms::DataGridViewCheckBoxCell^>(gridViewState->Rows[index]->Cells[dataGridViewTextBoxColumnStateValue->Name]);
3773  cell->Value = ConvertValue2String(stateVariable->GetInitValue());
3774  cell->Tag = gcnew CLRWrapper<std::shared_ptr<DataTypes::Object>>(stateVariable->GetInitValue());
3775  cell->Style->NullValue = false;
3776  cell->TrueValue = true;
3777  cell->FalseValue = false;
3778  }
3779  else if (std::shared_ptr<DataTypes::EnumerationElement> enumerationElement = std::dynamic_pointer_cast<DataTypes::EnumerationElement>(stateVariable->GetInitValue())) // Enumeration type
3780  {
3781  gridViewState->Rows[index]->Cells[dataGridViewTextBoxColumnStateValue->Name] = gcnew System::Windows::Forms::DataGridViewComboBoxCell();
3782  System::Windows::Forms::DataGridViewComboBoxCell^ cell = dynamic_cast<System::Windows::Forms::DataGridViewComboBoxCell^>(gridViewState->Rows[index]->Cells[dataGridViewTextBoxColumnStateValue->Name]);
3783  cell->DisplayStyle = System::Windows::Forms::DataGridViewComboBoxDisplayStyle::ComboBox;
3784  cell->FlatStyle = System::Windows::Forms::FlatStyle::Flat;
3785  cell->DisplayMember = "Name";
3786  cell->ValueMember = "Name";
3787  cell->DataSource = Util::Util::ArrayEnumerationElements2String(enumerationElement->GetEnumeration()->GetElements());;
3788  cell->Value = ConvertValue2String(stateVariable->GetInitValue());
3789  cell->Tag = gcnew CLRWrapper<std::shared_ptr<DataTypes::Object>>(stateVariable->GetInitValue());
3790  }
3791  else
3792  {
3793  try
3794  {
3795  if (IS_NOT_NULL(stateVariable->GetInitValue()))
3796  {
3797  gridViewState->Rows[index]->Cells[dataGridViewTextBoxColumnStateValue->Name]->Value = ConvertValue2String(stateVariable->GetInitValue());
3798  }
3799  }
3800  catch (System::Exception^ ex)
3801  {
3802  gridViewState->Rows[index]->Cells[dataGridViewTextBoxColumnStateValue->Name]->ErrorText = ex->Message;
3803  }
3804  }
3805 
3806  if (IS_NOT_NULL(stateVariable->GetInitValue()))
3807  {
3808  gridViewState->Rows[index]->Cells[dataGridViewTextBoxColumnStateDetails->Name]->Value = GetDetails(stateVariable->GetInitValue());
3809  }
3810  }
3811 
3812  try
3813  {
3814  std::vector<std::shared_ptr<IDocument>> importDocs = document->GetImports();
3815  for (int i = 0; i < importDocs.size(); i++)
3816  {
3817  UpdateGridViewStateVariable(importDocs[i], true, listItemReviewed);
3818  }
3819  }
3820  catch (const std::exception& ex)
3821  {
3822  PrintException(ex);
3823  }
3824  catch (System::Exception^ ex)
3825  {
3826  PrintException(ex);
3827  }
3828 }
3829 
3830 // TODO: refactor
3831 void SampleForm::UpdateGridViewStateVariable(std::shared_ptr<IStateVariable> stateVariable)
3832 {
3833  if (stateVariable == nullptr)
3834  {
3835  return;
3836  }
3837 
3838  // Update existing value
3839  for (int i = 0; i < gridViewState->Rows->Count; i++)
3840  {
3841  System::Windows::Forms::DataGridViewRow^ row = gridViewState->Rows[i];
3842  if (row->Cells[dataGridViewTextBoxColumnStateName->Name]->Value != nullptr && Util::Util::CastTo<std::shared_ptr<IStateVariable>>(row->Tag) == stateVariable)
3843  {
3844  std::shared_ptr<DataTypes::Object> stateVariableValue = nullptr;
3845 
3846  if (radioButtonDefaultImplementation->Checked)
3847  {
3848  stateVariableValue = piml->StateVariableImplementation->GetValue(stateVariable);
3849  }
3850  else
3851  {
3852  stateVariableValue = stateVariable->GetInitValue();
3853  }
3854 
3855  if (IS_NOT_NULL(stateVariableValue))
3856  {
3857  try
3858  {
3859  row->Cells[dataGridViewTextBoxColumnStateValue->Name]->Value = ConvertValue2String(stateVariableValue);
3860  }
3861  catch (System::Exception^ ex)
3862  {
3863  row->Cells[dataGridViewTextBoxColumnStateValue->Name]->ErrorText = ex->Message;
3864  }
3865 
3866  row->Cells[dataGridViewTextBoxColumnStateDetails->Name]->Value = GetDetails(stateVariableValue);
3867  }
3868  else
3869  {
3870  row->Cells[dataGridViewTextBoxColumnStateValue->Name]->Value = nullptr;
3871  row->Cells[dataGridViewTextBoxColumnStateDetails->Name]->Value = System::String::Empty;
3872  }
3873  break;
3874  }
3875  }
3876 
3877  System::Windows::Forms::Application::DoEvents();
3878 }
3879 
3880 System::Void SampleForm::buttonNewInstance_Click(System::Object^ sender, System::EventArgs^ e)
3881 {
3882  SampleForm^ form = gcnew SampleForm();
3883  form->SetInstanceName(Util::Util::ToString(SampleConstants::CHILD_INSTANCE_NAME));
3884  form->SetCreatorForm(this);
3885  form->Show();
3886 }
3887 
3888 System::Void SampleForm::buttonNewInstanceNewThread_Click(System::Object^ sender, System::EventArgs^ e)
3889 {
3890  System::Threading::Thread^ thread = gcnew System::Threading::Thread(gcnew System::Threading::ThreadStart(this, &SampleForm::NewInstanceInThread));
3891  thread->SetApartmentState(System::Threading::ApartmentState::STA);
3892  thread->Start();
3893 }
3894 
3895 System::Void SampleForm::NewInstanceInThread()
3896 {
3897  SampleForm^ form = gcnew SampleForm();
3898  form->SetInstanceName(Util::Util::ToString(SampleConstants::CHILD_INSTANCE_NAME));
3899  form->SetCreatorForm(this);
3900  System::Windows::Forms::Application::Run(form);
3901 }
3902 
3903 System::Void SampleForm::buttonHmi_Click(System::Object^ sender, System::EventArgs^ e)
3904 {
3905  if (buttonHmi->Checked)
3906  {
3907  piml->HmiWindow = gcnew HmiWindow();
3908  piml->HmiWindow->FormClosing += gcnew System::Windows::Forms::FormClosingEventHandler(this, &SampleForm::HmiWindow_FormClosing);
3909  piml->HmiWindow->SizeChanged += gcnew System::EventHandler(this, &SampleForm::HmiWindow_SizeChanged);
3910  piml->HmiWindow->Activated += gcnew System::EventHandler(this, &SampleForm::HmiWindow_Activated);
3911  piml->HmiWindow->Show();
3912 
3913  piml->HmiWindow->Size = System::Drawing::Size(Setting::UserSettings::GetInstance().GetHmiWindowWidth(), Setting::UserSettings::GetInstance().GetHmiWindowHeight());
3914  piml->HmiWindow->Location = System::Drawing::Point(Location.X + Size.Width, Location.Y);
3915  if (IS_NOT_NULL(piml->CreatorForm) && IS_NOT_NULL(piml->CreatorForm->piml->HmiWindow))
3916  {
3917  piml->HmiWindow->Size = piml->CreatorForm->piml->HmiWindow->Size;
3918  }
3919 
3920  piml->HmiWindow->BringToFront();
3921 
3922  piml->CustomScreenImplementation->SetHmiScreenHandle(piml->HmiWindow->GetHmiControl()->Handle.ToInt64());
3923  }
3924  else if (IS_NOT_NULL(piml->HmiWindow))
3925  {
3926  piml->HmiWindow->Close();
3927  }
3928 
3929  SyncWithParent(IS_NOT_NULL(piml->CreatorForm) ? piml->CreatorForm->buttonHmi : nullptr, buttonHmi);
3930 }
3931 
3932 System::Void SampleForm::HmiWindow_FormClosing(System::Object^ sender, System::Windows::Forms::FormClosingEventArgs^ e)
3933 {
3934  piml->CustomScreenImplementation->SetHmiScreenHandle(NULL);
3935  piml->HmiWindow = nullptr;
3936 
3937  buttonHmi->Checked = false;
3938 }
3939 
3940 void SampleForm::HmiWindow_Activated(System::Object^ sender, System::EventArgs^ e)
3941 {
3942  if (piml->CustomScreenImplementation!=nullptr)
3943  {
3944  piml->CustomScreenImplementation->ActivateHmiScreen();
3945  }
3946 }
3947 
3948 void SampleForm::HmiWindow_SizeChanged(System::Object^ sender, System::EventArgs^ e)
3949 {
3950  Setting::UserSettings::GetInstance().SetHmiWindowWidth(piml->HmiWindow->Width);
3951  Setting::UserSettings::GetInstance().SetHmiWindowHeight(piml->HmiWindow->Height);
3952 
3953  if (piml->CustomScreenImplementation != nullptr)
3954  {
3955  piml->CustomScreenImplementation->RefreshHmiScreen();
3956  }
3957 }
3958 
3959 void SampleForm::CustomScreenImplementation_KeyDown(std::shared_ptr<Custom::KeyEventArgs> eventArgs)
3960 {
3961  std::string key = "Unknown";
3962  if (std::shared_ptr<Custom::WpfKeyEventArgs> wpfKeyEventArgs = std::dynamic_pointer_cast<Custom::WpfKeyEventArgs>(eventArgs))
3963  {
3964  key = wpfKeyEventArgs->ToString();
3965  if (wpfKeyEventArgs->GetModifierKeys() == Custom::ModifierKeys::Alt &&
3966  wpfKeyEventArgs->GetKey() == Custom::Key::F4)
3967  {
3968  if (IS_NOT_NULL(piml->HmiWindow))
3969  {
3970  piml->HmiWindow->Close();
3971  }
3972  }
3973  else if (wpfKeyEventArgs->GetKey() == Custom::Key::F10 ||
3974  wpfKeyEventArgs->GetKey() == Custom::Key::LeftAlt ||
3975  wpfKeyEventArgs->GetKey() == Custom::Key::RightAlt)
3976  {
3977  eventArgs->SetHandled(true);
3978  }
3979  }
3980  else if (std::shared_ptr<Custom::FormKeyEventArgs> formKeyEventArgs = std::dynamic_pointer_cast<Custom::FormKeyEventArgs>(eventArgs))
3981  {
3982  if (formKeyEventArgs->GetModifierKeys() == Custom::Keys::Alt &&
3983  formKeyEventArgs->GetKey() == Custom::Keys::F4)
3984  {
3985  if (IS_NOT_NULL(piml->HmiWindow))
3986  {
3987  piml->HmiWindow->Close();
3988  }
3989  }
3990  else if (formKeyEventArgs->GetKey() == Custom::Keys::F10 ||
3991  formKeyEventArgs->GetKey() == Custom::Keys::Alt)
3992  {
3993  eventArgs->SetHandled(true);
3994  }
3995  key = formKeyEventArgs->ToString();
3996  }
3997 
3998  PrintTextCallback("CustomScreenImplementation_KeyDown(" + Util::Util::ToString(key) + ")");
3999 }
4000 
4001 System::Void SampleForm::SampleForm_FormClosing(System::Object^ sender, System::Windows::Forms::FormClosingEventArgs^ e)
4002 {
4003  // at C#: listForms.Remove(this)
4004  for (size_t i = 0; i < piml->ListForms.size(); i++)
4005  {
4006  if (piml->ListForms.at(i).get() == this)
4007  {
4008  piml->ListForms.erase(piml->ListForms.begin() + i);
4009  }
4010  }
4011 
4012  // Remove Event
4013  if (piml->GlobalRuntimeManager != nullptr)
4014  {
4015  piml->GlobalRuntimeManager->StopAll();
4016  piml->RemoveRuntimeEvents(piml->GlobalRuntimeManager);
4017  }
4018 
4019  //piml->StateVariableImplementation->SetStateVariableValueChangedHandler(nullptr);
4020 
4021  piml->RemoveOutputImplLogEventHandler();
4022 
4023  SaveSettings();
4024 }
4025 
4026 void SampleForm::SaveSettings()
4027 {
4028  if (piml->CreatorForm.get() == nullptr)
4029  {
4030  // Only main form
4031  Setting::UserSettings::GetInstance().SetPtxPpxDirectory(Util::Util::ToString(cbFilePath->Text->Trim()));
4032  Setting::UserSettings::GetInstance().SetPtxPpxDirectoryList(Util::Util::Join(";", cbFilePath->Items->GetEnumerator()));
4033 
4034  Setting::UserSettings::GetInstance().SetTraceFileMaxCount(System::Convert::ToInt32(textBoxTraceFileMaxCount->Text->Trim()));
4035  Setting::UserSettings::GetInstance().SetTraceFileMaxSize(System::Convert::ToInt32(textBoxTraceFileMaxSize->Text->Trim()));
4036  Setting::UserSettings::GetInstance().SetTraceLevels(RuntimeConfig::GetInstance().GetTraceLevel());
4037  Setting::UserSettings::GetInstance().SetTracingDirectory(Util::Util::ToString(textBoxTraceFolder->Text->Trim()));
4038 
4039  Setting::UserSettings::GetInstance().SetWindowWidth(Size.Height);
4040  Setting::UserSettings::GetInstance().SetWindowWidth(Size.Width);
4041  Setting::UserSettings::GetInstance().SetWindowLocationX(Location.X);
4042  Setting::UserSettings::GetInstance().SetWindowLocationY(Location.Y);
4043  Setting::UserSettings::GetInstance().SetCustomImplTypes(GetCurrentCustomImpl());
4044  SaveSocketPortOrPipeName();
4045 
4046  Setting::UserSettings::GetInstance().SetAsynchron(checkBoxAsyncExecution->Checked);
4047  Setting::UserSettings::GetInstance().SetCyclic(checkBoxCyclicExecution->Checked);
4048  Setting::UserSettings::GetInstance().SetCyclicReload(checkBoxCyclicReload->Checked);
4049  Setting::UserSettings::GetInstance().SetNewRuntimeManager(checkBoxNewRuntimeManager->Checked);
4050  Setting::UserSettings::GetInstance().SetAddMessageToOutput(checkBoxAdd2Output->Checked);
4051  Setting::UserSettings::GetInstance().SetStartAllParents(checkBoxStartAllParents->Checked);
4052 
4053  Setting::UserSettings::GetInstance().SetTimeout(System::Convert::ToUInt64(textBoxTimeout->Text->Trim()));
4054  Setting::UserSettings::GetInstance().SetConnectionState(checkBoxUseConnectionState->Checked);
4055  Setting::UserSettings::GetInstance().SetIgnition((int)checkBoxIgnition->CheckState);
4056  Setting::UserSettings::GetInstance().SetPollingTime(System::Convert::ToInt32(textBoxPollingTime->Text->Trim()));
4057  Setting::UserSettings::GetInstance().SetVoltageThreshold(System::Convert::ToInt32(textBoxVoltageThreshold->Text->Trim()));
4058 
4059  Setting::UserSettings::GetInstance().SetRuntimeContextName(Util::Util::ToString(textBoxRuntimeContextName->Text->Trim()));
4060 
4061 #pragma region C++ for RAW-mode
4062  Setting::UserSettings::GetInstance().SetDiagIpcType(comboBoxDiagIpcType->SelectedItem != nullptr ?
4063  Util::Util::ToIpcType(comboBoxDiagIpcType->SelectedItem->ToString()) :
4064  IpcTypes::Raw);
4065  Setting::UserSettings::GetInstance().SetDiagManagerLicenseKey(Util::LicenseUtil::Encrypt(Util::Util::ToString(textBoxDiagManagerLicenseKey->Text)));
4066  Setting::UserSettings::GetInstance().SetDiagManagerTraceLevel(comboBoxDiagManagerTraceLevel->SelectedItem != nullptr ?
4067  Util::Util::ToLoggerLevel(comboBoxDiagManagerTraceLevel->SelectedItem->ToString()) :
4068  (DiagManager::Common::ILog::Level)Util::OtxDiagUtil::GetLevelLoggerDefault());
4069  Setting::UserSettings::GetInstance().SetDiagLoggingTraceLevel(comboBoxDiagLoggingTraceLevel->SelectedItem != nullptr ?
4070  Util::Util::ToDiagDiagnosticsLogLevel(comboBoxDiagLoggingTraceLevel->SelectedItem->ToString()) :
4071  (DiagManager::NoneOtxDiagApi::INoneOtxDiag::LogLevels)Util::OtxDiagUtil::GetDiagnosticLogLevelDefault());
4072  Setting::UserSettings::GetInstance().SetIncludeTraceDiagLogging(checkBoxIncludedDiagLogging->Checked);
4073  Setting::UserSettings::GetInstance().SetDiagTraceDirectory(Util::Util::ToString(textBoxDiagManagerTraceFolder->Text));
4074  Setting::UserSettings::GetInstance().SetOdxProject(comboBoxODXProject->SelectedItem != nullptr ?
4075  Util::Util::ToString(comboBoxODXProject->SelectedItem->ToString()) :
4076  "");
4077  Setting::UserSettings::GetInstance().SetOdxVehicleInformation(comboBoxODXVehicle->SelectedItem != nullptr ?
4078  Util::Util::ToString(comboBoxODXVehicle->SelectedItem->ToString()) :
4079  "");
4080 #pragma endregion//Only C++
4081 
4082  Setting::UserSettings::GetInstance().Save();
4083  }
4084 }
4085 
4086 void SampleForm::SaveSocketPortOrPipeName()
4087 {
4088  IpcTypes ipcType = Util::Util::ToIpcType(comboBoxIpcType->SelectedItem->ToString());
4089 
4090  switch (ipcType)
4091  {
4092 #pragma region C++ for RAW-mode
4093  case IpcTypes::Raw:
4094  {
4095  Setting::UserSettings::GetInstance().SetIpcType(ipcType);
4096  break;
4097  }
4098 #pragma endregion//C++ for RAW-mode
4099  case IpcTypes::Socket:
4100  {
4101  try
4102  {
4103  Setting::UserSettings::GetInstance().SetDiagManagerPort(System::Convert::ToUInt16(textBoxDiagPortPipe->Text->Trim()));
4104  Setting::UserSettings::GetInstance().SetRuntimePort(System::Convert::ToUInt16(textBoxRtPortPipe->Text->Trim()));
4105  Setting::UserSettings::GetInstance().SetIpcType(ipcType);
4106  }
4107  catch (...)
4108  {
4109  Setting::UserSettings::GetInstance().SetDiagManagerPort(SampleConstants::DEFAULT_DM_PORT);
4110  Setting::UserSettings::GetInstance().SetRuntimePort(SampleConstants::DEFAULT_RT_PORT);
4111  }
4112  break;
4113  }
4114  case IpcTypes::Pipe:
4115  {
4116  std::string diagManagerPipeName = Util::Util::ToString(textBoxDiagPortPipe->Text->Trim());
4117  std::string runtimePipeName = Util::Util::ToString(textBoxRtPortPipe->Text->Trim());
4118 
4119  Setting::UserSettings::GetInstance().SetDiagManagerPipeName(!diagManagerPipeName.empty() ? diagManagerPipeName : SampleConstants::DEFAULT_DM_PIPE_NAME);
4120  Setting::UserSettings::GetInstance().SetRuntimePipeName(!runtimePipeName.empty() ? runtimePipeName : SampleConstants::DEFAULT_RT_PIPE_NAME);
4121  Setting::UserSettings::GetInstance().SetIpcType(ipcType);
4122  break;
4123  }
4124  default:
4125  break;
4126  }
4127 }
4128 
4129 System::Void SampleForm::textBoxRuntimeContextName_TextChanged(System::Object^ sender, System::EventArgs^ e)
4130 {
4131  textBoxRuntimeContextName->Text = textBoxRuntimeContextName->Text->Trim();
4132  piml->RuntimeContextName = Util::Util::ToString(textBoxRuntimeContextName->Text);
4133 
4134  SetTitle(Util::Util::ToString(piml->Title));
4135 }
4136 
4137 System::Void SampleForm::listBoxOuput_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e)
4138 {
4139  buttonCopyRow->Enabled = listBoxOuput->SelectedItems->Count > 0;
4140 }
4141 
4142 System::Void SampleForm::buttonPause_Click(System::Object^ sender, System::EventArgs^ e)
4143 {
4144  msclr::lock l(piml->LockRuntimeContexts.get());
4145  {
4146  if (buttonPause->Checked)
4147  {
4148  for (int i = 0; i < piml->RuntimeContexts.size(); i++)
4149  {
4150  if (piml->RuntimeContexts[i]->GetExecutionState() == ExecutionState::Running)
4151  {
4152  piml->RuntimeContexts[i]->Pause();
4153  }
4154  }
4155  }
4156  else
4157  {
4158  for (int i = 0; i < piml->RuntimeContexts.size(); i++)
4159  {
4160  if (piml->RuntimeContexts[i]->GetExecutionState() == ExecutionState::Paused)
4161  {
4162  piml->RuntimeContexts[i]->Continue();
4163  }
4164  }
4165  }
4166  }
4167 
4168  SyncWithParent(IS_NOT_NULL(piml->CreatorForm) ? piml->CreatorForm->buttonPause : nullptr, buttonPause);
4169 }
4170 
4171 void SampleForm::AddRuntimeContext(IRuntimeContext* context)
4172 {
4173  msclr::lock l(piml->LockRuntimeContexts.get());
4174  {
4175  if (std::find(piml->RuntimeContexts.begin(), piml->RuntimeContexts.end(), context) == piml->RuntimeContexts.end()) // context not exist into vector
4176  {
4177  piml->RuntimeContexts.push_back(context);
4178  }
4179 
4180  if (piml->RuntimeContextIdsExecutionStartTick.find(context->GetRuntimeId()) == piml->RuntimeContextIdsExecutionStartTick.end())
4181  {
4182  piml->RuntimeContextIdsExecutionStartTick.insert({context->GetRuntimeId(), System::DateTime::Now.Ticks});
4183  }
4184  }
4185 }
4186 
4187 void SampleForm::RemoveRuntimeContext(IRuntimeContext* context)
4188 {
4189  long long contextRuntimeId = context->GetRuntimeId();
4190 
4191  msclr::lock l(piml->LockRuntimeContexts.get());
4192  {
4193  for (int i = 0; i < piml->RuntimeContexts.size(); i++)
4194  {
4195  if (piml->RuntimeContexts[i]->GetRuntimeId() == contextRuntimeId)
4196  {
4197  piml->RuntimeContexts.erase(piml->RuntimeContexts.begin() + i);
4198  }
4199  }
4200 
4201  std::map<long long, long long>::iterator itr = piml->RuntimeContextIdsExecutionStartTick.find(contextRuntimeId);
4202  if (itr != piml->RuntimeContextIdsExecutionStartTick.end())
4203  {
4204  piml->RuntimeContextIdsExecutionStartTick.erase(itr);
4205  }
4206  }
4207 }
4208 
4209 bool SampleForm::IsPauseEnabled()
4210 {
4211  msclr::lock l(piml->LockRuntimeContexts.get());
4212  {
4213  for (int i = 0; i < piml->RuntimeContexts.size(); i++)
4214  {
4215  if (piml->RuntimeContexts[i]->GetExecutionState() == ExecutionState::Running)
4216  {
4217  return true;
4218  }
4219  }
4220 
4221  return false;
4222  }
4223 }
4224 
4225 bool SampleForm::IsContinueEnable()
4226 {
4227  msclr::lock l(piml->LockRuntimeContexts.get());
4228  {
4229  for (int i = 0; i < piml->RuntimeContexts.size(); i++)
4230  {
4231  if (piml->RuntimeContexts[i]->GetExecutionState() == ExecutionState::Paused)
4232  {
4233  return true;
4234  }
4235  }
4236  return false;
4237  }
4238 }
4239 
4240 void SampleForm::SetExpectedState()
4241 {
4242  if (piml->UseConnectionState)
4243  {
4244  if (piml->KL15State == -1)
4245  {
4246  piml->ExpectedConnectionState = ExpectedState::BatteryOn;
4247  }
4248  else if (piml->KL15State == 1)
4249  {
4250  piml->ExpectedConnectionState = ExpectedState::IgnitionOn;
4251  }
4252  else
4253  {
4254  piml->ExpectedConnectionState = ExpectedState::IgnitionOff;
4255  }
4256  }
4257  else
4258  {
4259  piml->ExpectedConnectionState = ExpectedState::None;
4260  }
4261 }
4262 
4263 System::Void SampleForm::checkBoxUseConnectionState_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
4264 {
4265  piml->UseConnectionState = checkBoxUseConnectionState->Checked;
4266  EnableConnectionState();
4267  SetExpectedState();
4268 
4269  System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(SampleForm::typeid));
4270  labelBatteryState->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"IconBattery16")));
4271  labelIgnitionState->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"IconIgnition16")));
4272 
4273  SyncWithParent(IS_NOT_NULL(piml->CreatorForm) ? piml->CreatorForm->checkBoxUseConnectionState : nullptr, checkBoxUseConnectionState);
4274 }
4275 
4276 System::Void SampleForm::CheckBoxKL15_CheckStateChanged(System::Object^ sender, System::EventArgs^ e)
4277 {
4278  switch (checkBoxIgnition->CheckState)
4279  {
4280  case System::Windows::Forms::CheckState::Checked:
4281  piml->KL15State = 1;
4282  break;
4283  case System::Windows::Forms::CheckState::Unchecked:
4284  piml->KL15State = 0;
4285  break;
4286  default:
4287  piml->KL15State = -1;
4288  break;
4289  }
4290 
4291  SetExpectedState();
4292 
4293  SyncWithParent(IS_NOT_NULL(piml->CreatorForm) ? piml->CreatorForm->checkBoxIgnition : nullptr, checkBoxIgnition);
4294 }
4295 
4296 void SampleForm::EnableConnectionState()
4297 {
4298  labelExpectedState->Enabled = piml->UseConnectionState;
4299  labelBatteryState->Enabled = piml->UseConnectionState;
4300  checkBoxIgnition->Enabled = piml->UseConnectionState;
4301  labelPollingTime->Enabled = piml->UseConnectionState;
4302  textBoxPollingTime->Enabled = piml->UseConnectionState;
4303  labelVoltageThreshold->Enabled = piml->UseConnectionState;
4304  textBoxVoltageThreshold->Enabled = piml->UseConnectionState;
4305  buttonCheckBatteryIgnition->Enabled = piml->UseConnectionState;
4306 }
4307 
4308 System::Void SampleForm::buttonCheckBatteryIgnition_Click(System::Object^ sender, System::EventArgs^ e)
4309 {
4310  CheckBatteryIgnitionState(piml->GlobalRuntimeManager);
4311 
4312  SyncWithParent(IS_NOT_NULL(piml->CreatorForm) ? piml->CreatorForm->buttonCheckBatteryIgnition : nullptr, buttonCheckBatteryIgnition);
4313 }
4314 
4315 System::Void SampleForm::textBoxPollingTime_TextChanged(System::Object^ sender, System::EventArgs^ e)
4316 {
4317  try
4318  {
4319  if (System::Convert::ToInt32(textBoxPollingTime->Text->Trim()) <= 0)
4320  {
4321  textBoxPollingTime->Text = piml->DEFAULT_POLLING_TIME.ToString();
4322  }
4323  }
4324  catch (...)
4325  {
4326  textBoxPollingTime->Text = piml->DEFAULT_POLLING_TIME.ToString();
4327  }
4328 
4329  SyncWithParent(IS_NOT_NULL(piml->CreatorForm) ? piml->CreatorForm->textBoxPollingTime : nullptr, textBoxPollingTime);
4330 }
4331 
4332 System::Void SampleForm::textBoxBatteryVoltageThreshold_TextChanged(System::Object^ sender, System::EventArgs^ e)
4333 {
4334  try
4335  {
4336  if (System::Convert::ToInt32(textBoxVoltageThreshold->Text->Trim()) <= 0)
4337  {
4338  textBoxVoltageThreshold->Text = piml->DEFAULT_POLLING_TIME.ToString();
4339  }
4340  }
4341  catch (...)
4342  {
4343  textBoxVoltageThreshold->Text = piml->DEFAULT_POLLING_TIME.ToString();
4344  }
4345 
4346  SyncWithParent(IS_NOT_NULL(piml->CreatorForm) ? piml->CreatorForm->textBoxVoltageThreshold : nullptr, textBoxVoltageThreshold);
4347 }
4348 
4349 void SampleForm::CheckBatteryIgnitionState(std::shared_ptr<IRuntimeManager> runtimeManager)
4350 {
4351  if (piml->UseConnectionState)
4352  {
4353  runtimeManager->GetDiagConnectionState()->SetPollingTime(System::Convert::ToInt32(textBoxPollingTime->Text));
4354  runtimeManager->GetDiagConnectionState()->SetBatteryVoltageThreshold(System::Convert::ToInt32(textBoxVoltageThreshold->Text));
4355  ClampState batteryState = runtimeManager->GetDiagConnectionState()->GetBatteryState();
4356  ClampState ignitionState = runtimeManager->GetDiagConnectionState()->GetIgnitionState();
4357 
4358  SetBatteryIgnitionState(batteryState, ignitionState);
4359 
4360  PrintTextCallback("Check DiagConnection State - BatteryState = " + Util::Util::ToString(batteryState) + ", IgnitionState = " + Util::Util::ToString(ignitionState));
4361  }
4362 }
4363 
4364 void SampleForm::SetBatteryIgnitionState(ClampState batteryState, ClampState ignitionState)
4365 {
4366 #pragma region C++ for initialize resource
4367  System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(SampleForm::typeid));
4368 #pragma endregion
4369 
4370  switch (batteryState)
4371  {
4373  labelBatteryState->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"IconBatteryNotAvailable16")));
4374  break;
4375  case OpenTestSystem::Otx::Runtime::Api::ClampState::Off:
4376  labelBatteryState->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"IconBatteryOff16")));
4377  break;
4379  labelBatteryState->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"IconBatteryOn16")));
4380  break;
4381  }
4382 
4383  switch (ignitionState)
4384  {
4386  labelIgnitionState->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"IconIgnitionNotAvailable16")));
4387  break;
4388  case OpenTestSystem::Otx::Runtime::Api::ClampState::Off:
4389  labelIgnitionState->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"IconIgnitionOff16")));
4390  break;
4392  labelIgnitionState->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"IconIgnitionOn16")));
4393  break;
4394  }
4395 }
4396 
4397 void SampleForm::ShowConnectionStateMessage(IRuntimeContext* runtimeContext)
4398 {
4399  if (runtimeContext != nullptr)
4400  {
4401  System::Media::SystemSounds::Beep->Play();
4402 
4403  switch (piml->ExpectedConnectionState)
4404  {
4406  PrintTextCallback("----------------------------------------------------------------------------------------------------------------------------------------------");
4407  PrintTextCallback("-- Not expected connection state: Either it is not possible to communicate with the VCI or the battery is not connected. Please connect it! --");
4408  PrintTextCallback("----------------------------------------------------------------------------------------------------------------------------------------------");
4409  break;
4411  PrintTextCallback("------------------------------------------------------------------------------------");
4412  PrintTextCallback("-- Not expected connection state: The ignition must be OFF. Please switch it OFF! --");
4413  PrintTextCallback("------------------------------------------------------------------------------------");
4414  break;
4416  PrintTextCallback("----------------------------------------------------------------------------------");
4417  PrintTextCallback("-- Not expected connection state: The ignition must be ON. Please switch it ON! --");
4418  PrintTextCallback("----------------------------------------------------------------------------------");
4419  break;
4420  default:
4421  break;
4422  }
4423  }
4424 }
4425 
4426 System::Void SampleForm::checkBoxAdd2Output_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
4427 {
4428  SyncWithParent(IS_NOT_NULL(piml->CreatorForm) ? piml->CreatorForm->checkBoxAdd2Output : nullptr, checkBoxAdd2Output);
4429 }
4430 
4431 void SampleForm::NumericUpDownSetValueCallback(cli::array<System::Object^>^ arr)
4432 {
4433  if (arr == nullptr || arr->Length != 2) return;
4434 
4435  System::Windows::Forms::NumericUpDown^ numericUpDown = dynamic_cast<System::Windows::Forms::NumericUpDown^>(arr[0]);
4436  System::Windows::Forms::NumericUpDown^ control = dynamic_cast<System::Windows::Forms::NumericUpDown^>(arr[1]);
4437 
4438  numericUpDown->Value = control->Value;
4439 }
4440 
4441 void SampleForm::ParentNumericUpDownSetValueCallback(System::Object^ state)
4442 {
4443  cli::array<System::Object^>^ arr = dynamic_cast<cli::array<System::Object^>^>(state);
4444  if (arr == nullptr || arr->Length != 2) return;
4445 
4446  System::Windows::Forms::NumericUpDown^ numericUpDown = dynamic_cast<System::Windows::Forms::NumericUpDown^>(arr[0]);
4447  System::Windows::Forms::NumericUpDown^ control = dynamic_cast<System::Windows::Forms::NumericUpDown^>(arr[1]);
4448 
4449  if (numericUpDown == nullptr || control == nullptr)
4450  {
4451  return;
4452  }
4453 
4454  if (numericUpDown->InvokeRequired)
4455  {
4456  piml->CreatorForm->Invoke(gcnew System::Action<cli::array<System::Object^>^>(this, &SampleForm::NumericUpDownSetValueCallback), gcnew cli::array<System::Object^>{arr});
4457  }
4458  else
4459  {
4460  NumericUpDownSetValueCallback(arr);
4461  }
4462 }
4463 
4464 System::Void SampleForm::comboBoxTraceLevel_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e)
4465 {
4466  SyncWithParent(IS_NOT_NULL(piml->CreatorForm) ? piml->CreatorForm->comboBoxTraceLevel : nullptr,
4467  comboBoxTraceLevel);
4468 }
4469 
4470 System::Void SampleForm::txtPassword_TextChanged(System::Object^ sender, System::EventArgs^ e)
4471 {
4472  SyncWithParent(IS_NOT_NULL(piml->CreatorForm) ? piml->CreatorForm->txtPassword : nullptr, txtPassword);
4473 }
4474 
4475 System::Void SampleForm::textBoxTimeout_TextChanged(System::Object^ sender, System::EventArgs^ e)
4476 {
4477  SyncWithParent(IS_NOT_NULL(piml->CreatorForm) ? piml->CreatorForm->textBoxTimeout : nullptr, textBoxTimeout);
4478 }
4479 
4480 System::Void SampleForm::textBoxTraceFileMaxSize_TextChanged(System::Object^ sender, System::EventArgs^ e)
4481 {
4482  if (piml->GlobalRuntimeManager == nullptr)
4483  {
4484  return;
4485  }
4486 
4487  PrintTextCallback("Set TraceFileMaxSize to " + textBoxTraceFileMaxSize->Text);
4488 
4489  try
4490  {
4491  RuntimeConfig::GetInstance().SetTraceFileMaxSize(System::Convert::ToInt32(textBoxTraceFileMaxSize->Text));
4492  SyncWithParent(IS_NOT_NULL(piml->CreatorForm) ? piml->CreatorForm->textBoxTraceFileMaxSize : nullptr, textBoxTraceFileMaxSize);
4493  }
4494  catch (System::Exception^ ex)
4495  {
4496  PrintException(ex);
4497  textBoxTraceFileMaxSize->Text = RuntimeConfig::GetInstance().GetTraceFileMaxSize().ToString();
4498  }
4499 }
4500 
4501 System::Void SampleForm::textBoxTraceFileMaxCount_TextChanged(System::Object^ sender, System::EventArgs^ e)
4502 {
4503  if (piml->GlobalRuntimeManager == nullptr)
4504  {
4505  return;
4506  }
4507 
4508  PrintTextCallback("Set TraceFileMaxCount to " + textBoxTraceFileMaxCount->Text);
4509 
4510  try
4511  {
4512  RuntimeConfig::GetInstance().SetTraceFileMaxCount(System::Convert::ToInt32(textBoxTraceFileMaxCount->Text));
4513  SyncWithParent(IS_NOT_NULL(piml->CreatorForm) ? piml->CreatorForm->textBoxTraceFileMaxCount : nullptr,
4514  textBoxTraceFileMaxCount);
4515  }
4516  catch (System::Exception^ ex)
4517  {
4518  PrintException(ex);
4519  textBoxTraceFileMaxCount->Text = RuntimeConfig::GetInstance().GetTraceFileMaxCount().ToString();
4520  }
4521 }
4522 
4523 void SampleForm::WebServerTimer_Tick(System::Object^ sender, System::EventArgs^ e)
4524 {
4525  UpdateWebServerButtonCallback();
4526 }
4527 
4528 void SampleForm::UpdateWebServerButtonCallback()
4529 {
4530  if (InvokeRequired)
4531  {
4532  Invoke(gcnew System::Action(this, &SampleForm::UpdateWebServerButtonCallback));
4533  return;
4534  }
4535 
4536  if (piml->CustomScreenImplementation == nullptr)
4537  {
4538  buttonStartStopWebServer->Enabled = false;
4539  return;
4540  }
4541 
4542  buttonStartStopWebServer->Enabled = true;
4543 #pragma region C++ for initialize resource
4544  System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(SampleForm::typeid));
4545 #pragma endregion
4546  if (Custom::DefaultCustomScreenImplementation::IsStartedHtmlWebserver()) // Has Start WebServer
4547  {
4548  if (piml->IsStartWebSever == 1)
4549  {
4550  return;
4551  }
4552 
4553  buttonStartStopWebServer->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"StopWebServer.image")));
4554  piml->IsStartWebSever = 1;
4555  }
4556  else
4557  {
4558  if (piml->IsStartWebSever == 0)
4559  {
4560  return;
4561  }
4562 
4563  buttonStartStopWebServer->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"StartWebServer.image")));
4564  piml->IsStartWebSever = 0;
4565  }
4566 }
4567 
4568 System::Void SampleForm::buttonStartStopWebServer_Click(System::Object^ sender, System::EventArgs^ e)
4569 {
4570  StartStopWebServerCallback();
4571 }
4572 
4573 void SampleForm::StartStopWebServerCallback()
4574 {
4575  if (InvokeRequired)
4576  {
4577  Invoke(gcnew System::Action(this, &SampleForm::StartStopWebServerCallback));
4578  return;
4579  }
4580 
4581  if (piml->CustomScreenImplementation == nullptr)
4582  {
4583  return;
4584  }
4585 
4586  if (Custom::DefaultCustomScreenImplementation::IsStartedHtmlWebserver() == false) // No Start WebServer
4587  {
4588  piml->CustomScreenImplementation->StartHtmlWebServer();
4589  }
4590  else
4591  {
4592  piml->CustomScreenImplementation->StopHtmlWebServer();
4593  }
4594 }
4595 
4596 System::Void SampleForm::buttonLicense_Click(System::Object^ sender, System::EventArgs^ e)
4597 {
4598  LicenseForm^ form = gcnew LicenseForm();
4599  form->SetParentForm(this);
4600  if (form != nullptr)
4601  {
4602  form->ShowDialog(this);
4603  }
4604 }
4605 
4606 void SampleForm::ReloadRuntimeManager()
4607 {
4608  try
4609  {
4610  // Reason: See #15223. Only implement at Sample Dotnet
4611  //std::string licenseKeyFromOTForOTPLicense = OpenTestSystem::Common::LicensingV5::Util->CreateLicenseKeyFromOTForOTPLicense();
4612  //if (!licenseKeyFromOTForOTPLicense.empty()&&LicenseUtil::Util::CheckLicenesFormat(licenseKeyFromOTForOTPLicense))
4613  //{
4614  // OpenTestSystem::Otx::Runtime::Api::License::LicenseManager::SetLicenseKey(licenseKeyFromOTForOTPLicense);
4615  //}
4616 
4617  piml->GlobalRuntimeManager = CreateRuntimeManager();
4618 
4619  // TODO: update GUI if license is not valid
4620  }
4621  catch (const std::exception& ex)
4622  {
4623  PrintException(ex);
4624  PrintTextCallback("No RuntimeManager created");
4625  }
4626  catch (System::Exception^ ex)
4627  {
4628  PrintException(ex);
4629  PrintTextCallback("No RuntimeManager created");
4630  }
4631 }
4632 
4633 #pragma region C++ for Invoke inside DoCyclic
4634 void SampleForm::ReloadContextFileCallback(CLRWrapper<std::shared_ptr<IRuntimeManager>>^ clrRuntimeManager)
4635 {
4637  if (checkBoxNewRuntimeManager->Checked)
4638  {
4639  LoadContextFile(clrRuntimeManager->GetPtr());
4640  }
4641 }
4642 #pragma endregion
4643 
4644 #pragma region C++
4645 IRuntimeContext* SampleForm::GetRuntimeContext(long long runtimeId)
4646 {
4647  for (int i = 0; i < piml->RuntimeContexts.size(); i++)
4648  {
4649  if (piml->RuntimeContexts[i]->GetRuntimeId() == runtimeId)
4650  {
4651  return piml->RuntimeContexts[i];
4652  }
4653  }
4654  return nullptr;
4655 }
4656 
4657 void SampleForm::SetInstanceName(System::String^ instanceName)
4658 {
4659  if (System::String::IsNullOrEmpty(instanceName) == false)
4660  {
4661  piml->Title = Util::Util::ToString(instanceName);
4662  }
4663  else
4664  {
4665  piml->Title = SampleConstants::MAIN_INSTANCE_NAME;
4666  }
4667 }
4668 
4669 void SampleForm::SetCreatorForm(SampleForm^ creatorForm)
4670 {
4671  piml->CreatorForm = creatorForm;
4672 }
4673 #pragma endregion
4674 
4675 
4676 #pragma region C++ for RAW-mode
4677 std::shared_ptr<IRuntimeManager> SampleForm::CreateRawRuntimeManager()
4678 {
4679  std::shared_ptr<IRuntimeManager> runtimeManager = nullptr;
4680  System::String^ ipcTypeString = "";
4681  if (comboBoxDiagIpcType->SelectedItem != nullptr)
4682  {
4683  ipcTypeString = comboBoxDiagIpcType->SelectedItem->ToString()->Trim();
4684  }
4685  IpcTypes ipcType = Util::Util::ToIpcType(ipcTypeString);
4686  std::string licenseKey;
4687  std::shared_ptr<Otx::DiagManager::OtxDiagApi::IOtxDiag> rawOtxDiag = nullptr;
4688  unsigned short diagPort;
4689 
4690  switch (ipcType)
4691  {
4692  case OpenTestSystem::Otx::Runtime2::Api::Sample::Raw:
4693 
4694  comboBoxODXProject->Items->Clear();
4695  comboBoxODXVehicle->Items->Clear();
4696 
4697  licenseKey = Util::Util::ToString(textBoxDiagManagerLicenseKey->Text);
4698  rawOtxDiag = Util::OtxDiagUtil::RawOtxDiag(licenseKey);
4699  runtimeManager = RuntimeManagerFactory::CreateRawRuntimeManager(rawOtxDiag);
4700 
4701  InitializeODXProject();
4702 
4703  break;
4704  case OpenTestSystem::Otx::Runtime2::Api::Sample::Socket:
4705 
4706  diagPort = System::Convert::ToUInt16(textBoxDiagPortPipe->Text);
4707  runtimeManager = RuntimeManagerFactory::CreateRawRuntimeManager(diagPort);
4708 
4709  break;
4710  case OpenTestSystem::Otx::Runtime2::Api::Sample::Pipe:
4711 
4712  runtimeManager = RuntimeManagerFactory::CreateRawRuntimeManager(Util::Util::ToString(textBoxDiagPortPipe->Text));
4713 
4714  break;
4715  }
4716 
4717  return runtimeManager;
4718 }
4719 
4720 System::Void SampleForm::comboBoxODXProject_SelectedValueChanged(System::Object^ sender, System::EventArgs^ e)
4721 {
4722  try
4723  {
4724  std::shared_ptr<Otx::DiagManager::OtxDiagApi::IOtxDiag> rawOtxDiag = Util::OtxDiagUtil::RawOtxDiag();
4725  if (rawOtxDiag != nullptr && rawOtxDiag->GetDiagConfiguration() != nullptr)
4726  {
4727  std::string odxProject = Util::Util::ToString(comboBoxODXProject->SelectedItem->ToString());
4728  rawOtxDiag->GetDiagConfiguration()->SelectProject(odxProject);
4729 
4730  comboBoxODXVehicle->Items->Clear();
4731  std::vector<std::string> odxVehicles = rawOtxDiag->GetDiagConfiguration()->GetDbVehicleInformationList();
4732 
4733  std::string vehicleSetting = Setting::UserSettings::GetInstance().GetOdxVehicleInformation();
4734 
4735  for (size_t i = 0; i < odxVehicles.size(); i++)
4736  {
4737  std::string odxVehicle = odxVehicles[i];
4738  comboBoxODXVehicle->Items->Add(Util::Util::ToString(odxVehicle));
4739 
4740  if (vehicleSetting._Equal(odxVehicle))
4741  {
4742  comboBoxODXVehicle->SelectedIndex = i;
4743  }
4744  }
4745 
4746  if (comboBoxODXVehicle->SelectedIndex == -1)
4747  {
4748  comboBoxODXVehicle->SelectedIndex = 0;
4749  }
4750  }
4751  }
4752  catch (const std::exception& ex)
4753  {
4754  PrintException(ex);
4755  }
4756  catch (System::Exception^ ex)
4757  {
4758  PrintException(ex);
4759  }
4760 }
4761 
4762 System::Void SampleForm::comboBoxODXVehicle_SelectedValueChanged(System::Object^ sender, System::EventArgs^ e)
4763 {
4764  try
4765  {
4766  std::shared_ptr<Otx::DiagManager::OtxDiagApi::IOtxDiag> rawOtxDiag = Util::OtxDiagUtil::RawOtxDiag();
4767  rawOtxDiag->GetDiagConfiguration()->SelectVehicleInformation(Util::Util::ToString(comboBoxODXVehicle->SelectedItem->ToString()));
4768  }
4769  catch (const std::exception& ex)
4770  {
4771  PrintException(ex);
4772  }
4773  catch (System::Exception^ ex)
4774  {
4775  PrintException(ex);
4776  }
4777 }
4778 
4779 void SampleForm::InitializeODXProject()
4780 {
4781  comboBoxODXProject->Items->Clear();
4782 
4783  try
4784  {
4785  std::string licenseKey = Util::Util::ToString(textBoxDiagManagerLicenseKey->Text);
4786  std::shared_ptr<OpenTestSystem::Otx::DiagManager::OtxDiagApi::IOtxDiag> otxDiag = Util::OtxDiagUtil::RawOtxDiag(licenseKey);
4787 
4788  if (otxDiag == nullptr)
4789  {
4790  return;
4791  }
4792 
4793  std::vector<std::string> dbProjectList = otxDiag->GetDiagConfiguration()->GetDbProjectList();
4794 
4795  std::string odxProjectSetting = Setting::UserSettings::GetInstance().GetOdxProject();
4796  for (size_t i = 0; i < dbProjectList.size(); i++)
4797  {
4798  std::string dbProject = dbProjectList[i];
4799  comboBoxODXProject->Items->Add(Util::Util::ToString(dbProject));
4800 
4801  if (odxProjectSetting._Equal(dbProject))
4802  {
4803  comboBoxODXProject->SelectedIndex = i;
4804  }
4805  }
4806 
4807  if (comboBoxODXProject->SelectedIndex == -1)
4808  {
4809  comboBoxODXProject->SelectedIndex = 0;
4810  }
4811  }
4812  catch (const std::exception& ex)
4813  {
4814  PrintException(ex);
4815  }
4816  catch (System::Exception^ ex)
4817  {
4818  PrintException(ex);
4819  }
4820 }
4821 
4822 void SampleForm::SetupDiagManagerControls()
4823 {
4824  // move to line of diag ipc type
4825  portPipeLabel->Location = System::Drawing::Point(Width - 324, 65);
4826  textBoxDiagPortPipe->Location = System::Drawing::Point(Width - 221, 62);
4827  textBoxDiagPortPipe->Size = System::Drawing::Size(181, 22);
4828 
4829  // initialize default value of related controls
4830 
4831  if (comboBoxDiagIpcType->Items->Count == 0)
4832  {
4833  comboBoxDiagIpcType->Items->AddRange(Util::Util::ArrayIpcTypes2String());
4834  comboBoxDiagIpcType->SelectedItem = Util::Util::ToString(Setting::UserSettings::GetInstance().GetDiagIpcType());
4835  }
4836 
4837  if (comboBoxDiagManagerTraceLevel->Items->Count == 0)
4838  {
4839  comboBoxDiagManagerTraceLevel->Items->AddRange(Util::Util::ArrayDiagLoggerLevels2String());
4840  comboBoxDiagManagerTraceLevel->SelectedItem = Util::Util::ToString(Setting::UserSettings::GetInstance().GetDiagManagerTraceLevel());
4841  }
4842 
4843  if (comboBoxDiagLoggingTraceLevel->Items->Count==0)
4844  {
4845  comboBoxDiagLoggingTraceLevel->Items->AddRange(Util::Util::ArrayDiagnosticLogLevels2String());
4846  comboBoxDiagLoggingTraceLevel->SelectedItem = Util::Util::ToString(Setting::UserSettings::GetInstance().GetDiagLoggingTraceLevel());
4847  }
4848 
4849 }
4850 
4851 System::Void SampleForm::comboBoxDiagIpcType_SelectedValueChanged(System::Object ^ sender, System::EventArgs ^ e)
4852 {
4853  labelOdxProject->Hide();
4854  comboBoxODXProject->Hide();
4855  labelODXVehicle->Hide();
4856  comboBoxODXVehicle->Hide();
4857 
4858  portPipeLabel->Hide();
4859  textBoxDiagPortPipe->Hide();
4860 
4861  IpcTypes diagIpcType = Util::Util::ToIpcType(comboBoxDiagIpcType->SelectedItem->ToString());
4862  switch (diagIpcType)
4863  {
4864  case IpcTypes::Raw:
4865 
4866  labelOdxProject->Show();
4867  comboBoxODXProject->Show();
4868  labelODXVehicle->Show();
4869  comboBoxODXVehicle->Show();
4870 
4871  InitializeODXProject();
4872  break;
4873 
4874  case IpcTypes::Socket:
4875 
4876  portPipeLabel->Show();
4877  portPipeLabel->Text = "DiagManager Ports";
4878 
4879  textBoxDiagPortPipe->Show();
4880  textBoxDiagPortPipe->Text = piml->DefaultDiagPort.ToString();
4881  textBoxDiagPortPipe->TextChanged+= gcnew System::EventHandler(this, &SampleForm::textBoxPortPipe_TextChanged);
4882 
4883  break;
4884 
4885  case IpcTypes::Pipe:
4886 
4887  portPipeLabel->Show();
4888  portPipeLabel->Text = "DiagManager Pipes";
4889 
4890  textBoxDiagPortPipe->Show();
4891  textBoxDiagPortPipe->Text = Util::Util::ToString(piml->DefaultDiagPipeName);
4892  textBoxDiagPortPipe->TextChanged+= gcnew System::EventHandler(this, &SampleForm::textBoxPortPipe_TextChanged);
4893 
4894  break;
4895 
4896  }
4897 
4898  piml->GlobalRuntimeManager = CreateRuntimeManager();
4899 }
4900 
4901 System::Void SampleForm::checkBoxIncludedDiagLogging_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
4902 {
4903  comboBoxDiagLoggingTraceLevel->Enabled = checkBoxIncludedDiagLogging->Checked;
4904 
4905  UpdateDiagLogging();
4906 }
4907 
4908 System::Void SampleForm::buttonOpenDiagLoggingTraceFolder_Click(System::Object^ sender, System::EventArgs^ e)
4909 {
4910  System::String^ path = textBoxDiagManagerTraceFolder->Text;
4911  if (System::IO::Directory::Exists(path))
4912  {
4913  System::Diagnostics::Process::Start(path);
4914  }
4915 }
4916 
4917 System::Void SampleForm::buttonBrowseDiagLoggingTraceFolder_Click(System::Object ^ sender, System::EventArgs ^ e)
4918 {
4919  folderBrowserDialog1->SelectedPath = textBoxDiagManagerTraceFolder->Text;
4920  folderBrowserDialog1->ShowNewFolderButton = true;
4921 
4922  System::Windows::Forms::DialogResult result = folderBrowserDialog1->ShowDialog();
4923  if (result==System::Windows::Forms::DialogResult::OK)
4924  {
4925  textBoxDiagManagerTraceFolder->Text = folderBrowserDialog1->SelectedPath;
4926  }
4927 }
4928 
4929 System::Void SampleForm::textBoxDiagManagerLicenseKey_KeyDown(System::Object ^ sender, System::Windows::Forms::KeyEventArgs ^ e)
4930 {
4931  if (e->KeyCode == System::Windows::Forms::Keys::Delete || e->KeyCode == System::Windows::Forms::Keys::Back)
4932  {
4933  textBoxDiagManagerLicenseKey->Clear();
4934  }
4935 }
4936 
4937 System::Void SampleForm::textBoxDiagManagerLicenseKey_TextChanged(System::Object ^ sender, System::EventArgs ^ e)
4938 {
4939  System::Windows::Forms::TextBox^ textBox = dynamic_cast<System::Windows::Forms::TextBox^>(sender);
4940  System::String^ inputRemoveHyphen = textBox->Text->Replace("-", "");
4941 
4942  System::Text::StringBuilder^ formattedLicenseKey = gcnew System::Text::StringBuilder();
4943  for (int i = 0; i < inputRemoveHyphen->Length; i++)
4944  {
4945  formattedLicenseKey->Append(inputRemoveHyphen[i]);
4946  if ((i + 1) % 5 == 0 && i + 1 < inputRemoveHyphen->Length)
4947  {
4948  formattedLicenseKey->Append("-");
4949  }
4950  }
4951 
4952  if (formattedLicenseKey->Length > 29)
4953  {
4954  formattedLicenseKey->Length = 29;
4955  }
4956 
4957  textBoxDiagManagerLicenseKey->Text = formattedLicenseKey->ToString();
4958  textBoxDiagManagerLicenseKey->SelectionStart = textBoxDiagManagerLicenseKey->Text->Length;
4959 
4960  std::string licenseKey = Util::Util::ToString(textBoxDiagManagerLicenseKey->Text);
4961  if (Util::LicenseUtil::CheckLicenseFormat(licenseKey))
4962  {
4963  this->piml->ErrorProvider->Clear();
4964  try
4965  {
4966  std::shared_ptr<OpenTestSystem::Otx::DiagManager::OtxDiagApi::IOtxDiag> otxDiag = Util::OtxDiagUtil::RawOtxDiag(licenseKey);
4967  }
4968  catch (const std::exception& ex)
4969  {
4970  piml->ErrorProvider->SetError(textBoxDiagManagerLicenseKey, Util::Util::ToString(ex.what()));
4971  }
4972  catch (System::Exception^ ex)
4973  {
4974  piml->ErrorProvider->SetError(textBoxDiagManagerLicenseKey, ex->Message);
4975  }
4976 
4977  try
4978  {
4979  piml->GlobalRuntimeManager = CreateRuntimeManager();
4980  }
4981  catch (const std::exception& ex)
4982  {
4983  PrintException(ex);
4984  }
4985  catch (System::Exception^ ex)
4986  {
4987  PrintException(ex);
4988  }
4989  }
4990  else
4991  {
4992  if (System::String::IsNullOrEmpty(this->piml->ErrorProvider->GetError(textBoxDiagManagerLicenseKey)))
4993  {
4994  this->piml->ErrorProvider->SetError(textBoxDiagManagerLicenseKey, "License key does not match the desired format XXXXX-XXXXX-XXXXX-XXXXX-XXXXX.");
4995  }
4996  }
4997 }
4998 
4999 System::Void SampleForm::comboBoxDiagManagerTraceLevel_SelectedValueChanged(System::Object ^ sender, System::EventArgs ^ e)
5000 {
5001  OpenTestSystem::Otx::DiagManager::Common::ILog::Level loggerLevel = Util::Util::ToLoggerLevel(comboBoxDiagManagerTraceLevel->SelectedItem->ToString());
5002 
5003  Util::OtxDiagUtil::SetLevelLogger(loggerLevel);
5004  PrintTextCallback("Updated trace level");
5005 }
5006 
5007 void SampleForm::UpdateDiagLogging()
5008 {
5009  if (checkBoxIncludedDiagLogging->Checked && comboBoxDiagLoggingTraceLevel->SelectedItem != nullptr)
5010  {
5011  OpenTestSystem::Otx::DiagManager::NoneOtxDiagApi::INoneOtxDiag::LogLevels logLevel = Util::Util::ToDiagDiagnosticsLogLevel(comboBoxDiagLoggingTraceLevel->SelectedItem->ToString());
5012  std::string diagTraceFolder = Util::Util::ToString(textBoxDiagManagerTraceFolder->Text);
5013 
5014  Util::OtxDiagUtil::SetDiagDiagnosticLogging(logLevel, diagTraceFolder);
5015  }
5016  else
5017  {
5018  std::string traceFolder = Util::Util::ToString(textBoxDiagManagerTraceFolder->Text->Trim());
5019  Util::OtxDiagUtil::SetDiagDiagnosticLogging(Util::OtxDiagUtil::GetDiagnosticLogLevelDefault(), traceFolder);
5020  }
5021 }
5022 
5023 System::Void SampleForm::comboBoxDiagLoggingTraceLevel_SelectedValueChanged(System::Object ^ sender, System::EventArgs ^ e)
5024 {
5025  UpdateDiagLogging();
5026 }
5027 
5028 System::Void SampleForm::textBoxDiagManagerTraceFolder_TextChanged(System::Object^ sender, System::EventArgs^ e)
5029 {
5030  std::string diagTraceFolder = Util::Util::ToString(textBoxDiagManagerTraceFolder->Text);
5031 
5032  Util::OtxDiagUtil::SetPathLogger(diagTraceFolder);
5033  UpdateDiagLogging();
5034 }
5035 #pragma endregion
LogLevels
Levels for logging of diagnostic communication
Definition: INoneOtxDiag.h:21
static void SetLicenseKey(const std::string &licenseKey)
Sets a valid license key to release the API.
TraceLevels GetTraceLevel() const
Gets OTX-Runtime Tracing Level. The Tracing is the internal logging of the API. Default value: ERROR.
bool SetTraceFolder(const std::string &path)
Sets directory where the trace files are stored.
bool SetTraceLevel(const TraceLevels traceLevel)
Sets OTX-Runtime Tracing Level. The Tracing is the internal logging of the API. Default value: ERROR.
static RuntimeConfig & GetInstance()
Get RuntimeConfig Instance
ExecutionStateChangeReason
Reason, why a procedure execution state was changed, e.g. Paused or Running
Definition: ExecutionStateChangeReason.h:12
ClampState
Contains the state of a clamp
Definition: ClampState.h:12
@ NotAvailable
The clamp state cannot be determined (default)
ExpectedState
Contains the expected state of the diagnostic connection
Definition: ExpectedState.h:12
@ BatteryOn
The connection state is battery ON, which means KL30 is On AND KL15 will be ignored
@ IgnitionOff
The connection state is ignition OFF, which means KL30 is On AND KL15 is Off OR KL15 is NotAvailable
@ IgnitionOn
The connection state is ignition ON, which means KL30 is On AND KL15 is On

Code Example Header-File

Code example (.\otxruntime\ReferenceApplication\src\Gui\SampleForm.h) of the OTX-Runtime API Sample Program.

1 #pragma once
2 
3 #include "CustomImplTypes.h"
4 #include "IRuntimeManager.h"
5 #include "CLRWrapper.h"
6 
7 #include <Project/IProject.h>
8 #include <Otx/IPackage.h>
9 #include <Otx/IDocument.h>
10 #include <Otx/IProcedure.h>
11 #include <KeyEventArgs.h>
12 #include <Exceptions/Exception.h>
13 using namespace OpenTestSystem::Otx::Runtime::Api;
14 
15 #include <memory>
16 
17 namespace OpenTestSystem { namespace Otx { namespace Runtime2 { namespace Api { namespace Sample {
18 
19  struct SampleFormImpl;
20 
24  public ref class SampleForm : public System::Windows::Forms::Form
25  {
26  public:
27  SampleForm(void)
28  {
29  InitializeComponent();
30  //
31  //TODO: Add the constructor code here
32  //
33  InitializeInternalComponent();
34  }
35  SampleForm(System::String^ title, SampleForm^ createForm);
36 
37  protected:
41  ~SampleForm()
42  {
43  if (components)
44  {
45  delete components;
46  }
47 
48  if (piml)
49  {
50  delete piml;
51  }
52  }
53 
54  private: System::Windows::Forms::Panel^ panel1;
55  private: System::Windows::Forms::Button^ buttonBrowseFile;
56  private: System::Windows::Forms::ComboBox^ cbFilePath;
57  private: System::Windows::Forms::Label^ label1;
58  private: System::Windows::Forms::Panel^ panel2;
59  private: System::Windows::Forms::OpenFileDialog^ openFileDialog1;
60  private: System::Windows::Forms::TextBox^ txtPassword;
61  private: System::Windows::Forms::Label^ passwordLabel;
62  private: System::Windows::Forms::SplitContainer^ splitContainer1;
63  private: System::Windows::Forms::TreeView^ treeViewOtxProject;
64  private: System::Windows::Forms::Label^ label3;
65  private: System::Windows::Forms::DataGridView^ gridViewParameter;
66  private: System::Windows::Forms::Label^ labelAdjustProcedureParameters;
67  private: System::Windows::Forms::Button^ buttonExecuteSelectedProcedure;
68  private: System::Windows::Forms::Button^ buttonReload;
69  private: System::Windows::Forms::SplitContainer^ splitContainer2;
70  private: System::Windows::Forms::SplitContainer^ splitContainer3;
71  private: System::Windows::Forms::Label^ label4;
72  private: System::Windows::Forms::DataGridView^ gridViewContext;
73  private: System::Windows::Forms::Label^ label5;
74  private: System::Windows::Forms::DataGridView^ gridViewState;
75  private: System::Windows::Forms::SplitContainer^ splitContainer4;
76  private: System::Windows::Forms::ComboBox^ comboBoxTraceLevel;
77  private: System::Windows::Forms::Label^ label8;
78  private: System::Windows::Forms::Label^ label6;
79  private: System::Windows::Forms::TextBox^ textBoxTraceFolder;
80  private: System::Windows::Forms::Label^ label9;
81  private: System::Windows::Forms::Button^ buttonBrowseTraceFolder;
82  private: System::Windows::Forms::ComboBox^ comboBoxIpcType;
83  private: System::Windows::Forms::Label^ label11;
84  private: System::Windows::Forms::Label^ label10;
85  private: System::Windows::Forms::Label^ portPipeLabel;
86  private: System::Windows::Forms::TextBox^ textBoxRtPortPipe;
87  private: System::Windows::Forms::Button^ buttonExecuteMain;
88  private: System::Windows::Forms::Button^ buttonStop;
89  private: System::Windows::Forms::CheckBox^ checkBoxCyclicExecution;
90  private: System::Windows::Forms::CheckBox^ checkBoxAsyncExecution;
91  private: System::Windows::Forms::Button^ buttonNewInstanceNewThread;
92  private: System::Windows::Forms::Button^ buttonNewInstance;
93  private: System::Windows::Forms::Label^ labelOutputOverflow;
94  private: System::Windows::Forms::Button^ buttonCopyRow;
95  private: System::Windows::Forms::Button^ buttonClearOutput;
96  private: System::Windows::Forms::ListBox^ listBoxOuput;
97  private: System::Windows::Forms::FolderBrowserDialog^ folderBrowserDialog1;
98  private: System::Windows::Forms::ImageList^ imageList1;
99  private: System::Windows::Forms::SplitContainer^ splitContainer5;
100  private: System::Windows::Forms::GroupBox^ groupBox1;
101  private: System::Windows::Forms::RadioButton^ radioButtonDefaultImplementation;
102  private: System::Windows::Forms::RadioButton^ radioButtonOuputWindow;
103  private: System::Windows::Forms::RadioButton^ radioButtonNoCustomImplementation;
104  private: System::Windows::Forms::Panel^ panel3;
105  private: System::Windows::Forms::Panel^ panel4;
106  private: System::Windows::Forms::Button^ buttonWriteSettings;
107  private: System::Windows::Forms::Button^ buttonReadSettings;
108  private: System::Windows::Forms::DataGridView^ gridViewSettings;
109  private: System::Windows::Forms::Label^ label12;
110  private: System::Windows::Forms::CheckBox^ buttonHmi;
111  private: System::Windows::Forms::CheckBox^ checkBoxCyclicReload;
112  private: System::Windows::Forms::Label^ label13;
113  private: System::Windows::Forms::Label^ label15;
114  private: System::Windows::Forms::Label^ label14;
115  private: System::Windows::Forms::DataGridViewTextBoxColumn^ dataGridViewTextBoxColumnSettingName;
116  private: System::Windows::Forms::DataGridViewTextBoxColumn^ dataGridViewTextBoxColumnSettingValue;
117  private: System::Windows::Forms::CheckBox^ checkBoxAdd2Output;
118  private: System::Windows::Forms::CheckBox^ checkBoxNewRuntimeManager;
119  private: System::Windows::Forms::TextBox^ textBoxRuntimeContextName;
120  private: System::Windows::Forms::Label^ runtimeNameLabel;
121  private: System::Windows::Forms::CheckBox^ buttonPause;
122  private: System::Windows::Forms::CheckBox^ checkBoxIgnition;
123  private: System::Windows::Forms::CheckBox^ checkBoxUseConnectionState;
124  private: System::Windows::Forms::TextBox^ textBoxVoltageThreshold;
125  private: System::Windows::Forms::Label^ labelVoltageThreshold;
126  private: System::Windows::Forms::TextBox^ textBoxPollingTime;
127  private: System::Windows::Forms::Label^ labelPollingTime;
128  private: System::Windows::Forms::Label^ labelTimeout;
129  private: System::Windows::Forms::TextBox^ textBoxTimeout;
130  private: System::Windows::Forms::TextBox^ textBoxDiagPortPipe;
131  private: System::Windows::Forms::Button^ buttonOpenTraceFolder;
132  private: System::Windows::Forms::Label^ labelSeparator2;
133  private: System::Windows::Forms::Label^ labelProcedureExecutionState;
134  private: System::Windows::Forms::TableLayoutPanel^ tableLayoutPanelExecutionState;
135  private: System::Windows::Forms::Label^ label18;
136  private: System::Windows::Forms::Label^ labelExpectedState;
137  private: System::Windows::Forms::Label^ labelSeparator3;
138  private: System::Windows::Forms::Label^ labelSeparator4;
139  private: System::Windows::Forms::Label^ labelSeparator1;
140  private: System::Windows::Forms::Label^ labelBatteryState;
141  private: System::Windows::Forms::Label^ labelIconProcedureExecutionState;
142  private: System::Windows::Forms::Button^ buttonCheckBatteryIgnition;
143  private: System::Windows::Forms::Label^ labelIgnitionState;
144  private: System::Windows::Forms::CheckBox^ checkBoxStartAllParents;
145  private: System::Windows::Forms::TextBox^ textBoxTraceFileMaxSize;
146  private: System::Windows::Forms::TextBox^ textBoxTraceFileMaxCount;
147  private: System::Windows::Forms::Label^ label2;
148  private: System::Windows::Forms::Timer^ updateGuiTimer;
149  private: System::Windows::Forms::Label^ labelSeparator5;
150  private: System::Windows::Forms::Label^ labelProcedureExecutionTimes;
151  private: System::Windows::Forms::ToolTip^ toolTip1;
152  private: System::Windows::Forms::Button^ buttonStartStopWebServer;
153  private: System::Windows::Forms::Button^ buttonLicense;
154  private: System::ComponentModel::IContainer^ components;
155  private: System::Windows::Forms::DataGridViewTextBoxColumn^ dataGridViewTextBoxColumnName;
156  private: System::Windows::Forms::DataGridViewTextBoxColumn^ dataGridViewTextBoxColumnDirection;
157  private: System::Windows::Forms::DataGridViewTextBoxColumn^ dataGridViewTextBoxColumnDataType;
158  private: System::Windows::Forms::DataGridViewTextBoxColumn^ dataGridViewTextBoxColumnValue;
159  private: System::Windows::Forms::DataGridViewTextBoxColumn^ dataGridViewTextBoxColumnDetails;
160  private: System::Windows::Forms::DataGridViewTextBoxColumn^ dataGridViewTextBoxColumnContextName;
161  private: System::Windows::Forms::DataGridViewTextBoxColumn^ dataGridViewTextBoxColumnContextDataType;
162  private: System::Windows::Forms::DataGridViewTextBoxColumn^ dataGridViewTextBoxColumnContextValue;
163  private: System::Windows::Forms::DataGridViewTextBoxColumn^ dataGridViewTextBoxColumnContextDetails;
164  private: System::Windows::Forms::DataGridViewTextBoxColumn^ dataGridViewTextBoxColumnStateName;
165  private: System::Windows::Forms::DataGridViewTextBoxColumn^ dataGridViewTextBoxColumnStateDataType;
166  private: System::Windows::Forms::DataGridViewTextBoxColumn^ dataGridViewTextBoxColumnStateValue;
167  private: System::Windows::Forms::DataGridViewTextBoxColumn^ dataGridViewTextBoxColumnStateDetails;
168  private: System::Windows::Forms::ComboBox^ comboBoxODXProject;
169  private: System::Windows::Forms::ComboBox^ comboBoxODXVehicle;
170  private: System::Windows::Forms::Label^ labelDiagType;
171  private: System::Windows::Forms::Label^ labelOdxProject;
172  private: System::Windows::Forms::Label^ labelODXVehicle;
173  private: System::Windows::Forms::Label^ label7;
174  private: System::Windows::Forms::ComboBox^ comboBoxDiagIpcType;
175  private: System::Windows::Forms::CheckBox^ checkBoxIncludedDiagLogging;
176  private: System::Windows::Forms::ComboBox^ comboBoxDiagManagerTraceLevel;
177  private: System::Windows::Forms::Label^ label16;
178  private: System::Windows::Forms::TextBox^ textBoxDiagManagerLicenseKey;
179  private: System::Windows::Forms::ComboBox^ comboBoxDiagLoggingTraceLevel;
180  private: System::Windows::Forms::Label^ label17;
181  private: System::Windows::Forms::TextBox^ textBoxDiagManagerTraceFolder;
182  private: System::Windows::Forms::Label^ label19;
183  private: System::Windows::Forms::Button^ buttonBrowseDiagLoggingTraceFolder;
184  private: System::Windows::Forms::Button^ buttonOpenDiagLoggingTraceFolder;
185 
186  protected:
187 
188  private:
192  SampleFormImpl* piml;
193 
194  void RegisterSettingsEvent();
195  void InitializeInternalComponent();
196  void CreateCustomImpl();
197  void CreateDefaultCustomImpl();
198  void CreateOutputWindowCustomImpl();
199  void InitializeSampleDefaultValues();
200  void LoadSetting();
201  void AddComboBoxFileOrPath(System::Windows::Forms::ComboBox^ comboBox);
202  void SetupTraceLevel();
203  void SetupTraceFolder();
204  void SetupTraceFileMaxCountAndSize();
205  void SetupDefaultPortAndPipeName();
206  void SetupCustomImplType();
207  void SetupWindowSize();
208  void SetupWindowLocation();
209  bool CheckFormIsInBound(System::Drawing::Point location);
210  void SetupTimeOut();
211  void SetupPollingTime();
212  void SetupVoltageThreshold();
213  void UpdateWebServerButtonCallback();
214  void SetRuntimeContextName();
215  void SetTitle(System::String^ title);
216  void SetLocation(SampleForm^ creatorForm);
217  void PrintException(System::Exception^ ex);
218  void PrintException(System::Exception^ ex, System::String^ additionalText);
219  void PrintException(const std::exception& ex);
220  void PrintException(const std::exception& ex, System::String^ additionalText);
221  std::shared_ptr<IRuntimeManager> CreateRuntimeManager();
222  std::shared_ptr<IRuntimeManager> CreateRawRuntimeManager();
223  std::shared_ptr<IRuntimeManager> CreateSocketRuntimeManager();
224  std::shared_ptr<IRuntimeManager> CreatePipeRuntimeManager();
225  bool NoDiag();
226  void InitializeRuntimeEvents(std::shared_ptr<IRuntimeManager> runtimeManager);
227  void SetCustomImplementation(std::shared_ptr<IRuntimeManager> runtimeManager);
228  CustomImplTypes GetCurrentCustomImpl();
229  void SetOutputWindowImplementation(std::shared_ptr<IRuntimeManager> runtimeManager);
230  void SetDefaultCustomImplementation(std::shared_ptr<IRuntimeManager> runtimeManager);
231  void RemoveCustomImplementation(std::shared_ptr<IRuntimeManager> runtimeManager);
232  System::String^ GetTimeAndDurationStringSinceLastTimeAndUpdateLastTime();
233  void EnableConnectionState();
234  void SyncWithParent(System::Object^ parentControl);
235  void SyncWithParent(System::Object^ parentControl, System::Object^ control);
236  void SyncWithParent(System::Object^ parentControl, System::Object^ control, bool newThread);
237  void ParentButtonClickCallback(System::Object^ state);
238  void TextBoxSetTextCallback(cli::array<System::Object^>^ arr);
239  void ParentTextBoxSetTextCallback(System::Object^ state);
240  void CheckBoxSetCheckStateCallback(cli::array<System::Object^>^ arr);
241  void ParentCheckBoxSetCheckStateCallback(System::Object^ state);
242  void ComboBoxSetIndexCallback(cli::array<System::Object^>^ arr);
243  void ParentComboBoxSetIndexCallback(System::Object^ state);
244  void NumericUpDownSetValueCallback(cli::array<System::Object^>^ arr);
245  void ParentNumericUpDownSetValueCallback(System::Object^ state);
246  System::String^ IpcPortPipeString();
247  void LoadContextFile(std::shared_ptr<IRuntimeManager> runtimeManager);
248  void ReloadContextFileCallback(CLRWrapper<std::shared_ptr<IRuntimeManager>>^ clrRuntimeManager);
249  void ClearSampleGUI();
250  std::shared_ptr<Project::IProject> LoadPtx(std::shared_ptr<IRuntimeManager> runtimeManager);
251  void ClearCustomImplemetationCaches();
252  void LoadPackage(std::shared_ptr<Project::IProject> project);
253  System::Windows::Forms::TreeNode^ CreatePackageNode(std::shared_ptr<IPackage> pack);
254  System::Windows::Forms::TreeNode^ CreateDocumentNode(std::shared_ptr<IDocument> doc);
255  System::Windows::Forms::TreeNode^ CreateProcedureName(std::shared_ptr<IProcedure> proc);
256  void ReadSettings(std::map<std::string, std::string> settings);
257  std::shared_ptr<Project::IPlayerProject> LoadPpx(std::shared_ptr<IRuntimeManager> runtimeManager);
258  System::Void HmiWindow_FormClosing(System::Object^ sender, System::Windows::Forms::FormClosingEventArgs^ e);
259  System::Void NewInstanceInThread();
260  void ExecuteProcedure();
261  void ExecuteProcedureSync(cli::array<System::Object^>^ args);
262  void CheckBatteryIgnitionState(std::shared_ptr<IRuntimeManager> runtimeManager);
263  void SetBatteryIgnitionState(ClampState batteryState, ClampState ignitionState);
264  void UpdateGridView(std::shared_ptr<IProcedure> procedure);
265  void UpdateGridviewParameter(std::shared_ptr<IProcedure> procedure);
266  void UpdateGridviewParameter(std::shared_ptr<IProcedureParameter> parameter);
267  System::String^ ConvertValue2String(std::shared_ptr<DataTypes::Object> value);
268  System::String^ GetDetails(std::shared_ptr<DataTypes::Object> value);
269  void UpdateGridViewContextVariable(std::shared_ptr<IDocument> document, bool withPrefix, std::vector<std::string>& listItemReviewed);
270  void UpdateGridViewStateVariable(std::shared_ptr<IDocument> document, bool withPrefix, std::vector<std::string>& listItemReviewed);
271  void DoCyclic(System::Object^ args);
272  void CheckCyclicReloadOrNewRuntimeManager(std::shared_ptr<IRuntimeManager> runtimeManager);
273  void CheckCyclicReloadOrNewRuntimeManager(std::shared_ptr<IRuntimeManager> runtimeManager, bool waitCyclic);
274  void CheckCyclicReloadOrNewRuntimeManagerCallback(cli::array<System::Object^>^ arr);
275  void WaitCyclicExecuteAsyncIsProcessing();
276  void UpdateButtonStateAfterThrowException();
277  void UpdateExecutionStateButtons(bool wasExecuted);
278  void UpdatePauseButton(bool pauseAvailable);
279  void UpdatePauseButton(bool pauseAvailable, bool enabled);
280  void DisplayProcedureExecutionTimes();
281  void SaveSettings();
282  void SaveSocketPortOrPipeName();
283  void SetExpectedState();
284  std::shared_ptr<Project::IProject> GetProject(std::shared_ptr<IProcedure> procedure);
285  void UpdateExecutionState(IRuntimeContext* context);
286  void UpdateExecutionState(IRuntimeContext* context, ExecutionStateChangeReason reason);
287  void AddRuntimeContext(IRuntimeContext* context);
288  IRuntimeContext* GetRuntimeContext(long long runtimeId);
289  void DisplayProcedureExecutionState(IRuntimeContext* context);
290  void DisplayProcedureExecutionState(IRuntimeContext* context, System::String^ errorMessage);
291  void RemoveRuntimeContext(IRuntimeContext* context);
292  void StartStopUpdateGuiTimer();
293  void ShowConnectionStateMessage(IRuntimeContext* context);
294  std::string ShortenedValueString(std::shared_ptr<DataTypes::Object> value);
295  bool IsPauseEnabled();
296  bool IsContinueEnable();
297 
298  void StartStopWebServerCallback();
299 
300  void InitializeODXProject();
301  void SetupDiagManagerControls();
302  void UpdateDiagLogging();
303 
304  public:
305  void PrintTextCallback(System::String^ text);
306  void ReloadRuntimeManager();
307  void SetInstanceName(System::String^ instanceName);
308  void SetCreatorForm(SampleForm^ creatorForm);
309 
310  void ProcedurePendingCallback(CLRWrapper<IRuntimeContext*>^ clrContext);
311  void ProcedureStartedCallback(CLRWrapper<IRuntimeContext*>^ clrContext);
312  void ProcedurePaused(IRuntimeContext* context, ExecutionStateChangeReason reason);
313  void ProcedurePausedCallback(cli::array<System::Object^>^ arr);
314  void ProcedureContinuedCallback(CLRWrapper<IRuntimeContext*>^ clrContext);
315  void ProcedureFinishedCallback(CLRWrapper<IRuntimeContext*>^ clrContext);
316  void ProcedureStoppedCallback(CLRWrapper<IRuntimeContext*>^ clrContext);
317  void ProcedureAbortedCallback(CLRWrapper<IRuntimeContext*>^ clrContext);
318  void ProcedureTimeoutCallback(CLRWrapper<IRuntimeContext*>^ clrContext);
319  void DiagConnectionStateChanged(ClampState batteryState, ClampState ignitionState);
320  void DiagConnectionStateChangedCallback(cli::array<System::Object^>^ arr);
321  void InOutParameterValueChanged(IRuntimeContext* context, IProcedureInOutParameter* parameter);
322  void InOutParameterValueChangedCallback(cli::array<System::Object^>^ arr);
323  void CustomScreenImplementation_KeyDown(std::shared_ptr<Custom::KeyEventArgs> eventArgs);
324 
325  void ContextVariableRead(std::shared_ptr<IContextVariable> contextVariable, std::shared_ptr<DataTypes::Object> value);
326  void ContextVariableReadCallback(cli::array<System::Object^>^ arr);
327  void StateVariableValueChanged(std::shared_ptr<IStateVariable> stateVariable, std::shared_ptr<DataTypes::Object> value);
328  void StateVariableValueChangedCallback(cli::array<System::Object^>^ arr);
329  void UpdateGridViewStateVariable(std::shared_ptr<IStateVariable> stateVariable);
330 
331  private:
332 #pragma region Windows Form Designer generated code
337  void InitializeComponent(void)
338  {
339  this->components = (gcnew System::ComponentModel::Container());
340  System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(SampleForm::typeid));
341  System::Windows::Forms::DataGridViewCellStyle^ dataGridViewCellStyle1 = (gcnew System::Windows::Forms::DataGridViewCellStyle());
342  System::Windows::Forms::DataGridViewCellStyle^ dataGridViewCellStyle2 = (gcnew System::Windows::Forms::DataGridViewCellStyle());
343  System::Windows::Forms::DataGridViewCellStyle^ dataGridViewCellStyle3 = (gcnew System::Windows::Forms::DataGridViewCellStyle());
344  this->panel1 = (gcnew System::Windows::Forms::Panel());
345  this->buttonBrowseDiagLoggingTraceFolder = (gcnew System::Windows::Forms::Button());
346  this->buttonOpenDiagLoggingTraceFolder = (gcnew System::Windows::Forms::Button());
347  this->textBoxDiagManagerTraceFolder = (gcnew System::Windows::Forms::TextBox());
348  this->label19 = (gcnew System::Windows::Forms::Label());
349  this->comboBoxDiagLoggingTraceLevel = (gcnew System::Windows::Forms::ComboBox());
350  this->label17 = (gcnew System::Windows::Forms::Label());
351  this->checkBoxIncludedDiagLogging = (gcnew System::Windows::Forms::CheckBox());
352  this->comboBoxDiagManagerTraceLevel = (gcnew System::Windows::Forms::ComboBox());
353  this->label16 = (gcnew System::Windows::Forms::Label());
354  this->textBoxDiagManagerLicenseKey = (gcnew System::Windows::Forms::TextBox());
355  this->label7 = (gcnew System::Windows::Forms::Label());
356  this->comboBoxDiagIpcType = (gcnew System::Windows::Forms::ComboBox());
357  this->labelDiagType = (gcnew System::Windows::Forms::Label());
358  this->labelOdxProject = (gcnew System::Windows::Forms::Label());
359  this->labelODXVehicle = (gcnew System::Windows::Forms::Label());
360  this->comboBoxODXVehicle = (gcnew System::Windows::Forms::ComboBox());
361  this->comboBoxODXProject = (gcnew System::Windows::Forms::ComboBox());
362  this->label2 = (gcnew System::Windows::Forms::Label());
363  this->textBoxTraceFileMaxSize = (gcnew System::Windows::Forms::TextBox());
364  this->textBoxTraceFileMaxCount = (gcnew System::Windows::Forms::TextBox());
365  this->buttonOpenTraceFolder = (gcnew System::Windows::Forms::Button());
366  this->textBoxRuntimeContextName = (gcnew System::Windows::Forms::TextBox());
367  this->runtimeNameLabel = (gcnew System::Windows::Forms::Label());
368  this->textBoxDiagPortPipe = (gcnew System::Windows::Forms::TextBox());
369  this->textBoxRtPortPipe = (gcnew System::Windows::Forms::TextBox());
370  this->label13 = (gcnew System::Windows::Forms::Label());
371  this->portPipeLabel = (gcnew System::Windows::Forms::Label());
372  this->comboBoxIpcType = (gcnew System::Windows::Forms::ComboBox());
373  this->label11 = (gcnew System::Windows::Forms::Label());
374  this->label10 = (gcnew System::Windows::Forms::Label());
375  this->buttonBrowseTraceFolder = (gcnew System::Windows::Forms::Button());
376  this->textBoxTraceFolder = (gcnew System::Windows::Forms::TextBox());
377  this->label9 = (gcnew System::Windows::Forms::Label());
378  this->comboBoxTraceLevel = (gcnew System::Windows::Forms::ComboBox());
379  this->label8 = (gcnew System::Windows::Forms::Label());
380  this->label6 = (gcnew System::Windows::Forms::Label());
381  this->buttonReload = (gcnew System::Windows::Forms::Button());
382  this->txtPassword = (gcnew System::Windows::Forms::TextBox());
383  this->passwordLabel = (gcnew System::Windows::Forms::Label());
384  this->buttonBrowseFile = (gcnew System::Windows::Forms::Button());
385  this->cbFilePath = (gcnew System::Windows::Forms::ComboBox());
386  this->label1 = (gcnew System::Windows::Forms::Label());
387  this->textBoxTimeout = (gcnew System::Windows::Forms::TextBox());
388  this->labelTimeout = (gcnew System::Windows::Forms::Label());
389  this->textBoxVoltageThreshold = (gcnew System::Windows::Forms::TextBox());
390  this->labelVoltageThreshold = (gcnew System::Windows::Forms::Label());
391  this->textBoxPollingTime = (gcnew System::Windows::Forms::TextBox());
392  this->labelPollingTime = (gcnew System::Windows::Forms::Label());
393  this->checkBoxIgnition = (gcnew System::Windows::Forms::CheckBox());
394  this->checkBoxUseConnectionState = (gcnew System::Windows::Forms::CheckBox());
395  this->panel2 = (gcnew System::Windows::Forms::Panel());
396  this->buttonLicense = (gcnew System::Windows::Forms::Button());
397  this->buttonStartStopWebServer = (gcnew System::Windows::Forms::Button());
398  this->buttonHmi = (gcnew System::Windows::Forms::CheckBox());
399  this->checkBoxNewRuntimeManager = (gcnew System::Windows::Forms::CheckBox());
400  this->label15 = (gcnew System::Windows::Forms::Label());
401  this->label14 = (gcnew System::Windows::Forms::Label());
402  this->checkBoxCyclicReload = (gcnew System::Windows::Forms::CheckBox());
403  this->listBoxOuput = (gcnew System::Windows::Forms::ListBox());
404  this->labelOutputOverflow = (gcnew System::Windows::Forms::Label());
405  this->buttonCopyRow = (gcnew System::Windows::Forms::Button());
406  this->buttonClearOutput = (gcnew System::Windows::Forms::Button());
407  this->buttonNewInstanceNewThread = (gcnew System::Windows::Forms::Button());
408  this->buttonNewInstance = (gcnew System::Windows::Forms::Button());
409  this->checkBoxStartAllParents = (gcnew System::Windows::Forms::CheckBox());
410  this->checkBoxAdd2Output = (gcnew System::Windows::Forms::CheckBox());
411  this->checkBoxCyclicExecution = (gcnew System::Windows::Forms::CheckBox());
412  this->checkBoxAsyncExecution = (gcnew System::Windows::Forms::CheckBox());
413  this->buttonPause = (gcnew System::Windows::Forms::CheckBox());
414  this->buttonStop = (gcnew System::Windows::Forms::Button());
415  this->buttonExecuteMain = (gcnew System::Windows::Forms::Button());
416  this->buttonExecuteSelectedProcedure = (gcnew System::Windows::Forms::Button());
417  this->openFileDialog1 = (gcnew System::Windows::Forms::OpenFileDialog());
418  this->splitContainer1 = (gcnew System::Windows::Forms::SplitContainer());
419  this->treeViewOtxProject = (gcnew System::Windows::Forms::TreeView());
420  this->label3 = (gcnew System::Windows::Forms::Label());
421  this->splitContainer5 = (gcnew System::Windows::Forms::SplitContainer());
422  this->splitContainer2 = (gcnew System::Windows::Forms::SplitContainer());
423  this->gridViewParameter = (gcnew System::Windows::Forms::DataGridView());
424  this->dataGridViewTextBoxColumnName = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
425  this->dataGridViewTextBoxColumnDirection = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
426  this->dataGridViewTextBoxColumnDataType = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
427  this->dataGridViewTextBoxColumnValue = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
428  this->dataGridViewTextBoxColumnDetails = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
429  this->labelAdjustProcedureParameters = (gcnew System::Windows::Forms::Label());
430  this->splitContainer3 = (gcnew System::Windows::Forms::SplitContainer());
431  this->gridViewContext = (gcnew System::Windows::Forms::DataGridView());
432  this->dataGridViewTextBoxColumnContextName = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
433  this->dataGridViewTextBoxColumnContextDataType = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
434  this->dataGridViewTextBoxColumnContextValue = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
435  this->dataGridViewTextBoxColumnContextDetails = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
436  this->label4 = (gcnew System::Windows::Forms::Label());
437  this->gridViewState = (gcnew System::Windows::Forms::DataGridView());
438  this->dataGridViewTextBoxColumnStateName = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
439  this->dataGridViewTextBoxColumnStateDataType = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
440  this->dataGridViewTextBoxColumnStateValue = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
441  this->dataGridViewTextBoxColumnStateDetails = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
442  this->label5 = (gcnew System::Windows::Forms::Label());
443  this->panel3 = (gcnew System::Windows::Forms::Panel());
444  this->gridViewSettings = (gcnew System::Windows::Forms::DataGridView());
445  this->dataGridViewTextBoxColumnSettingName = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
446  this->dataGridViewTextBoxColumnSettingValue = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
447  this->panel4 = (gcnew System::Windows::Forms::Panel());
448  this->label12 = (gcnew System::Windows::Forms::Label());
449  this->buttonWriteSettings = (gcnew System::Windows::Forms::Button());
450  this->buttonReadSettings = (gcnew System::Windows::Forms::Button());
451  this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
452  this->radioButtonNoCustomImplementation = (gcnew System::Windows::Forms::RadioButton());
453  this->radioButtonDefaultImplementation = (gcnew System::Windows::Forms::RadioButton());
454  this->radioButtonOuputWindow = (gcnew System::Windows::Forms::RadioButton());
455  this->splitContainer4 = (gcnew System::Windows::Forms::SplitContainer());
456  this->folderBrowserDialog1 = (gcnew System::Windows::Forms::FolderBrowserDialog());
457  this->imageList1 = (gcnew System::Windows::Forms::ImageList(this->components));
458  this->labelSeparator2 = (gcnew System::Windows::Forms::Label());
459  this->labelProcedureExecutionState = (gcnew System::Windows::Forms::Label());
460  this->tableLayoutPanelExecutionState = (gcnew System::Windows::Forms::TableLayoutPanel());
461  this->labelIconProcedureExecutionState = (gcnew System::Windows::Forms::Label());
462  this->labelBatteryState = (gcnew System::Windows::Forms::Label());
463  this->labelExpectedState = (gcnew System::Windows::Forms::Label());
464  this->labelSeparator3 = (gcnew System::Windows::Forms::Label());
465  this->labelSeparator4 = (gcnew System::Windows::Forms::Label());
466  this->labelSeparator1 = (gcnew System::Windows::Forms::Label());
467  this->buttonCheckBatteryIgnition = (gcnew System::Windows::Forms::Button());
468  this->labelIgnitionState = (gcnew System::Windows::Forms::Label());
469  this->labelSeparator5 = (gcnew System::Windows::Forms::Label());
470  this->labelProcedureExecutionTimes = (gcnew System::Windows::Forms::Label());
471  this->label18 = (gcnew System::Windows::Forms::Label());
472  this->updateGuiTimer = (gcnew System::Windows::Forms::Timer(this->components));
473  this->toolTip1 = (gcnew System::Windows::Forms::ToolTip(this->components));
474  this->panel1->SuspendLayout();
475  this->panel2->SuspendLayout();
476  (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->splitContainer1))->BeginInit();
477  this->splitContainer1->Panel1->SuspendLayout();
478  this->splitContainer1->Panel2->SuspendLayout();
479  this->splitContainer1->SuspendLayout();
480  (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->splitContainer5))->BeginInit();
481  this->splitContainer5->Panel1->SuspendLayout();
482  this->splitContainer5->Panel2->SuspendLayout();
483  this->splitContainer5->SuspendLayout();
484  (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->splitContainer2))->BeginInit();
485  this->splitContainer2->Panel1->SuspendLayout();
486  this->splitContainer2->Panel2->SuspendLayout();
487  this->splitContainer2->SuspendLayout();
488  (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->gridViewParameter))->BeginInit();
489  (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->splitContainer3))->BeginInit();
490  this->splitContainer3->Panel1->SuspendLayout();
491  this->splitContainer3->Panel2->SuspendLayout();
492  this->splitContainer3->SuspendLayout();
493  (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->gridViewContext))->BeginInit();
494  (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->gridViewState))->BeginInit();
495  this->panel3->SuspendLayout();
496  (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->gridViewSettings))->BeginInit();
497  this->panel4->SuspendLayout();
498  this->groupBox1->SuspendLayout();
499  (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->splitContainer4))->BeginInit();
500  this->splitContainer4->Panel1->SuspendLayout();
501  this->splitContainer4->Panel2->SuspendLayout();
502  this->splitContainer4->SuspendLayout();
503  this->tableLayoutPanelExecutionState->SuspendLayout();
504  this->SuspendLayout();
505  //
506  // panel1
507  //
508  this->panel1->Controls->Add(this->buttonBrowseDiagLoggingTraceFolder);
509  this->panel1->Controls->Add(this->buttonOpenDiagLoggingTraceFolder);
510  this->panel1->Controls->Add(this->textBoxDiagManagerTraceFolder);
511  this->panel1->Controls->Add(this->label19);
512  this->panel1->Controls->Add(this->comboBoxDiagLoggingTraceLevel);
513  this->panel1->Controls->Add(this->label17);
514  this->panel1->Controls->Add(this->checkBoxIncludedDiagLogging);
515  this->panel1->Controls->Add(this->comboBoxDiagManagerTraceLevel);
516  this->panel1->Controls->Add(this->label16);
517  this->panel1->Controls->Add(this->textBoxDiagManagerLicenseKey);
518  this->panel1->Controls->Add(this->label7);
519  this->panel1->Controls->Add(this->comboBoxDiagIpcType);
520  this->panel1->Controls->Add(this->labelDiagType);
521  this->panel1->Controls->Add(this->labelOdxProject);
522  this->panel1->Controls->Add(this->labelODXVehicle);
523  this->panel1->Controls->Add(this->comboBoxODXVehicle);
524  this->panel1->Controls->Add(this->comboBoxODXProject);
525  this->panel1->Controls->Add(this->label2);
526  this->panel1->Controls->Add(this->textBoxTraceFileMaxSize);
527  this->panel1->Controls->Add(this->textBoxTraceFileMaxCount);
528  this->panel1->Controls->Add(this->buttonOpenTraceFolder);
529  this->panel1->Controls->Add(this->textBoxRuntimeContextName);
530  this->panel1->Controls->Add(this->runtimeNameLabel);
531  this->panel1->Controls->Add(this->textBoxDiagPortPipe);
532  this->panel1->Controls->Add(this->textBoxRtPortPipe);
533  this->panel1->Controls->Add(this->label13);
534  this->panel1->Controls->Add(this->portPipeLabel);
535  this->panel1->Controls->Add(this->comboBoxIpcType);
536  this->panel1->Controls->Add(this->label11);
537  this->panel1->Controls->Add(this->label10);
538  this->panel1->Controls->Add(this->buttonBrowseTraceFolder);
539  this->panel1->Controls->Add(this->textBoxTraceFolder);
540  this->panel1->Controls->Add(this->label9);
541  this->panel1->Controls->Add(this->comboBoxTraceLevel);
542  this->panel1->Controls->Add(this->label8);
543  this->panel1->Controls->Add(this->label6);
544  this->panel1->Controls->Add(this->buttonReload);
545  this->panel1->Controls->Add(this->txtPassword);
546  this->panel1->Controls->Add(this->passwordLabel);
547  this->panel1->Controls->Add(this->buttonBrowseFile);
548  this->panel1->Controls->Add(this->cbFilePath);
549  this->panel1->Controls->Add(this->label1);
550  this->panel1->Dock = System::Windows::Forms::DockStyle::Top;
551  this->panel1->Location = System::Drawing::Point(0, 0);
552  this->panel1->Name = L"panel1";
553  this->panel1->Padding = System::Windows::Forms::Padding(0, 0, 0, 6);
554  this->panel1->Size = System::Drawing::Size(1328, 115);
555  this->panel1->TabIndex = 0;
556  //
557  // buttonBrowseDiagLoggingTraceFolder
558  //
559  this->buttonBrowseDiagLoggingTraceFolder->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
560  this->buttonBrowseDiagLoggingTraceFolder->Location = System::Drawing::Point(1298, 86);
561  this->buttonBrowseDiagLoggingTraceFolder->Name = L"buttonBrowseDiagLoggingTraceFolder";
562  this->buttonBrowseDiagLoggingTraceFolder->Size = System::Drawing::Size(30, 23);
563  this->buttonBrowseDiagLoggingTraceFolder->TabIndex = 45;
564  this->buttonBrowseDiagLoggingTraceFolder->Text = L"...";
565  this->buttonBrowseDiagLoggingTraceFolder->UseVisualStyleBackColor = true;
566  this->buttonBrowseDiagLoggingTraceFolder->Click += gcnew System::EventHandler(this, &SampleForm::buttonBrowseDiagLoggingTraceFolder_Click);
567  //
568  // buttonOpenDiagLoggingTraceFolder
569  //
570  this->buttonOpenDiagLoggingTraceFolder->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
571  this->buttonOpenDiagLoggingTraceFolder->Location = System::Drawing::Point(1210, 86);
572  this->buttonOpenDiagLoggingTraceFolder->Name = L"buttonOpenDiagLoggingTraceFolder";
573  this->buttonOpenDiagLoggingTraceFolder->Size = System::Drawing::Size(82, 23);
574  this->buttonOpenDiagLoggingTraceFolder->TabIndex = 44;
575  this->buttonOpenDiagLoggingTraceFolder->Text = L"Open Folder";
576  this->buttonOpenDiagLoggingTraceFolder->UseVisualStyleBackColor = true;
577  this->buttonOpenDiagLoggingTraceFolder->Click += gcnew System::EventHandler(this, &SampleForm::buttonOpenDiagLoggingTraceFolder_Click);
578  //
579  // textBoxDiagManagerTraceFolder
580  //
581  this->textBoxDiagManagerTraceFolder->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
582  this->textBoxDiagManagerTraceFolder->Location = System::Drawing::Point(1095, 88);
583  this->textBoxDiagManagerTraceFolder->Name = L"textBoxDiagManagerTraceFolder";
584  this->textBoxDiagManagerTraceFolder->Size = System::Drawing::Size(109, 20);
585  this->textBoxDiagManagerTraceFolder->TabIndex = 43;
586  this->textBoxDiagManagerTraceFolder->TextChanged += gcnew System::EventHandler(this, &SampleForm::textBoxDiagManagerTraceFolder_TextChanged);
587  //
588  // label19
589  //
590  this->label19->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
591  this->label19->AutoSize = true;
592  this->label19->Location = System::Drawing::Point(1073, 91);
593  this->label19->Name = L"label19";
594  this->label19->Size = System::Drawing::Size(15, 13);
595  this->label19->TabIndex = 42;
596  this->label19->Text = L"in";
597  //
598  // comboBoxDiagLoggingTraceLevel
599  //
600  this->comboBoxDiagLoggingTraceLevel->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
601  this->comboBoxDiagLoggingTraceLevel->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
602  this->comboBoxDiagLoggingTraceLevel->Enabled = false;
603  this->comboBoxDiagLoggingTraceLevel->FormattingEnabled = true;
604  this->comboBoxDiagLoggingTraceLevel->Location = System::Drawing::Point(943, 88);
605  this->comboBoxDiagLoggingTraceLevel->Name = L"comboBoxDiagLoggingTraceLevel";
606  this->comboBoxDiagLoggingTraceLevel->Size = System::Drawing::Size(124, 21);
607  this->comboBoxDiagLoggingTraceLevel->TabIndex = 41;
608  this->comboBoxDiagLoggingTraceLevel->SelectedValueChanged += gcnew System::EventHandler(this, &SampleForm::comboBoxDiagLoggingTraceLevel_SelectedValueChanged);
609  //
610  // label17
611  //
612  this->label17->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
613  this->label17->AutoSize = true;
614  this->label17->Location = System::Drawing::Point(893, 91);
615  this->label17->Name = L"label17";
616  this->label17->Size = System::Drawing::Size(44, 13);
617  this->label17->TabIndex = 40;
618  this->label17->Text = L"at level:";
619  //
620  // checkBoxIncludedDiagLogging
621  //
622  this->checkBoxIncludedDiagLogging->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
623  this->checkBoxIncludedDiagLogging->AutoSize = true;
624  this->checkBoxIncludedDiagLogging->Location = System::Drawing::Point(760, 90);
625  this->checkBoxIncludedDiagLogging->Name = L"checkBoxIncludedDiagLogging";
626  this->checkBoxIncludedDiagLogging->Size = System::Drawing::Size(129, 17);
627  this->checkBoxIncludedDiagLogging->TabIndex = 39;
628  this->checkBoxIncludedDiagLogging->Text = L"included DiagLogging";
629  this->checkBoxIncludedDiagLogging->UseVisualStyleBackColor = true;
630  this->checkBoxIncludedDiagLogging->CheckedChanged += gcnew System::EventHandler(this, &SampleForm::checkBoxIncludedDiagLogging_CheckedChanged);
631  //
632  // comboBoxDiagManagerTraceLevel
633  //
634  this->comboBoxDiagManagerTraceLevel->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
635  this->comboBoxDiagManagerTraceLevel->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
636  this->comboBoxDiagManagerTraceLevel->FormattingEnabled = true;
637  this->comboBoxDiagManagerTraceLevel->Location = System::Drawing::Point(660, 88);
638  this->comboBoxDiagManagerTraceLevel->Name = L"comboBoxDiagManagerTraceLevel";
639  this->comboBoxDiagManagerTraceLevel->Size = System::Drawing::Size(94, 21);
640  this->comboBoxDiagManagerTraceLevel->TabIndex = 38;
641  this->comboBoxDiagManagerTraceLevel->SelectedValueChanged += gcnew System::EventHandler(this, &SampleForm::comboBoxDiagManagerTraceLevel_SelectedValueChanged);
642  //
643  // label16
644  //
645  this->label16->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
646  this->label16->AutoSize = true;
647  this->label16->Location = System::Drawing::Point(598, 91);
648  this->label16->Name = L"label16";
649  this->label16->Size = System::Drawing::Size(59, 13);
650  this->label16->TabIndex = 37;
651  this->label16->Text = L"trace level:";
652  //
653  // textBoxDiagManagerLicenseKey
654  //
655  this->textBoxDiagManagerLicenseKey->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left)
656  | System::Windows::Forms::AnchorStyles::Right));
657  this->textBoxDiagManagerLicenseKey->Location = System::Drawing::Point(128, 88);
658  this->textBoxDiagManagerLicenseKey->Name = L"textBoxDiagManagerLicenseKey";
659  this->textBoxDiagManagerLicenseKey->PasswordChar = '*';
660  this->textBoxDiagManagerLicenseKey->Size = System::Drawing::Size(456, 20);
661  this->textBoxDiagManagerLicenseKey->TabIndex = 36;
662  this->textBoxDiagManagerLicenseKey->TextChanged += gcnew System::EventHandler(this, &SampleForm::textBoxDiagManagerLicenseKey_TextChanged);
663  this->textBoxDiagManagerLicenseKey->KeyDown += gcnew System::Windows::Forms::KeyEventHandler(this, &SampleForm::textBoxDiagManagerLicenseKey_KeyDown);
664  //
665  // label7
666  //
667  this->label7->AutoSize = true;
668  this->label7->Location = System::Drawing::Point(-3, 91);
669  this->label7->Name = L"label7";
670  this->label7->Size = System::Drawing::Size(130, 13);
671  this->label7->TabIndex = 35;
672  this->label7->Text = L"DiagManager license key:";
673  //
674  // comboBoxDiagIpcType
675  //
676  this->comboBoxDiagIpcType->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
677  this->comboBoxDiagIpcType->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
678  this->comboBoxDiagIpcType->FormattingEnabled = true;
679  this->comboBoxDiagIpcType->Location = System::Drawing::Point(943, 61);
680  this->comboBoxDiagIpcType->Name = L"comboBoxDiagIpcType";
681  this->comboBoxDiagIpcType->Size = System::Drawing::Size(93, 21);
682  this->comboBoxDiagIpcType->TabIndex = 34;
683  this->comboBoxDiagIpcType->SelectedValueChanged += gcnew System::EventHandler(this, &SampleForm::comboBoxDiagIpcType_SelectedValueChanged);
684  //
685  // labelDiagType
686  //
687  this->labelDiagType->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
688  this->labelDiagType->AutoSize = true;
689  this->labelDiagType->Location = System::Drawing::Point(878, 65);
690  this->labelDiagType->Name = L"labelDiagType";
691  this->labelDiagType->Size = System::Drawing::Size(59, 13);
692  this->labelDiagType->TabIndex = 33;
693  this->labelDiagType->Text = L"Diag Type:";
694  //
695  // labelOdxProject
696  //
697  this->labelOdxProject->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
698  this->labelOdxProject->AutoSize = true;
699  this->labelOdxProject->Location = System::Drawing::Point(1046, 35);
700  this->labelOdxProject->Name = L"labelOdxProject";
701  this->labelOdxProject->Size = System::Drawing::Size(43, 13);
702  this->labelOdxProject->TabIndex = 32;
703  this->labelOdxProject->Text = L"Project:";
704  //
705  // labelODXVehicle
706  //
707  this->labelODXVehicle->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
708  this->labelODXVehicle->AutoSize = true;
709  this->labelODXVehicle->Location = System::Drawing::Point(1044, 65);
710  this->labelODXVehicle->Name = L"labelODXVehicle";
711  this->labelODXVehicle->Size = System::Drawing::Size(45, 13);
712  this->labelODXVehicle->TabIndex = 31;
713  this->labelODXVehicle->Text = L"Vehicle:";
714  //
715  // comboBoxODXVehicle
716  //
717  this->comboBoxODXVehicle->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
718  this->comboBoxODXVehicle->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
719  this->comboBoxODXVehicle->DropDownWidth = 120;
720  this->comboBoxODXVehicle->FormattingEnabled = true;
721  this->comboBoxODXVehicle->Location = System::Drawing::Point(1095, 61);
722  this->comboBoxODXVehicle->Name = L"comboBoxODXVehicle";
723  this->comboBoxODXVehicle->Size = System::Drawing::Size(233, 21);
724  this->comboBoxODXVehicle->TabIndex = 3;
725  this->comboBoxODXVehicle->SelectedValueChanged += gcnew System::EventHandler(this, &SampleForm::comboBoxODXVehicle_SelectedValueChanged);
726  //
727  // comboBoxODXProject
728  //
729  this->comboBoxODXProject->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
730  this->comboBoxODXProject->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
731  this->comboBoxODXProject->DropDownWidth = 200;
732  this->comboBoxODXProject->FormattingEnabled = true;
733  this->comboBoxODXProject->Location = System::Drawing::Point(1095, 31);
734  this->comboBoxODXProject->Name = L"comboBoxODXProject";
735  this->comboBoxODXProject->Size = System::Drawing::Size(233, 21);
736  this->comboBoxODXProject->TabIndex = 4;
737  this->comboBoxODXProject->SelectedValueChanged += gcnew System::EventHandler(this, &SampleForm::comboBoxODXProject_SelectedValueChanged);
738  //
739  // label2
740  //
741  this->label2->AutoSize = true;
742  this->label2->Location = System::Drawing::Point(165, 34);
743  this->label2->Name = L"label2";
744  this->label2->Size = System::Drawing::Size(54, 13);
745  this->label2->TabIndex = 30;
746  this->label2->Text = L"Files, Size";
747  //
748  // textBoxTraceFileMaxSize
749  //
750  this->textBoxTraceFileMaxSize->Font = (gcnew System::Drawing::Font(L"Consolas", 9));
751  this->textBoxTraceFileMaxSize->Location = System::Drawing::Point(256, 30);
752  this->textBoxTraceFileMaxSize->Name = L"textBoxTraceFileMaxSize";
753  this->textBoxTraceFileMaxSize->Size = System::Drawing::Size(32, 22);
754  this->textBoxTraceFileMaxSize->TabIndex = 29;
755  this->textBoxTraceFileMaxSize->Text = L"100";
756  this->textBoxTraceFileMaxSize->TextAlign = System::Windows::Forms::HorizontalAlignment::Right;
757  this->textBoxTraceFileMaxSize->TextChanged += gcnew System::EventHandler(this, &SampleForm::textBoxTraceFileMaxSize_TextChanged);
758  //
759  // textBoxTraceFileMaxCount
760  //
761  this->textBoxTraceFileMaxCount->Font = (gcnew System::Drawing::Font(L"Consolas", 9));
762  this->textBoxTraceFileMaxCount->Location = System::Drawing::Point(225, 30);
763  this->textBoxTraceFileMaxCount->Name = L"textBoxTraceFileMaxCount";
764  this->textBoxTraceFileMaxCount->Size = System::Drawing::Size(25, 22);
765  this->textBoxTraceFileMaxCount->TabIndex = 28;
766  this->textBoxTraceFileMaxCount->Text = L"10";
767  this->textBoxTraceFileMaxCount->TextAlign = System::Windows::Forms::HorizontalAlignment::Right;
768  this->textBoxTraceFileMaxCount->TextChanged += gcnew System::EventHandler(this, &SampleForm::textBoxTraceFileMaxCount_TextChanged);
769  //
770  // buttonOpenTraceFolder
771  //
772  this->buttonOpenTraceFolder->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
773  this->buttonOpenTraceFolder->Location = System::Drawing::Point(833, 30);
774  this->buttonOpenTraceFolder->Name = L"buttonOpenTraceFolder";
775  this->buttonOpenTraceFolder->Size = System::Drawing::Size(49, 23);
776  this->buttonOpenTraceFolder->TabIndex = 15;
777  this->buttonOpenTraceFolder->Text = L"Open...";
778  this->buttonOpenTraceFolder->UseVisualStyleBackColor = true;
779  this->buttonOpenTraceFolder->Click += gcnew System::EventHandler(this, &SampleForm::buttonOpenTraceFolder_Click);
780  //
781  // textBoxRuntimeContextName
782  //
783  this->textBoxRuntimeContextName->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
784  this->textBoxRuntimeContextName->Font = (gcnew System::Drawing::Font(L"Consolas", 9));
785  this->textBoxRuntimeContextName->Location = System::Drawing::Point(1124, 2);
786  this->textBoxRuntimeContextName->Name = L"textBoxRuntimeContextName";
787  this->textBoxRuntimeContextName->Size = System::Drawing::Size(123, 22);
788  this->textBoxRuntimeContextName->TabIndex = 8;
789  this->textBoxRuntimeContextName->TextChanged += gcnew System::EventHandler(this, &SampleForm::textBoxRuntimeContextName_TextChanged);
790  //
791  // runtimeNameLabel
792  //
793  this->runtimeNameLabel->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
794  this->runtimeNameLabel->AutoSize = true;
795  this->runtimeNameLabel->Location = System::Drawing::Point(1044, 5);
796  this->runtimeNameLabel->Name = L"runtimeNameLabel";
797  this->runtimeNameLabel->Size = System::Drawing::Size(75, 13);
798  this->runtimeNameLabel->TabIndex = 7;
799  this->runtimeNameLabel->Text = L"Runtime name";
800  //
801  // textBoxDiagPortPipe
802  //
803  this->textBoxDiagPortPipe->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
804  this->textBoxDiagPortPipe->Font = (gcnew System::Drawing::Font(L"Consolas", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
805  static_cast<System::Byte>(0)));
806  this->textBoxDiagPortPipe->Location = System::Drawing::Point(1273, 31);
807  this->textBoxDiagPortPipe->Name = L"textBoxDiagPortPipe";
808  this->textBoxDiagPortPipe->Size = System::Drawing::Size(55, 22);
809  this->textBoxDiagPortPipe->TabIndex = 22;
810  this->textBoxDiagPortPipe->TextChanged += gcnew System::EventHandler(this, &SampleForm::textBoxPortPipe_TextChanged);
811  //
812  // textBoxRtPortPipe
813  //
814  this->textBoxRtPortPipe->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
815  this->textBoxRtPortPipe->BackColor = System::Drawing::SystemColors::Window;
816  this->textBoxRtPortPipe->Font = (gcnew System::Drawing::Font(L"Consolas", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
817  static_cast<System::Byte>(0)));
818  this->textBoxRtPortPipe->Location = System::Drawing::Point(1192, 31);
819  this->textBoxRtPortPipe->Name = L"textBoxRtPortPipe";
820  this->textBoxRtPortPipe->Size = System::Drawing::Size(55, 22);
821  this->textBoxRtPortPipe->TabIndex = 20;
822  this->textBoxRtPortPipe->TextChanged += gcnew System::EventHandler(this, &SampleForm::textBoxPortPipe_TextChanged);
823  //
824  // label13
825  //
826  this->label13->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
827  this->label13->AutoSize = true;
828  this->label13->Location = System::Drawing::Point(1254, 34);
829  this->label13->Name = L"label13";
830  this->label13->Size = System::Drawing::Size(12, 13);
831  this->label13->TabIndex = 21;
832  this->label13->Text = L"/";
833  //
834  // portPipeLabel
835  //
836  this->portPipeLabel->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
837  this->portPipeLabel->AutoSize = true;
838  this->portPipeLabel->Location = System::Drawing::Point(1044, 34);
839  this->portPipeLabel->Name = L"portPipeLabel";
840  this->portPipeLabel->Size = System::Drawing::Size(144, 13);
841  this->portPipeLabel->TabIndex = 19;
842  this->portPipeLabel->Text = L"Runner / DiagManager Ports";
843  //
844  // comboBoxIpcType
845  //
846  this->comboBoxIpcType->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
847  this->comboBoxIpcType->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
848  this->comboBoxIpcType->DropDownWidth = 170;
849  this->comboBoxIpcType->FormattingEnabled = true;
850  this->comboBoxIpcType->Location = System::Drawing::Point(943, 31);
851  this->comboBoxIpcType->Name = L"comboBoxIpcType";
852  this->comboBoxIpcType->Size = System::Drawing::Size(93, 21);
853  this->comboBoxIpcType->TabIndex = 18;
854  this->comboBoxIpcType->SelectedValueChanged += gcnew System::EventHandler(this, &SampleForm::comboBoxIpcType_SelectedValueChanged);
855  //
856  // label11
857  //
858  this->label11->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
859  this->label11->AutoSize = true;
860  this->label11->Location = System::Drawing::Point(895, 34);
861  this->label11->Name = L"label11";
862  this->label11->Size = System::Drawing::Size(24, 13);
863  this->label11->TabIndex = 17;
864  this->label11->Text = L"IPC";
865  //
866  // label10
867  //
868  this->label10->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
869  this->label10->BackColor = System::Drawing::SystemColors::ControlDark;
870  this->label10->Location = System::Drawing::Point(888, 35);
871  this->label10->Name = L"label10";
872  this->label10->Size = System::Drawing::Size(1, 14);
873  this->label10->TabIndex = 16;
874  //
875  // buttonBrowseTraceFolder
876  //
877  this->buttonBrowseTraceFolder->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
878  this->buttonBrowseTraceFolder->Location = System::Drawing::Point(798, 30);
879  this->buttonBrowseTraceFolder->Name = L"buttonBrowseTraceFolder";
880  this->buttonBrowseTraceFolder->Size = System::Drawing::Size(29, 23);
881  this->buttonBrowseTraceFolder->TabIndex = 14;
882  this->buttonBrowseTraceFolder->Text = L"...";
883  this->buttonBrowseTraceFolder->UseVisualStyleBackColor = true;
884  this->buttonBrowseTraceFolder->Click += gcnew System::EventHandler(this, &SampleForm::buttonBrowseTraceFolder_Click);
885  //
886  // textBoxTraceFolder
887  //
888  this->textBoxTraceFolder->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left)
889  | System::Windows::Forms::AnchorStyles::Right));
890  this->textBoxTraceFolder->Font = (gcnew System::Drawing::Font(L"Consolas", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
891  static_cast<System::Byte>(0)));
892  this->textBoxTraceFolder->Location = System::Drawing::Point(306, 30);
893  this->textBoxTraceFolder->Name = L"textBoxTraceFolder";
894  this->textBoxTraceFolder->Size = System::Drawing::Size(486, 22);
895  this->textBoxTraceFolder->TabIndex = 13;
896  this->textBoxTraceFolder->TextChanged += gcnew System::EventHandler(this, &SampleForm::textBoxTraceFolder_TextChanged);
897  //
898  // label9
899  //
900  this->label9->AutoSize = true;
901  this->label9->Location = System::Drawing::Point(291, 35);
902  this->label9->Name = L"label9";
903  this->label9->Size = System::Drawing::Size(15, 13);
904  this->label9->TabIndex = 12;
905  this->label9->Text = L"in";
906  //
907  // comboBoxTraceLevel
908  //
909  this->comboBoxTraceLevel->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
910  this->comboBoxTraceLevel->FormattingEnabled = true;
911  this->comboBoxTraceLevel->Location = System::Drawing::Point(90, 31);
912  this->comboBoxTraceLevel->Name = L"comboBoxTraceLevel";
913  this->comboBoxTraceLevel->Size = System::Drawing::Size(69, 21);
914  this->comboBoxTraceLevel->TabIndex = 11;
915  this->comboBoxTraceLevel->SelectedIndexChanged += gcnew System::EventHandler(this, &SampleForm::comboBoxTraceLevel_SelectedIndexChanged);
916  this->comboBoxTraceLevel->SelectedValueChanged += gcnew System::EventHandler(this, &SampleForm::comboBoxTraceLevel_SelectedValueChanged);
917  //
918  // label8
919  //
920  this->label8->AutoSize = true;
921  this->label8->Location = System::Drawing::Point(-3, 34);
922  this->label8->Name = L"label8";
923  this->label8->Size = System::Drawing::Size(83, 13);
924  this->label8->TabIndex = 10;
925  this->label8->Text = L"TraceFile: Level";
926  //
927  // label6
928  //
929  this->label6->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left)
930  | System::Windows::Forms::AnchorStyles::Right));
931  this->label6->BackColor = System::Drawing::SystemColors::ControlDark;
932  this->label6->Location = System::Drawing::Point(-3, 27);
933  this->label6->Name = L"label6";
934  this->label6->Size = System::Drawing::Size(1332, 1);
935  this->label6->TabIndex = 9;
936  //
937  // buttonReload
938  //
939  this->buttonReload->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
940  this->buttonReload->Enabled = false;
941  this->buttonReload->Location = System::Drawing::Point(833, 1);
942  this->buttonReload->Name = L"buttonReload";
943  this->buttonReload->Size = System::Drawing::Size(49, 23);
944  this->buttonReload->TabIndex = 3;
945  this->buttonReload->Text = L"Reload";
946  this->buttonReload->UseVisualStyleBackColor = true;
947  this->buttonReload->Click += gcnew System::EventHandler(this, &SampleForm::buttonReload_Click);
948  //
949  // txtPassword
950  //
951  this->txtPassword->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
952  this->txtPassword->Font = (gcnew System::Drawing::Font(L"Consolas", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
953  static_cast<System::Byte>(0)));
954  this->txtPassword->Location = System::Drawing::Point(943, 2);
955  this->txtPassword->Name = L"txtPassword";
956  this->txtPassword->PasswordChar = '*';
957  this->txtPassword->Size = System::Drawing::Size(93, 22);
958  this->txtPassword->TabIndex = 5;
959  this->txtPassword->TextChanged += gcnew System::EventHandler(this, &SampleForm::txtPassword_TextChanged);
960  //
961  // passwordLabel
962  //
963  this->passwordLabel->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
964  this->passwordLabel->AutoSize = true;
965  this->passwordLabel->Location = System::Drawing::Point(884, 6);
966  this->passwordLabel->Name = L"passwordLabel";
967  this->passwordLabel->Size = System::Drawing::Size(53, 13);
968  this->passwordLabel->TabIndex = 4;
969  this->passwordLabel->Text = L"Password";
970  //
971  // buttonBrowseFile
972  //
973  this->buttonBrowseFile->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
974  this->buttonBrowseFile->Location = System::Drawing::Point(798, 1);
975  this->buttonBrowseFile->Name = L"buttonBrowseFile";
976  this->buttonBrowseFile->Size = System::Drawing::Size(29, 23);
977  this->buttonBrowseFile->TabIndex = 2;
978  this->buttonBrowseFile->Text = L"...";
979  this->buttonBrowseFile->UseVisualStyleBackColor = true;
980  this->buttonBrowseFile->Click += gcnew System::EventHandler(this, &SampleForm::buttonBrowseFile_Click);
981  //
982  // cbFilePath
983  //
984  this->cbFilePath->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left)
985  | System::Windows::Forms::AnchorStyles::Right));
986  this->cbFilePath->Font = (gcnew System::Drawing::Font(L"Consolas", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
987  static_cast<System::Byte>(0)));
988  this->cbFilePath->Location = System::Drawing::Point(90, 1);
989  this->cbFilePath->Name = L"cbFilePath";
990  this->cbFilePath->Size = System::Drawing::Size(702, 22);
991  this->cbFilePath->TabIndex = 1;
992  this->cbFilePath->SelectedValueChanged += gcnew System::EventHandler(this, &SampleForm::cbFilePath_SelectedValueChanged);
993  this->cbFilePath->TextChanged += gcnew System::EventHandler(this, &SampleForm::cbFilePath_TextChanged);
994  //
995  // label1
996  //
997  this->label1->AutoSize = true;
998  this->label1->Location = System::Drawing::Point(-3, 6);
999  this->label1->Name = L"label1";
1000  this->label1->Size = System::Drawing::Size(87, 13);
1001  this->label1->TabIndex = 0;
1002  this->label1->Text = L"Select PTX/PPX";
1003  //
1004  // textBoxTimeout
1005  //
1006  this->textBoxTimeout->Font = (gcnew System::Drawing::Font(L"Consolas", 9));
1007  this->textBoxTimeout->Location = System::Drawing::Point(642, 3);
1008  this->textBoxTimeout->Name = L"textBoxTimeout";
1009  this->textBoxTimeout->RightToLeft = System::Windows::Forms::RightToLeft::Yes;
1010  this->textBoxTimeout->Size = System::Drawing::Size(45, 22);
1011  this->textBoxTimeout->TabIndex = 4;
1012  this->textBoxTimeout->Text = L"0";
1013  this->textBoxTimeout->TextChanged += gcnew System::EventHandler(this, &SampleForm::textBoxTimeout_TextChanged);
1014  //
1015  // labelTimeout
1016  //
1017  this->labelTimeout->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
1018  this->labelTimeout->AutoSize = true;
1019  this->labelTimeout->Location = System::Drawing::Point(591, 0);
1020  this->labelTimeout->Name = L"labelTimeout";
1021  this->labelTimeout->Padding = System::Windows::Forms::Padding(0, 7, 0, 0);
1022  this->labelTimeout->Size = System::Drawing::Size(45, 20);
1023  this->labelTimeout->TabIndex = 3;
1024  this->labelTimeout->Text = L"Timeout";
1025  //
1026  // textBoxVoltageThreshold
1027  //
1028  this->textBoxVoltageThreshold->Font = (gcnew System::Drawing::Font(L"Consolas", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
1029  static_cast<System::Byte>(0)));
1030  this->textBoxVoltageThreshold->Location = System::Drawing::Point(1301, 3);
1031  this->textBoxVoltageThreshold->Name = L"textBoxVoltageThreshold";
1032  this->textBoxVoltageThreshold->RightToLeft = System::Windows::Forms::RightToLeft::Yes;
1033  this->textBoxVoltageThreshold->Size = System::Drawing::Size(45, 22);
1034  this->textBoxVoltageThreshold->TabIndex = 16;
1035  this->textBoxVoltageThreshold->Text = L"6000";
1036  this->textBoxVoltageThreshold->TextChanged += gcnew System::EventHandler(this, &SampleForm::textBoxBatteryVoltageThreshold_TextChanged);
1037  //
1038  // labelVoltageThreshold
1039  //
1040  this->labelVoltageThreshold->AutoSize = true;
1041  this->labelVoltageThreshold->Location = System::Drawing::Point(1205, 0);
1042  this->labelVoltageThreshold->Name = L"labelVoltageThreshold";
1043  this->labelVoltageThreshold->Padding = System::Windows::Forms::Padding(0, 7, 0, 0);
1044  this->labelVoltageThreshold->Size = System::Drawing::Size(90, 20);
1045  this->labelVoltageThreshold->TabIndex = 15;
1046  this->labelVoltageThreshold->Text = L"VoltageThreshold";
1047  //
1048  // textBoxPollingTime
1049  //
1050  this->textBoxPollingTime->Font = (gcnew System::Drawing::Font(L"Consolas", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
1051  static_cast<System::Byte>(0)));
1052  this->textBoxPollingTime->Location = System::Drawing::Point(1159, 3);
1053  this->textBoxPollingTime->Name = L"textBoxPollingTime";
1054  this->textBoxPollingTime->RightToLeft = System::Windows::Forms::RightToLeft::Yes;
1055  this->textBoxPollingTime->Size = System::Drawing::Size(40, 22);
1056  this->textBoxPollingTime->TabIndex = 14;
1057  this->textBoxPollingTime->Text = L"500";
1058  this->textBoxPollingTime->TextChanged += gcnew System::EventHandler(this, &SampleForm::textBoxPollingTime_TextChanged);
1059  //
1060  // labelPollingTime
1061  //
1062  this->labelPollingTime->AutoSize = true;
1063  this->labelPollingTime->Location = System::Drawing::Point(1092, 0);
1064  this->labelPollingTime->Name = L"labelPollingTime";
1065  this->labelPollingTime->Padding = System::Windows::Forms::Padding(0, 7, 0, 0);
1066  this->labelPollingTime->Size = System::Drawing::Size(61, 20);
1067  this->labelPollingTime->TabIndex = 13;
1068  this->labelPollingTime->Text = L"PollingTime";
1069  //
1070  // checkBoxIgnition
1071  //
1072  this->checkBoxIgnition->AutoSize = true;
1073  this->checkBoxIgnition->Checked = true;
1074  this->checkBoxIgnition->CheckState = System::Windows::Forms::CheckState::Indeterminate;
1075  this->checkBoxIgnition->Location = System::Drawing::Point(978, 3);
1076  this->checkBoxIgnition->Name = L"checkBoxIgnition";
1077  this->checkBoxIgnition->Padding = System::Windows::Forms::Padding(0, 3, 0, 0);
1078  this->checkBoxIgnition->Size = System::Drawing::Size(45, 20);
1079  this->checkBoxIgnition->TabIndex = 10;
1080  this->checkBoxIgnition->Text = L"IGN";
1081  this->checkBoxIgnition->TextImageRelation = System::Windows::Forms::TextImageRelation::TextBeforeImage;
1082  this->checkBoxIgnition->ThreeState = true;
1083  this->checkBoxIgnition->UseVisualStyleBackColor = true;
1084  this->checkBoxIgnition->CheckStateChanged += gcnew System::EventHandler(this, &SampleForm::CheckBoxKL15_CheckStateChanged);
1085  //
1086  // checkBoxUseConnectionState
1087  //
1088  this->checkBoxUseConnectionState->AutoSize = true;
1089  this->checkBoxUseConnectionState->CheckAlign = System::Drawing::ContentAlignment::MiddleRight;
1090  this->checkBoxUseConnectionState->Location = System::Drawing::Point(700, 3);
1091  this->checkBoxUseConnectionState->Name = L"checkBoxUseConnectionState";
1092  this->checkBoxUseConnectionState->Padding = System::Windows::Forms::Padding(0, 3, 0, 0);
1093  this->checkBoxUseConnectionState->Size = System::Drawing::Size(139, 20);
1094  this->checkBoxUseConnectionState->TabIndex = 6;
1095  this->checkBoxUseConnectionState->Text = L"Check ConnectionState";
1096  this->checkBoxUseConnectionState->UseVisualStyleBackColor = true;
1097  this->checkBoxUseConnectionState->CheckedChanged += gcnew System::EventHandler(this, &SampleForm::checkBoxUseConnectionState_CheckedChanged);
1098  //
1099  // panel2
1100  //
1101  this->panel2->Controls->Add(this->buttonLicense);
1102  this->panel2->Controls->Add(this->buttonStartStopWebServer);
1103  this->panel2->Controls->Add(this->buttonHmi);
1104  this->panel2->Controls->Add(this->checkBoxNewRuntimeManager);
1105  this->panel2->Controls->Add(this->label15);
1106  this->panel2->Controls->Add(this->label14);
1107  this->panel2->Controls->Add(this->checkBoxCyclicReload);
1108  this->panel2->Controls->Add(this->listBoxOuput);
1109  this->panel2->Controls->Add(this->labelOutputOverflow);
1110  this->panel2->Controls->Add(this->buttonCopyRow);
1111  this->panel2->Controls->Add(this->buttonClearOutput);
1112  this->panel2->Controls->Add(this->buttonNewInstanceNewThread);
1113  this->panel2->Controls->Add(this->buttonNewInstance);
1114  this->panel2->Controls->Add(this->checkBoxStartAllParents);
1115  this->panel2->Controls->Add(this->checkBoxAdd2Output);
1116  this->panel2->Controls->Add(this->checkBoxCyclicExecution);
1117  this->panel2->Controls->Add(this->checkBoxAsyncExecution);
1118  this->panel2->Controls->Add(this->buttonPause);
1119  this->panel2->Controls->Add(this->buttonStop);
1120  this->panel2->Controls->Add(this->buttonExecuteMain);
1121  this->panel2->Controls->Add(this->buttonExecuteSelectedProcedure);
1122  this->panel2->Dock = System::Windows::Forms::DockStyle::Fill;
1123  this->panel2->Location = System::Drawing::Point(0, 0);
1124  this->panel2->Name = L"panel2";
1125  this->panel2->Size = System::Drawing::Size(1328, 305);
1126  this->panel2->TabIndex = 0;
1127  //
1128  // buttonLicense
1129  //
1130  this->buttonLicense->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
1131  this->buttonLicense->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"buttonLicense.Image")));
1132  this->buttonLicense->ImageAlign = System::Drawing::ContentAlignment::MiddleLeft;
1133  this->buttonLicense->Location = System::Drawing::Point(798, 5);
1134  this->buttonLicense->Name = L"buttonLicense";
1135  this->buttonLicense->Padding = System::Windows::Forms::Padding(10, 0, 5, 0);
1136  this->buttonLicense->Size = System::Drawing::Size(91, 35);
1137  this->buttonLicense->TabIndex = 19;
1138  this->buttonLicense->Tag = L"http://www.emotive.de/DeveloperReference/OtxRuntime/html/3333D311.htm";
1139  this->buttonLicense->Text = L"License";
1140  this->buttonLicense->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
1141  this->buttonLicense->UseVisualStyleBackColor = true;
1142  this->buttonLicense->Click += gcnew System::EventHandler(this, &SampleForm::buttonLicense_Click);
1143  //
1144  // buttonStartStopWebServer
1145  //
1146  this->buttonStartStopWebServer->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
1147  this->buttonStartStopWebServer->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"buttonStartStopWebServer.Image")));
1148  this->buttonStartStopWebServer->ImageAlign = System::Drawing::ContentAlignment::MiddleLeft;
1149  this->buttonStartStopWebServer->Location = System::Drawing::Point(676, 5);
1150  this->buttonStartStopWebServer->Name = L"buttonStartStopWebServer";
1151  this->buttonStartStopWebServer->Padding = System::Windows::Forms::Padding(10, 0, 5, 0);
1152  this->buttonStartStopWebServer->Size = System::Drawing::Size(116, 35);
1153  this->buttonStartStopWebServer->TabIndex = 18;
1154  this->buttonStartStopWebServer->Tag = L"http://www.emotive.de/DeveloperReference/OtxRuntime/html/3333D311.htm";
1155  this->buttonStartStopWebServer->Text = L"Web Server";
1156  this->buttonStartStopWebServer->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
1157  this->buttonStartStopWebServer->UseVisualStyleBackColor = true;
1158  this->buttonStartStopWebServer->Click += gcnew System::EventHandler(this, &SampleForm::buttonStartStopWebServer_Click);
1159  //
1160  // buttonHmi
1161  //
1162  this->buttonHmi->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
1163  this->buttonHmi->Appearance = System::Windows::Forms::Appearance::Button;
1164  this->buttonHmi->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"buttonHmi.Image")));
1165  this->buttonHmi->ImageAlign = System::Drawing::ContentAlignment::MiddleLeft;
1166  this->buttonHmi->Location = System::Drawing::Point(895, 5);
1167  this->buttonHmi->Name = L"buttonHmi";
1168  this->buttonHmi->Padding = System::Windows::Forms::Padding(10, 0, 10, 0);
1169  this->buttonHmi->Size = System::Drawing::Size(80, 35);
1170  this->buttonHmi->TabIndex = 9;
1171  this->buttonHmi->Tag = L"http://www.emotive.de/DeveloperReference/OtxRuntime/html/18FE2C39.htm";
1172  this->buttonHmi->Text = L"HMI";
1173  this->buttonHmi->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
1174  this->buttonHmi->UseVisualStyleBackColor = true;
1175  this->buttonHmi->CheckedChanged += gcnew System::EventHandler(this, &SampleForm::buttonHmi_Click);
1176  //
1177  // checkBoxNewRuntimeManager
1178  //
1179  this->checkBoxNewRuntimeManager->AutoSize = true;
1180  this->checkBoxNewRuntimeManager->Enabled = false;
1181  this->checkBoxNewRuntimeManager->Location = System::Drawing::Point(481, 7);
1182  this->checkBoxNewRuntimeManager->Name = L"checkBoxNewRuntimeManager";
1183  this->checkBoxNewRuntimeManager->Size = System::Drawing::Size(89, 17);
1184  this->checkBoxNewRuntimeManager->TabIndex = 7;
1185  this->checkBoxNewRuntimeManager->Tag = L"http://www.emotive.de/DeveloperReference/OtxRuntime/html/A42F362A.htm";
1186  this->checkBoxNewRuntimeManager->Text = L"New RntMgr.";
1187  this->checkBoxNewRuntimeManager->UseVisualStyleBackColor = true;
1188  this->checkBoxNewRuntimeManager->CheckedChanged += gcnew System::EventHandler(this, &SampleForm::checkBoxNewRuntimeManager_CheckedChanged);
1189  //
1190  // label15
1191  //
1192  this->label15->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left)
1193  | System::Windows::Forms::AnchorStyles::Right));
1194  this->label15->BackColor = System::Drawing::SystemColors::ControlDark;
1195  this->label15->Location = System::Drawing::Point(3, 43);
1196  this->label15->Name = L"label15";
1197  this->label15->Size = System::Drawing::Size(1328, 1);
1198  this->label15->TabIndex = 12;
1199  //
1200  // label14
1201  //
1202  this->label14->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left)
1203  | System::Windows::Forms::AnchorStyles::Right));
1204  this->label14->BackColor = System::Drawing::SystemColors::ControlDark;
1205  this->label14->Location = System::Drawing::Point(1, 1);
1206  this->label14->Name = L"label14";
1207  this->label14->Size = System::Drawing::Size(1328, 1);
1208  this->label14->TabIndex = 0;
1209  //
1210  // checkBoxCyclicReload
1211  //
1212  this->checkBoxCyclicReload->AutoSize = true;
1213  this->checkBoxCyclicReload->Enabled = false;
1214  this->checkBoxCyclicReload->Location = System::Drawing::Point(481, 23);
1215  this->checkBoxCyclicReload->Name = L"checkBoxCyclicReload";
1216  this->checkBoxCyclicReload->Size = System::Drawing::Size(91, 17);
1217  this->checkBoxCyclicReload->TabIndex = 8;
1218  this->checkBoxCyclicReload->Text = L"Cyclic Reload";
1219  this->checkBoxCyclicReload->UseVisualStyleBackColor = true;
1220  this->checkBoxCyclicReload->CheckedChanged += gcnew System::EventHandler(this, &SampleForm::checkBoxCyclicReload_CheckedChanged);
1221  //
1222  // listBoxOuput
1223  //
1224  this->listBoxOuput->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom)
1225  | System::Windows::Forms::AnchorStyles::Left)
1226  | System::Windows::Forms::AnchorStyles::Right));
1227  this->listBoxOuput->Font = (gcnew System::Drawing::Font(L"Consolas", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
1228  static_cast<System::Byte>(0)));
1229  this->listBoxOuput->HorizontalScrollbar = true;
1230  this->listBoxOuput->IntegralHeight = false;
1231  this->listBoxOuput->ItemHeight = 14;
1232  this->listBoxOuput->Location = System::Drawing::Point(0, 76);
1233  this->listBoxOuput->Name = L"listBoxOuput";
1234  this->listBoxOuput->SelectionMode = System::Windows::Forms::SelectionMode::MultiExtended;
1235  this->listBoxOuput->Size = System::Drawing::Size(1328, 81);
1236  this->listBoxOuput->TabIndex = 17;
1237  this->listBoxOuput->SelectedIndexChanged += gcnew System::EventHandler(this, &SampleForm::listBoxOuput_SelectedIndexChanged);
1238  //
1239  // labelOutputOverflow
1240  //
1241  this->labelOutputOverflow->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
1242  this->labelOutputOverflow->AutoSize = true;
1243  this->labelOutputOverflow->ForeColor = System::Drawing::Color::DarkRed;
1244  this->labelOutputOverflow->Location = System::Drawing::Point(781, 53);
1245  this->labelOutputOverflow->Name = L"labelOutputOverflow";
1246  this->labelOutputOverflow->Size = System::Drawing::Size(345, 13);
1247  this->labelOutputOverflow->TabIndex = 14;
1248  this->labelOutputOverflow->Text = L"More than 7,500 lines are in output! After 10,000 all lines will be cleared!";
1249  this->labelOutputOverflow->Visible = false;
1250  //
1251  // buttonCopyRow
1252  //
1253  this->buttonCopyRow->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
1254  this->buttonCopyRow->Enabled = false;
1255  this->buttonCopyRow->Location = System::Drawing::Point(1132, 48);
1256  this->buttonCopyRow->Name = L"buttonCopyRow";
1257  this->buttonCopyRow->Size = System::Drawing::Size(86, 23);
1258  this->buttonCopyRow->TabIndex = 15;
1259  this->buttonCopyRow->Text = L"Copy";
1260  this->buttonCopyRow->UseVisualStyleBackColor = true;
1261  this->buttonCopyRow->Click += gcnew System::EventHandler(this, &SampleForm::buttonCopyRow_Click);
1262  //
1263  // buttonClearOutput
1264  //
1265  this->buttonClearOutput->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
1266  this->buttonClearOutput->Location = System::Drawing::Point(1224, 48);
1267  this->buttonClearOutput->Name = L"buttonClearOutput";
1268  this->buttonClearOutput->Size = System::Drawing::Size(104, 23);
1269  this->buttonClearOutput->TabIndex = 16;
1270  this->buttonClearOutput->Text = L"Clear Output";
1271  this->buttonClearOutput->UseVisualStyleBackColor = true;
1272  this->buttonClearOutput->Click += gcnew System::EventHandler(this, &SampleForm::buttonClearOutput_Click);
1273  //
1274  // buttonNewInstanceNewThread
1275  //
1276  this->buttonNewInstanceNewThread->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
1277  this->buttonNewInstanceNewThread->AutoSize = true;
1278  this->buttonNewInstanceNewThread->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"buttonNewInstanceNewThread.Image")));
1279  this->buttonNewInstanceNewThread->ImageAlign = System::Drawing::ContentAlignment::MiddleLeft;
1280  this->buttonNewInstanceNewThread->Location = System::Drawing::Point(1116, 5);
1281  this->buttonNewInstanceNewThread->Name = L"buttonNewInstanceNewThread";
1282  this->buttonNewInstanceNewThread->Padding = System::Windows::Forms::Padding(10, 0, 10, 0);
1283  this->buttonNewInstanceNewThread->Size = System::Drawing::Size(212, 35);
1284  this->buttonNewInstanceNewThread->TabIndex = 11;
1285  this->buttonNewInstanceNewThread->Tag = L"http://www.emotive.de/DeveloperReference/OtxRuntime/html/18FE2C39.htm";
1286  this->buttonNewInstanceNewThread->Text = L"New Instance - New Thread";
1287  this->buttonNewInstanceNewThread->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
1288  this->buttonNewInstanceNewThread->UseVisualStyleBackColor = true;
1289  this->buttonNewInstanceNewThread->Click += gcnew System::EventHandler(this, &SampleForm::buttonNewInstanceNewThread_Click);
1290  //
1291  // buttonNewInstance
1292  //
1293  this->buttonNewInstance->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right));
1294  this->buttonNewInstance->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"buttonNewInstance.Image")));
1295  this->buttonNewInstance->ImageAlign = System::Drawing::ContentAlignment::MiddleLeft;
1296  this->buttonNewInstance->Location = System::Drawing::Point(981, 5);
1297  this->buttonNewInstance->Name = L"buttonNewInstance";
1298  this->buttonNewInstance->Padding = System::Windows::Forms::Padding(10, 0, 10, 0);
1299  this->buttonNewInstance->Size = System::Drawing::Size(129, 35);
1300  this->buttonNewInstance->TabIndex = 10;
1301  this->buttonNewInstance->Tag = L"http://www.emotive.de/DeveloperReference/OtxRuntime/html/18FE2C39.htm";
1302  this->buttonNewInstance->Text = L"New Instance";
1303  this->buttonNewInstance->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
1304  this->buttonNewInstance->UseVisualStyleBackColor = true;
1305  this->buttonNewInstance->Click += gcnew System::EventHandler(this, &SampleForm::buttonNewInstance_Click);
1306  //
1307  // checkBoxStartAllParents
1308  //
1309  this->checkBoxStartAllParents->AutoSize = true;
1310  this->checkBoxStartAllParents->Location = System::Drawing::Point(149, 51);
1311  this->checkBoxStartAllParents->Name = L"checkBoxStartAllParents";
1312  this->checkBoxStartAllParents->Size = System::Drawing::Size(106, 17);
1313  this->checkBoxStartAllParents->TabIndex = 12;
1314  this->checkBoxStartAllParents->Tag = L"";
1315  this->checkBoxStartAllParents->Text = L"Sync with Parent";
1316  this->checkBoxStartAllParents->UseVisualStyleBackColor = true;
1317  this->checkBoxStartAllParents->Visible = false;
1318  //
1319  // checkBoxAdd2Output
1320  //
1321  this->checkBoxAdd2Output->AutoSize = true;
1322  this->checkBoxAdd2Output->Checked = true;
1323  this->checkBoxAdd2Output->CheckState = System::Windows::Forms::CheckState::Checked;
1324  this->checkBoxAdd2Output->Location = System::Drawing::Point(0, 51);
1325  this->checkBoxAdd2Output->Name = L"checkBoxAdd2Output";
1326  this->checkBoxAdd2Output->Size = System::Drawing::Size(143, 17);
1327  this->checkBoxAdd2Output->TabIndex = 13;
1328  this->checkBoxAdd2Output->Tag = L"";
1329  this->checkBoxAdd2Output->Text = L"Add Messages to Output";
1330  this->checkBoxAdd2Output->UseVisualStyleBackColor = true;
1331  this->checkBoxAdd2Output->CheckedChanged += gcnew System::EventHandler(this, &SampleForm::checkBoxAdd2Output_CheckedChanged);
1332  //
1333  // checkBoxCyclicExecution
1334  //
1335  this->checkBoxCyclicExecution->AutoSize = true;
1336  this->checkBoxCyclicExecution->Location = System::Drawing::Point(405, 23);
1337  this->checkBoxCyclicExecution->Name = L"checkBoxCyclicExecution";
1338  this->checkBoxCyclicExecution->Size = System::Drawing::Size(54, 17);
1339  this->checkBoxCyclicExecution->TabIndex = 6;
1340  this->checkBoxCyclicExecution->Tag = L"";
1341  this->checkBoxCyclicExecution->Text = L"Cyclic";
1342  this->checkBoxCyclicExecution->UseVisualStyleBackColor = true;
1343  this->checkBoxCyclicExecution->CheckedChanged += gcnew System::EventHandler(this, &SampleForm::checkBoxCyclicExecution_CheckedChanged);
1344  //
1345  // checkBoxAsyncExecution
1346  //
1347  this->checkBoxAsyncExecution->AutoSize = true;
1348  this->checkBoxAsyncExecution->Checked = true;
1349  this->checkBoxAsyncExecution->CheckState = System::Windows::Forms::CheckState::Checked;
1350  this->checkBoxAsyncExecution->Location = System::Drawing::Point(405, 7);
1351  this->checkBoxAsyncExecution->Name = L"checkBoxAsyncExecution";
1352  this->checkBoxAsyncExecution->Size = System::Drawing::Size(76, 17);
1353  this->checkBoxAsyncExecution->TabIndex = 5;
1354  this->checkBoxAsyncExecution->Tag = L"http://www.emotive.de/DeveloperReference/OtxRuntime/html/A42F362A.htm";
1355  this->checkBoxAsyncExecution->Text = L"Asynchron";
1356  this->checkBoxAsyncExecution->UseVisualStyleBackColor = true;
1357  this->checkBoxAsyncExecution->CheckedChanged += gcnew System::EventHandler(this, &SampleForm::checkBoxAsyncExecution_CheckedChanged);
1358  //
1359  // buttonPause
1360  //
1361  this->buttonPause->Appearance = System::Windows::Forms::Appearance::Button;
1362  this->buttonPause->Enabled = false;
1363  this->buttonPause->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"buttonPause.Image")));
1364  this->buttonPause->Location = System::Drawing::Point(263, 5);
1365  this->buttonPause->Name = L"buttonPause";
1366  this->buttonPause->Padding = System::Windows::Forms::Padding(10, 0, 10, 0);
1367  this->buttonPause->Size = System::Drawing::Size(42, 35);
1368  this->buttonPause->TabIndex = 3;
1369  this->buttonPause->Tag = L"http://www.emotive.de/DeveloperReference/OtxRuntime/html/3333D311.htm";
1370  this->buttonPause->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
1371  this->buttonPause->UseVisualStyleBackColor = true;
1372  this->buttonPause->CheckedChanged += gcnew System::EventHandler(this, &SampleForm::buttonPause_Click);
1373  //
1374  // buttonStop
1375  //
1376  this->buttonStop->Enabled = false;
1377  this->buttonStop->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"buttonStop.Image")));
1378  this->buttonStop->ImageAlign = System::Drawing::ContentAlignment::MiddleLeft;
1379  this->buttonStop->Location = System::Drawing::Point(311, 5);
1380  this->buttonStop->Name = L"buttonStop";
1381  this->buttonStop->Padding = System::Windows::Forms::Padding(10, 0, 10, 0);
1382  this->buttonStop->Size = System::Drawing::Size(88, 35);
1383  this->buttonStop->TabIndex = 4;
1384  this->buttonStop->Tag = L"http://www.emotive.de/DeveloperReference/OtxRuntime/html/3333D311.htm";
1385  this->buttonStop->Text = L"Stop";
1386  this->buttonStop->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
1387  this->buttonStop->UseVisualStyleBackColor = true;
1388  this->buttonStop->Click += gcnew System::EventHandler(this, &SampleForm::buttonStop_Click);
1389  //
1390  // buttonExecuteMain
1391  //
1392  this->buttonExecuteMain->Enabled = false;
1393  this->buttonExecuteMain->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"buttonExecuteMain.Image")));
1394  this->buttonExecuteMain->ImageAlign = System::Drawing::ContentAlignment::MiddleLeft;
1395  this->buttonExecuteMain->Location = System::Drawing::Point(0, 5);
1396  this->buttonExecuteMain->Name = L"buttonExecuteMain";
1397  this->buttonExecuteMain->Padding = System::Windows::Forms::Padding(10, 0, 10, 0);
1398  this->buttonExecuteMain->Size = System::Drawing::Size(91, 35);
1399  this->buttonExecuteMain->TabIndex = 1;
1400  this->buttonExecuteMain->Text = L"Main";
1401  this->buttonExecuteMain->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
1402  this->buttonExecuteMain->UseVisualStyleBackColor = true;
1403  this->buttonExecuteMain->Click += gcnew System::EventHandler(this, &SampleForm::buttonExecuteMain_Click);
1404  //
1405  // buttonExecuteSelectedProcedure
1406  //
1407  this->buttonExecuteSelectedProcedure->Enabled = false;
1408  this->buttonExecuteSelectedProcedure->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"buttonExecuteSelectedProcedure.Image")));
1409  this->buttonExecuteSelectedProcedure->ImageAlign = System::Drawing::ContentAlignment::MiddleLeft;
1410  this->buttonExecuteSelectedProcedure->Location = System::Drawing::Point(97, 5);
1411  this->buttonExecuteSelectedProcedure->Name = L"buttonExecuteSelectedProcedure";
1412  this->buttonExecuteSelectedProcedure->Padding = System::Windows::Forms::Padding(10, 0, 10, 0);
1413  this->buttonExecuteSelectedProcedure->Size = System::Drawing::Size(160, 35);
1414  this->buttonExecuteSelectedProcedure->TabIndex = 2;
1415  this->buttonExecuteSelectedProcedure->Text = L"Selected Procedure";
1416  this->buttonExecuteSelectedProcedure->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
1417  this->buttonExecuteSelectedProcedure->UseVisualStyleBackColor = true;
1418  this->buttonExecuteSelectedProcedure->Click += gcnew System::EventHandler(this, &SampleForm::buttonExecuteSelectedProcedure_Click);
1419  //
1420  // openFileDialog1
1421  //
1422  this->openFileDialog1->Filter = L"All supported formats(*.ptx, *.ppx)|*.ptx;*.ppx|PTX Files(*.ptx)|*.ptx|PPX Files("
1423  L"*->ppx)|*->ppx|All Files (*->*)|*->*";
1424  this->openFileDialog1->Title = L"Please select a PTX/PPX file";
1425  //
1426  // splitContainer1
1427  //
1428  this->splitContainer1->Dock = System::Windows::Forms::DockStyle::Fill;
1429  this->splitContainer1->FixedPanel = System::Windows::Forms::FixedPanel::Panel1;
1430  this->splitContainer1->Location = System::Drawing::Point(0, 115);
1431  this->splitContainer1->Name = L"splitContainer1";
1432  //
1433  // splitContainer1.Panel1
1434  //
1435  this->splitContainer1->Panel1->Controls->Add(this->treeViewOtxProject);
1436  this->splitContainer1->Panel1->Controls->Add(this->label3);
1437  //
1438  // splitContainer1.Panel2
1439  //
1440  this->splitContainer1->Panel2->Controls->Add(this->splitContainer5);
1441  this->splitContainer1->Size = System::Drawing::Size(1328, 290);
1442  this->splitContainer1->SplitterDistance = 307;
1443  this->splitContainer1->TabIndex = 5;
1444  //
1445  // treeViewOtxProject
1446  //
1447  this->treeViewOtxProject->Dock = System::Windows::Forms::DockStyle::Fill;
1448  this->treeViewOtxProject->Enabled = false;
1449  this->treeViewOtxProject->Font = (gcnew System::Drawing::Font(L"Consolas", 9));
1450  this->treeViewOtxProject->HideSelection = false;
1451  this->treeViewOtxProject->Location = System::Drawing::Point(0, 16);
1452  this->treeViewOtxProject->Name = L"treeViewOtxProject";
1453  this->treeViewOtxProject->Size = System::Drawing::Size(307, 274);
1454  this->treeViewOtxProject->TabIndex = 1;
1455  this->treeViewOtxProject->DrawNode += gcnew System::Windows::Forms::DrawTreeNodeEventHandler(this, &SampleForm::treeViewOtxProject_DrawNode);
1456  this->treeViewOtxProject->AfterSelect += gcnew System::Windows::Forms::TreeViewEventHandler(this, &SampleForm::treeViewOtxProject_AfterSelect);
1457  //
1458  // label3
1459  //
1460  this->label3->AutoSize = true;
1461  this->label3->Dock = System::Windows::Forms::DockStyle::Top;
1462  this->label3->Location = System::Drawing::Point(0, 0);
1463  this->label3->Name = L"label3";
1464  this->label3->Padding = System::Windows::Forms::Padding(0, 0, 0, 3);
1465  this->label3->Size = System::Drawing::Size(245, 16);
1466  this->label3->TabIndex = 0;
1467  this->label3->Tag = L"http://www.emotive.de/DeveloperReference/OtxRuntime/html/671A83F2.htm";
1468  this->label3->Text = L"OTX-Project Tree (To execute select a Procedure)";
1469  //
1470  // splitContainer5
1471  //
1472  this->splitContainer5->Dock = System::Windows::Forms::DockStyle::Fill;
1473  this->splitContainer5->FixedPanel = System::Windows::Forms::FixedPanel::Panel1;
1474  this->splitContainer5->Location = System::Drawing::Point(0, 0);
1475  this->splitContainer5->MinimumSize = System::Drawing::Size(0, 318);
1476  this->splitContainer5->Name = L"splitContainer5";
1477  //
1478  // splitContainer5.Panel1
1479  //
1480  this->splitContainer5->Panel1->Controls->Add(this->splitContainer2);
1481  //
1482  // splitContainer5.Panel2
1483  //
1484  this->splitContainer5->Panel2->Controls->Add(this->panel3);
1485  this->splitContainer5->Panel2->Controls->Add(this->groupBox1);
1486  this->splitContainer5->Size = System::Drawing::Size(1017, 318);
1487  this->splitContainer5->SplitterDistance = 311;
1488  this->splitContainer5->TabIndex = 4;
1489  //
1490  // splitContainer2
1491  //
1492  this->splitContainer2->Dock = System::Windows::Forms::DockStyle::Fill;
1493  this->splitContainer2->Location = System::Drawing::Point(0, 0);
1494  this->splitContainer2->Name = L"splitContainer2";
1495  this->splitContainer2->Orientation = System::Windows::Forms::Orientation::Horizontal;
1496  //
1497  // splitContainer2.Panel1
1498  //
1499  this->splitContainer2->Panel1->Controls->Add(this->gridViewParameter);
1500  this->splitContainer2->Panel1->Controls->Add(this->labelAdjustProcedureParameters);
1501  //
1502  // splitContainer2.Panel2
1503  //
1504  this->splitContainer2->Panel2->Controls->Add(this->splitContainer3);
1505  this->splitContainer2->Size = System::Drawing::Size(311, 318);
1506  this->splitContainer2->SplitterDistance = 95;
1507  this->splitContainer2->TabIndex = 3;
1508  //
1509  // gridViewParameter
1510  //
1511  this->gridViewParameter->AllowUserToAddRows = false;
1512  this->gridViewParameter->AllowUserToDeleteRows = false;
1513  this->gridViewParameter->AllowUserToResizeRows = false;
1514  this->gridViewParameter->BackgroundColor = System::Drawing::SystemColors::Window;
1515  this->gridViewParameter->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
1516  this->gridViewParameter->CellBorderStyle = System::Windows::Forms::DataGridViewCellBorderStyle::None;
1517  this->gridViewParameter->ColumnHeadersBorderStyle = System::Windows::Forms::DataGridViewHeaderBorderStyle::None;
1518  this->gridViewParameter->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
1519  this->gridViewParameter->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^ >(5)
1520  {
1521  this->dataGridViewTextBoxColumnName,
1522  this->dataGridViewTextBoxColumnDirection, this->dataGridViewTextBoxColumnDataType, this->dataGridViewTextBoxColumnValue, this->dataGridViewTextBoxColumnDetails
1523  });
1524  dataGridViewCellStyle1->Alignment = System::Windows::Forms::DataGridViewContentAlignment::MiddleLeft;
1525  dataGridViewCellStyle1->BackColor = System::Drawing::SystemColors::Window;
1526  dataGridViewCellStyle1->Font = (gcnew System::Drawing::Font(L"Consolas", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
1527  static_cast<System::Byte>(0)));
1528  dataGridViewCellStyle1->ForeColor = System::Drawing::SystemColors::ControlText;
1529  dataGridViewCellStyle1->SelectionBackColor = System::Drawing::SystemColors::Highlight;
1530  dataGridViewCellStyle1->SelectionForeColor = System::Drawing::SystemColors::HighlightText;
1531  dataGridViewCellStyle1->WrapMode = System::Windows::Forms::DataGridViewTriState::False;
1532  this->gridViewParameter->DefaultCellStyle = dataGridViewCellStyle1;
1533  this->gridViewParameter->Dock = System::Windows::Forms::DockStyle::Fill;
1534  this->gridViewParameter->Enabled = false;
1535  this->gridViewParameter->EnableHeadersVisualStyles = false;
1536  this->gridViewParameter->Location = System::Drawing::Point(0, 16);
1537  this->gridViewParameter->MultiSelect = false;
1538  this->gridViewParameter->Name = L"gridViewParameter";
1539  this->gridViewParameter->RowHeadersVisible = false;
1540  this->gridViewParameter->RowHeadersWidth = 51;
1541  this->gridViewParameter->SelectionMode = System::Windows::Forms::DataGridViewSelectionMode::FullRowSelect;
1542  this->gridViewParameter->Size = System::Drawing::Size(311, 79);
1543  this->gridViewParameter->StandardTab = true;
1544  this->gridViewParameter->TabIndex = 1;
1545  this->gridViewParameter->CellContentClick += gcnew System::Windows::Forms::DataGridViewCellEventHandler(this, &SampleForm::gridView_CellContentClick);
1546  this->gridViewParameter->CellValidated += gcnew System::Windows::Forms::DataGridViewCellEventHandler(this, &SampleForm::gridViewParameter_CellValidated);
1547  this->gridViewParameter->CellValidating += gcnew System::Windows::Forms::DataGridViewCellValidatingEventHandler(this, &SampleForm::gridViewParameter_CellValidating);
1548  this->gridViewParameter->CellValueChanged += gcnew System::Windows::Forms::DataGridViewCellEventHandler(this, &SampleForm::gridView_CellValueChanged);
1549  //
1550  // dataGridViewTextBoxColumnName
1551  //
1552  this->dataGridViewTextBoxColumnName->AutoSizeMode = System::Windows::Forms::DataGridViewAutoSizeColumnMode::AllCells;
1553  this->dataGridViewTextBoxColumnName->HeaderText = L"Name";
1554  this->dataGridViewTextBoxColumnName->MinimumWidth = 6;
1555  this->dataGridViewTextBoxColumnName->Name = L"dataGridViewTextBoxColumnName";
1556  this->dataGridViewTextBoxColumnName->ReadOnly = true;
1557  this->dataGridViewTextBoxColumnName->Width = 58;
1558  //
1559  // dataGridViewTextBoxColumnDirection
1560  //
1561  this->dataGridViewTextBoxColumnDirection->AutoSizeMode = System::Windows::Forms::DataGridViewAutoSizeColumnMode::AllCells;
1562  this->dataGridViewTextBoxColumnDirection->HeaderText = L"Direction";
1563  this->dataGridViewTextBoxColumnDirection->Name = L"dataGridViewTextBoxColumnDirection";
1564  this->dataGridViewTextBoxColumnDirection->ReadOnly = true;
1565  this->dataGridViewTextBoxColumnDirection->Width = 72;
1566  this->dataGridViewTextBoxColumnDirection->ReadOnly = true;
1567  //
1568  // dataGridViewTextBoxColumnDataType
1569  //
1570  this->dataGridViewTextBoxColumnDataType->AutoSizeMode = System::Windows::Forms::DataGridViewAutoSizeColumnMode::AllCells;
1571  this->dataGridViewTextBoxColumnDataType->HeaderText = L"DataType";
1572  this->dataGridViewTextBoxColumnDataType->MinimumWidth = 6;
1573  this->dataGridViewTextBoxColumnDataType->Name = L"dataGridViewTextBoxColumnDataType";
1574  this->dataGridViewTextBoxColumnDataType->ReadOnly = true;
1575  this->dataGridViewTextBoxColumnDataType->Width = 77;
1576  //
1577  // dataGridViewTextBoxColumnValue
1578  //
1579  this->dataGridViewTextBoxColumnValue->AutoSizeMode = System::Windows::Forms::DataGridViewAutoSizeColumnMode::AllCells;
1580  this->dataGridViewTextBoxColumnValue->HeaderText = L"Value";
1581  this->dataGridViewTextBoxColumnValue->MinimumWidth = 80;
1582  this->dataGridViewTextBoxColumnValue->Name = L"dataGridViewTextBoxColumnValue";
1583  this->dataGridViewTextBoxColumnValue->Width = 80;
1584  //
1585  // dataGridViewTextBoxColumnDetails
1586  //
1587  this->dataGridViewTextBoxColumnDetails->AutoSizeMode = System::Windows::Forms::DataGridViewAutoSizeColumnMode::AllCells;
1588  this->dataGridViewTextBoxColumnDetails->HeaderText = L"Details";
1589  this->dataGridViewTextBoxColumnDetails->Name = L"dataGridViewTextBoxColumnDetails";
1590  this->dataGridViewTextBoxColumnDetails->ReadOnly = true;
1591  this->dataGridViewTextBoxColumnDetails->Width = 62;
1592  //
1593  // labelAdjustProcedureParameters
1594  //
1595  this->labelAdjustProcedureParameters->AutoSize = true;
1596  this->labelAdjustProcedureParameters->Dock = System::Windows::Forms::DockStyle::Top;
1597  this->labelAdjustProcedureParameters->Location = System::Drawing::Point(0, 0);
1598  this->labelAdjustProcedureParameters->Name = L"labelAdjustProcedureParameters";
1599  this->labelAdjustProcedureParameters->Padding = System::Windows::Forms::Padding(0, 0, 0, 3);
1600  this->labelAdjustProcedureParameters->Size = System::Drawing::Size(188, 16);
1601  this->labelAdjustProcedureParameters->TabIndex = 0;
1602  this->labelAdjustProcedureParameters->Tag = L"http://www.emotive.de/DeveloperReference/OtxRuntime/html/94D3A64.htm";
1603  this->labelAdjustProcedureParameters->Text = L"Parameters of the selected Procedure:";
1604  //
1605  // splitContainer3
1606  //
1607  this->splitContainer3->Dock = System::Windows::Forms::DockStyle::Fill;
1608  this->splitContainer3->Location = System::Drawing::Point(0, 0);
1609  this->splitContainer3->Name = L"splitContainer3";
1610  this->splitContainer3->Orientation = System::Windows::Forms::Orientation::Horizontal;
1611  //
1612  // splitContainer3.Panel1
1613  //
1614  this->splitContainer3->Panel1->Controls->Add(this->gridViewContext);
1615  this->splitContainer3->Panel1->Controls->Add(this->label4);
1616  //
1617  // splitContainer3.Panel2
1618  //
1619  this->splitContainer3->Panel2->Controls->Add(this->gridViewState);
1620  this->splitContainer3->Panel2->Controls->Add(this->label5);
1621  this->splitContainer3->Size = System::Drawing::Size(311, 219);
1622  this->splitContainer3->SplitterDistance = 105;
1623  this->splitContainer3->TabIndex = 0;
1624  //
1625  // gridViewContext
1626  //
1627  this->gridViewContext->AllowUserToAddRows = false;
1628  this->gridViewContext->AllowUserToDeleteRows = false;
1629  this->gridViewContext->AllowUserToResizeRows = false;
1630  this->gridViewContext->BackgroundColor = System::Drawing::SystemColors::Window;
1631  this->gridViewContext->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
1632  this->gridViewContext->CellBorderStyle = System::Windows::Forms::DataGridViewCellBorderStyle::None;
1633  this->gridViewContext->ColumnHeadersBorderStyle = System::Windows::Forms::DataGridViewHeaderBorderStyle::None;
1634  this->gridViewContext->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
1635  this->gridViewContext->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^ >(4)
1636  {
1637  this->dataGridViewTextBoxColumnContextName,
1638  this->dataGridViewTextBoxColumnContextDataType, this->dataGridViewTextBoxColumnContextValue, this->dataGridViewTextBoxColumnContextDetails
1639  });
1640  dataGridViewCellStyle2->Alignment = System::Windows::Forms::DataGridViewContentAlignment::MiddleLeft;
1641  dataGridViewCellStyle2->BackColor = System::Drawing::SystemColors::Window;
1642  dataGridViewCellStyle2->Font = (gcnew System::Drawing::Font(L"Consolas", 9));
1643  dataGridViewCellStyle2->ForeColor = System::Drawing::SystemColors::ControlText;
1644  dataGridViewCellStyle2->SelectionBackColor = System::Drawing::SystemColors::Highlight;
1645  dataGridViewCellStyle2->SelectionForeColor = System::Drawing::SystemColors::HighlightText;
1646  dataGridViewCellStyle2->WrapMode = System::Windows::Forms::DataGridViewTriState::False;
1647  this->gridViewContext->DefaultCellStyle = dataGridViewCellStyle2;
1648  this->gridViewContext->Dock = System::Windows::Forms::DockStyle::Fill;
1649  this->gridViewContext->EnableHeadersVisualStyles = false;
1650  this->gridViewContext->Location = System::Drawing::Point(0, 16);
1651  this->gridViewContext->MultiSelect = false;
1652  this->gridViewContext->Name = L"gridViewContext";
1653  this->gridViewContext->RowHeadersVisible = false;
1654  this->gridViewContext->RowHeadersWidth = 51;
1655  this->gridViewContext->SelectionMode = System::Windows::Forms::DataGridViewSelectionMode::FullRowSelect;
1656  this->gridViewContext->Size = System::Drawing::Size(311, 89);
1657  this->gridViewContext->StandardTab = true;
1658  this->gridViewContext->TabIndex = 1;
1659  this->gridViewContext->CellContentClick += gcnew System::Windows::Forms::DataGridViewCellEventHandler(this, &SampleForm::gridView_CellContentClick);
1660  this->gridViewContext->CellValidated += gcnew System::Windows::Forms::DataGridViewCellEventHandler(this, &SampleForm::gridViewContextVariable_CellValidated);
1661  this->gridViewContext->CellValidating += gcnew System::Windows::Forms::DataGridViewCellValidatingEventHandler(this, &SampleForm::gridViewContextVariable_CellValidating);
1662  this->gridViewContext->CellValueChanged += gcnew System::Windows::Forms::DataGridViewCellEventHandler(this, &SampleForm::gridView_CellValueChanged);
1663  //
1664  // dataGridViewTextBoxColumnContextName
1665  //
1666  this->dataGridViewTextBoxColumnContextName->AutoSizeMode = System::Windows::Forms::DataGridViewAutoSizeColumnMode::AllCells;
1667  this->dataGridViewTextBoxColumnContextName->HeaderText = L"Name";
1668  this->dataGridViewTextBoxColumnContextName->MinimumWidth = 6;
1669  this->dataGridViewTextBoxColumnContextName->Name = L"dataGridViewTextBoxColumnContextName";
1670  this->dataGridViewTextBoxColumnContextName->ReadOnly = true;
1671  this->dataGridViewTextBoxColumnContextName->Width = 58;
1672  //
1673  // dataGridViewTextBoxColumnContextDataType
1674  //
1675  this->dataGridViewTextBoxColumnContextDataType->AutoSizeMode = System::Windows::Forms::DataGridViewAutoSizeColumnMode::AllCells;
1676  this->dataGridViewTextBoxColumnContextDataType->HeaderText = L"DataType";
1677  this->dataGridViewTextBoxColumnContextDataType->MinimumWidth = 6;
1678  this->dataGridViewTextBoxColumnContextDataType->Name = L"dataGridViewTextBoxColumnContextDataType";
1679  this->dataGridViewTextBoxColumnContextDataType->ReadOnly = true;
1680  this->dataGridViewTextBoxColumnContextDataType->Width = 77;
1681  //
1682  // dataGridViewTextBoxColumnContextValue
1683  //
1684  this->dataGridViewTextBoxColumnContextValue->AutoSizeMode = System::Windows::Forms::DataGridViewAutoSizeColumnMode::AllCells;
1685  this->dataGridViewTextBoxColumnContextValue->HeaderText = L"Value";
1686  this->dataGridViewTextBoxColumnContextValue->MinimumWidth = 80;
1687  this->dataGridViewTextBoxColumnContextValue->Name = L"dataGridViewTextBoxColumnContextValue";
1688  this->dataGridViewTextBoxColumnContextValue->Width = 80;
1689  //
1690  // dataGridViewTextBoxColumnContextDetails
1691  //
1692  this->dataGridViewTextBoxColumnContextDetails->AutoSizeMode = System::Windows::Forms::DataGridViewAutoSizeColumnMode::AllCells;
1693  this->dataGridViewTextBoxColumnContextDetails->HeaderText = L"Details";
1694  this->dataGridViewTextBoxColumnContextDetails->Name = L"dataGridViewTextBoxColumnContextDetails";
1695  this->dataGridViewTextBoxColumnContextDetails->Width = 62;
1696  //
1697  // label4
1698  //
1699  this->label4->AutoSize = true;
1700  this->label4->Dock = System::Windows::Forms::DockStyle::Top;
1701  this->label4->Location = System::Drawing::Point(0, 0);
1702  this->label4->Name = L"label4";
1703  this->label4->Padding = System::Windows::Forms::Padding(0, 0, 0, 3);
1704  this->label4->Size = System::Drawing::Size(277, 16);
1705  this->label4->TabIndex = 0;
1706  this->label4->Tag = L"http://www.emotive.de/DeveloperReference/OtxRuntime/html/A926ED83.htm";
1707  this->label4->Text = L"Set value for ContextVariables of the selected Document:";
1708  //
1709  // gridViewState
1710  //
1711  this->gridViewState->AllowUserToAddRows = false;
1712  this->gridViewState->AllowUserToDeleteRows = false;
1713  this->gridViewState->AllowUserToResizeRows = false;
1714  this->gridViewState->BackgroundColor = System::Drawing::SystemColors::Window;
1715  this->gridViewState->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
1716  this->gridViewState->CellBorderStyle = System::Windows::Forms::DataGridViewCellBorderStyle::None;
1717  this->gridViewState->ColumnHeadersBorderStyle = System::Windows::Forms::DataGridViewHeaderBorderStyle::None;
1718  this->gridViewState->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
1719  this->gridViewState->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^ >(4)
1720  {
1721  this->dataGridViewTextBoxColumnStateName,
1722  this->dataGridViewTextBoxColumnStateDataType, this->dataGridViewTextBoxColumnStateValue, this->dataGridViewTextBoxColumnStateDetails
1723  });
1724  dataGridViewCellStyle3->Alignment = System::Windows::Forms::DataGridViewContentAlignment::MiddleLeft;
1725  dataGridViewCellStyle3->BackColor = System::Drawing::SystemColors::Window;
1726  dataGridViewCellStyle3->Font = (gcnew System::Drawing::Font(L"Consolas", 9));
1727  dataGridViewCellStyle3->ForeColor = System::Drawing::SystemColors::ControlText;
1728  dataGridViewCellStyle3->SelectionBackColor = System::Drawing::SystemColors::Highlight;
1729  dataGridViewCellStyle3->SelectionForeColor = System::Drawing::SystemColors::HighlightText;
1730  dataGridViewCellStyle3->WrapMode = System::Windows::Forms::DataGridViewTriState::False;
1731  this->gridViewState->DefaultCellStyle = dataGridViewCellStyle3;
1732  this->gridViewState->Dock = System::Windows::Forms::DockStyle::Fill;
1733  this->gridViewState->EnableHeadersVisualStyles = false;
1734  this->gridViewState->Location = System::Drawing::Point(0, 16);
1735  this->gridViewState->MultiSelect = false;
1736  this->gridViewState->Name = L"gridViewState";
1737  this->gridViewState->RowHeadersVisible = false;
1738  this->gridViewState->RowHeadersWidth = 51;
1739  this->gridViewState->Size = System::Drawing::Size(311, 94);
1740  this->gridViewState->StandardTab = true;
1741  this->gridViewState->TabIndex = 1;
1742  //
1743  // dataGridViewTextBoxColumnStateName
1744  //
1745  this->dataGridViewTextBoxColumnStateName->AutoSizeMode = System::Windows::Forms::DataGridViewAutoSizeColumnMode::DisplayedCells;
1746  this->dataGridViewTextBoxColumnStateName->HeaderText = L"Name";
1747  this->dataGridViewTextBoxColumnStateName->MinimumWidth = 6;
1748  this->dataGridViewTextBoxColumnStateName->Name = L"dataGridViewTextBoxColumnStateName";
1749  this->dataGridViewTextBoxColumnStateName->ReadOnly = true;
1750  this->dataGridViewTextBoxColumnStateName->Width = 58;
1751  //
1752  // dataGridViewTextBoxColumnStateDataType
1753  //
1754  this->dataGridViewTextBoxColumnStateDataType->AutoSizeMode = System::Windows::Forms::DataGridViewAutoSizeColumnMode::AllCells;
1755  this->dataGridViewTextBoxColumnStateDataType->HeaderText = L"DataType";
1756  this->dataGridViewTextBoxColumnStateDataType->MinimumWidth = 6;
1757  this->dataGridViewTextBoxColumnStateDataType->Name = L"dataGridViewTextBoxColumnStateDataType";
1758  this->dataGridViewTextBoxColumnStateDataType->ReadOnly = true;
1759  this->dataGridViewTextBoxColumnStateDataType->Width = 77;
1760  //
1761  // dataGridViewTextBoxColumnStateValue
1762  //
1763  this->dataGridViewTextBoxColumnStateValue->AutoSizeMode = System::Windows::Forms::DataGridViewAutoSizeColumnMode::AllCells;
1764  this->dataGridViewTextBoxColumnStateValue->HeaderText = L"Value";
1765  this->dataGridViewTextBoxColumnStateValue->MinimumWidth = 80;
1766  this->dataGridViewTextBoxColumnStateValue->Name = L"dataGridViewTextBoxColumnStateValue";
1767  this->dataGridViewTextBoxColumnStateValue->ReadOnly = true;
1768  this->dataGridViewTextBoxColumnStateValue->Width = 80;
1769  //
1770  // dataGridViewTextBoxColumnStateDetails
1771  //
1772  this->dataGridViewTextBoxColumnStateDetails->AutoSizeMode = System::Windows::Forms::DataGridViewAutoSizeColumnMode::AllCells;
1773  this->dataGridViewTextBoxColumnStateDetails->HeaderText = L"Details";
1774  this->dataGridViewTextBoxColumnStateDetails->Name = L"dataGridViewTextBoxColumnStateDetails";
1775  this->dataGridViewTextBoxColumnStateDetails->ReadOnly = true;
1776  this->dataGridViewTextBoxColumnStateDetails->Width = 62;
1777  //
1778  // label5
1779  //
1780  this->label5->AutoSize = true;
1781  this->label5->Dock = System::Windows::Forms::DockStyle::Top;
1782  this->label5->Location = System::Drawing::Point(0, 0);
1783  this->label5->Name = L"label5";
1784  this->label5->Padding = System::Windows::Forms::Padding(0, 0, 0, 3);
1785  this->label5->Size = System::Drawing::Size(248, 16);
1786  this->label5->TabIndex = 0;
1787  this->label5->Tag = L"http://www.emotive.de/DeveloperReference/OtxRuntime/html/94D3A64.htm";
1788  this->label5->Text = L"Display Status Variables of the selected Document:";
1789  //
1790  // panel3
1791  //
1792  this->panel3->Controls->Add(this->gridViewSettings);
1793  this->panel3->Controls->Add(this->panel4);
1794  this->panel3->Dock = System::Windows::Forms::DockStyle::Fill;
1795  this->panel3->Location = System::Drawing::Point(0, 46);
1796  this->panel3->Name = L"panel3";
1797  this->panel3->Size = System::Drawing::Size(702, 272);
1798  this->panel3->TabIndex = 1;
1799  //
1800  // gridViewSettings
1801  //
1802  this->gridViewSettings->AllowUserToAddRows = false;
1803  this->gridViewSettings->AllowUserToDeleteRows = false;
1804  this->gridViewSettings->AllowUserToResizeRows = false;
1805  this->gridViewSettings->BackgroundColor = System::Drawing::SystemColors::Window;
1806  this->gridViewSettings->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
1807  this->gridViewSettings->CellBorderStyle = System::Windows::Forms::DataGridViewCellBorderStyle::None;
1808  this->gridViewSettings->ColumnHeadersBorderStyle = System::Windows::Forms::DataGridViewHeaderBorderStyle::None;
1809  this->gridViewSettings->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
1810  this->gridViewSettings->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^ >(2)
1811  {
1812  this->dataGridViewTextBoxColumnSettingName,
1813  this->dataGridViewTextBoxColumnSettingValue
1814  });
1815  this->gridViewSettings->Dock = System::Windows::Forms::DockStyle::Fill;
1816  this->gridViewSettings->Location = System::Drawing::Point(0, 28);
1817  this->gridViewSettings->MultiSelect = false;
1818  this->gridViewSettings->Name = L"gridViewSettings";
1819  this->gridViewSettings->RowHeadersVisible = false;
1820  this->gridViewSettings->RowHeadersWidth = 51;
1821  this->gridViewSettings->SelectionMode = System::Windows::Forms::DataGridViewSelectionMode::FullRowSelect;
1822  this->gridViewSettings->Size = System::Drawing::Size(702, 244);
1823  this->gridViewSettings->StandardTab = true;
1824  this->gridViewSettings->TabIndex = 1;
1825  //
1826  // dataGridViewTextBoxColumnSettingName
1827  //
1828  this->dataGridViewTextBoxColumnSettingName->AutoSizeMode = System::Windows::Forms::DataGridViewAutoSizeColumnMode::Fill;
1829  this->dataGridViewTextBoxColumnSettingName->HeaderText = L"Name";
1830  this->dataGridViewTextBoxColumnSettingName->MinimumWidth = 100;
1831  this->dataGridViewTextBoxColumnSettingName->Name = L"dataGridViewTextBoxColumnSettingName";
1832  this->dataGridViewTextBoxColumnSettingName->ReadOnly = true;
1833  //
1834  // dataGridViewTextBoxColumnSettingValue
1835  //
1836  this->dataGridViewTextBoxColumnSettingValue->AutoSizeMode = System::Windows::Forms::DataGridViewAutoSizeColumnMode::Fill;
1837  this->dataGridViewTextBoxColumnSettingValue->HeaderText = L"Value";
1838  this->dataGridViewTextBoxColumnSettingValue->MinimumWidth = 160;
1839  this->dataGridViewTextBoxColumnSettingValue->Name = L"dataGridViewTextBoxColumnSettingValue";
1840  //
1841  // panel4
1842  //
1843  this->panel4->Controls->Add(this->label12);
1844  this->panel4->Controls->Add(this->buttonWriteSettings);
1845  this->panel4->Controls->Add(this->buttonReadSettings);
1846  this->panel4->Dock = System::Windows::Forms::DockStyle::Top;
1847  this->panel4->Location = System::Drawing::Point(0, 0);
1848  this->panel4->Name = L"panel4";
1849  this->panel4->Padding = System::Windows::Forms::Padding(20, 0, 20, 0);
1850  this->panel4->Size = System::Drawing::Size(702, 28);
1851  this->panel4->TabIndex = 0;
1852  //
1853  // label12
1854  //
1855  this->label12->AutoSize = true;
1856  this->label12->Location = System::Drawing::Point(2, 8);
1857  this->label12->Name = L"label12";
1858  this->label12->Padding = System::Windows::Forms::Padding(0, 3, 0, 3);
1859  this->label12->Size = System::Drawing::Size(81, 19);
1860  this->label12->TabIndex = 0;
1861  this->label12->Text = L"Project Settings";
1862  //
1863  // buttonWriteSettings