| Visioscan Set SDK Libraries 1.3.5 Visioscan Set SDK Help documentation file for C++ and C++/CLI |

Loading...
Searching...
No Matches
WBaseCommunication.h
1#pragma once
2#pragma make_public(BaseCommunication)
3
4#include "WBaseSettings.h"
5#include "BaseCommunication.h"
6#include "WCommunicationStatus.h"
7
8 using namespace System::Threading;
9 using namespace System;
10 using namespace System::Runtime::InteropServices;
11
12 public delegate void ManagedDelegate(CommunicationStatus*);
13
14 public delegate void CommunicationEventHandler(System::Object^ sender, WUtils::WCommunicationStatus^ e);
15
16 namespace WBase {
17
18 public ref class WBaseCommunication abstract
19 {
20 public:
21
22 WBaseCommunication() {
23 }
24
25 ~WBaseCommunication() {
26 }
27
32 virtual WUtils::WCommunicationStatus^ Connect() = 0;
33
37 virtual void Disconnect() = 0;
38
43 bool IsConnected() {
44 return _communication->IsConnected();
45 }
46
47 // Properties
48 property WBaseSettings^ Settings {
49 WBaseSettings^ get() {
50 return _settings;
51 }
52
53 void set(WBaseSettings^ pSettings) {
54 _settings = pSettings;
55 }
56 }
57
58 property BaseCommunication* __nativeCommunication {
59 BaseCommunication* get() {
60 return _communication;
61 }
62 }
63
64 event CommunicationEventHandler^ CommunicationEvent {
65 void add(CommunicationEventHandler^ handler) {
66 if (!_callbackAssigned) {
67 IntPtr ptr = this->GetFunctionPointer();
68 MarshallingConnectionCheckerCallback nativeFunc = reinterpret_cast<MarshallingConnectionCheckerCallback>(ptr.ToPointer());
69 _communication->SetCommunicationCallback(nativeFunc);
70 _callbackAssigned = true;
71 }
72
73 _communicationEvent += handler;
74 }
75 void remove(CommunicationEventHandler^ handler) {
76 _communicationEvent -= handler;
77 }
78 }
79
80 protected:
81 ManagedDelegate^ del = gcnew ManagedDelegate(this, &WBaseCommunication::CommunicationCallback);
82 IntPtr GetFunctionPointer() {
83 return Marshal::GetFunctionPointerForDelegate(del);
84 }
85
86 void CommunicationCallback(CommunicationStatus* status) {
87 WUtils::WCommunicationStatus^ eventDataToFire = gcnew WUtils::WCommunicationStatus();
88 for (int i = 0; i < status->Channels.size(); i++) {
89 WUtils::WChannel^ toAdd = gcnew WUtils::WChannel();
90 toAdd->RawDataAvailability = static_cast<DataAvailabilityEnum>(status->Channels[i].RawDataAvailability);
91 toAdd->Type = static_cast<ChannelTypeEnum>(status->Channels[i].Type);
92
93 eventDataToFire->Channels->Add(toAdd);
94 }
95
96 eventDataToFire->ErrorCode = gcnew WUtils::WCommunicationErrorCode();
97 eventDataToFire->ErrorCode->ErrorCode = status->ErrorCode.ErrorCode;
98 eventDataToFire->ErrorCode->ErrorMeaning = gcnew String(status->ErrorCode.ErrorMeaning.c_str());
99
100 eventDataToFire->Status = static_cast<ConnectionStatusEnum>(status->Status);
101
102 _communicationEvent(this, eventDataToFire);
103 }
104
105 BaseCommunication* _communication;
106 bool _monitoringExit = false;
107
108 private:
109 bool _callbackAssigned = false;
110 event CommunicationEventHandler^ _communicationEvent;
111 WBaseSettings^ _settings;
112 Thread^ _monitoringWorker;
113 };
114}
WBase
Definition WBaseCommunication.h:16
WEnumerations::DataAvailabilityEnum
DataAvailabilityEnum
Definition WEnums.h:28
WEnumerations::ChannelTypeEnum
ChannelTypeEnum
Definition WEnums.h:27
WEnumerations::ConnectionStatusEnum
ConnectionStatusEnum
Definition WEnums.h:26
CommErrorCode::ErrorMeaning
std::string ErrorMeaning
Definition CommunicationStructures.h:16
CommErrorCode::ErrorCode
int ErrorCode
Definition CommunicationStructures.h:15
CommunicationStatus
Definition CommunicationStructures.h:24
CommunicationStatus::Status
ConnectionState Status
Definition CommunicationStructures.h:26
CommunicationStatus::Channels
vector< Channel > Channels
Definition CommunicationStructures.h:25
CommunicationStatus::ErrorCode
CommErrorCode ErrorCode
Definition CommunicationStructures.h:27
WBase::abstract::IsConnected
bool IsConnected()
Indicates, based on the 'GetConnectionState' method, if the device is connected or not.
Definition WBaseCommunication.h:43
WBase::abstract::WBaseCommunication
WBaseCommunication()
Definition WBaseCommunication.h:22
WBase::abstract::GetFunctionPointer
IntPtr GetFunctionPointer()
Definition WBaseCommunication.h:82
WBase::abstract::Connect
virtual WUtils::WCommunicationStatus Connect()=0
Pure virtual method that will help the caller to proceed to the connection to media.
WBase::abstract::Disconnect
virtual void Disconnect()=0
Pure virtual method that will help the caller to proceed to media disconection.
WBase::abstract::CommunicationCallback
void CommunicationCallback(CommunicationStatus *status)
Definition WBaseCommunication.h:86
WBase::abstract::~WBaseCommunication
~WBaseCommunication()
Definition WBaseCommunication.h:25
WBase::abstract::_communication
BaseCommunication * _communication
Definition WBaseCommunication.h:105
WUtils::WChannel
Definition WChannel.h:12
WUtils::WChannel::Type
property ChannelTypeEnum Type
Definition WChannel.h:22
WUtils::WCommunicationErrorCode
Definition WCommunicationErrorCode.h:6
WUtils::WCommunicationStatus
Definition WCommunicationStatus.h:16
WUtils::WCommunicationStatus::Channels
property List< WChannel^> Channels
Definition WCommunicationStatus.h:24