Skip to content

Commit bde46cb

Browse files
committed
adding test for reading values
1 parent 2f05283 commit bde46cb

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

src/dds.net-connector-cpp.app/test-app.cpp

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,20 @@ float test_single_producer(const string& variableName);
2828
double test_double_producer(const string& variableName);
2929
int test_bytes_producer(const std::string& varName, unsigned char* in_buff, int size);
3030

31+
void test_string_consumer(const string& variableName, const string& variableValue);
32+
void test_boolean_consumer(const string& variableName, bool variableValue);
33+
void test_byte_consumer(const string& variableName, char variableValue);
34+
void test_word_consumer(const string& variableName, short variableValue);
35+
void test_dword_consumer(const string& variableName, long variableValue);
36+
void test_qword_consumer(const string& variableName, long long variableValue);
37+
void test_unsigned_byte_consumer(const string& variableName, unsigned char variableValue);
38+
void test_unsigned_word_consumer(const string& variableName, unsigned short variableValue);
39+
void test_unsigned_dword_consumer(const string& variableName, unsigned long variableValue);
40+
void test_unsigned_qword_consumer(const string& variableName, unsigned long long variableValue);
41+
void test_single_consumer(const string& variableName, float variableValue);
42+
void test_double_consumer(const string& variableName, double variableValue);
43+
void test_bytes_consumer(const string& variableName, unsigned char* buffer, int dataSize);
44+
3145

3246
int main()
3347
{
@@ -62,6 +76,20 @@ int main()
6276
connector.registerSingleProvider("Test-Single", test_single_producer, LOWEST);
6377
connector.registerDoubleProvider("Test-Double", test_double_producer, LOWEST);
6478
connector.registerRawBytesProvider("Test-Bytes", test_bytes_producer, LOWEST);
79+
connector.registerStringConsumer("Test-String", test_string_consumer, ON_CHANGE);
80+
connector.registerBooleanConsumer("Test-Boolean", test_boolean_consumer, ON_CHANGE);
81+
connector.registerByteConsumer("Test-Byte", test_byte_consumer, ON_CHANGE);
82+
connector.registerWordConsumer("Test-Word", test_word_consumer, ON_CHANGE);
83+
connector.registerDWordConsumer("Test-DWord", test_dword_consumer, ON_CHANGE);
84+
connector.registerQWordConsumer("Test-QWord", test_qword_consumer, ON_CHANGE);
85+
connector.registerUnsignedByteConsumer("Test-UnsignedByte", test_unsigned_byte_consumer, ON_CHANGE);
86+
connector.registerUnsignedWordConsumer("Test-UnsignedWord", test_unsigned_word_consumer, ON_CHANGE);
87+
connector.registerUnsignedDWordConsumer("Test-UnsignedDWord", test_unsigned_dword_consumer, ON_CHANGE);
88+
connector.registerUnsignedQWordConsumer("Test-UnsignedQWord", test_unsigned_qword_consumer, ON_CHANGE);
89+
connector.registerSingleConsumer("Test-Single", test_single_consumer, ON_CHANGE);
90+
connector.registerDoubleConsumer("Test-Double", test_double_consumer, ON_CHANGE);
91+
connector.registerRawBytesConsumer("Test-Bytes", test_bytes_consumer, ON_CHANGE);
92+
6593

6694
connector.start();
6795

@@ -105,6 +133,7 @@ void circle_values_consumer(const string& variableName, double variableValue)
105133

106134

107135

136+
108137
bool test_boolean = false;
109138
double test_value_signed = -100.555;
110139
unsigned long long test_value_unsigned = 0;
@@ -184,3 +213,63 @@ int test_bytes_producer(const std::string& varName, unsigned char* in_buff, int
184213

185214

186215

216+
217+
void test_string_consumer(const string& variableName, const string& variableValue)
218+
{
219+
cout << "Str: " << variableValue << endl;
220+
}
221+
void test_boolean_consumer(const string& variableName, bool variableValue)
222+
{
223+
cout << "Bool: " << variableValue << endl;
224+
}
225+
void test_byte_consumer(const string& variableName, char variableValue)
226+
{
227+
cout << "Byte: " << (int)variableValue << endl;
228+
}
229+
void test_word_consumer(const string& variableName, short variableValue)
230+
{
231+
cout << "Word: " << (int)variableValue << endl;
232+
}
233+
void test_dword_consumer(const string& variableName, long variableValue)
234+
{
235+
cout << "DWord: " << variableValue << endl;
236+
}
237+
void test_qword_consumer(const string& variableName, long long variableValue)
238+
{
239+
cout << "QWord: " << variableValue << endl;
240+
}
241+
void test_unsigned_byte_consumer(const string& variableName, unsigned char variableValue)
242+
{
243+
cout << "Unsigned Byte: " << (unsigned int)variableValue << endl;
244+
}
245+
void test_unsigned_word_consumer(const string& variableName, unsigned short variableValue)
246+
{
247+
cout << "Unsigned Word: " << variableValue << endl;
248+
}
249+
void test_unsigned_dword_consumer(const string& variableName, unsigned long variableValue)
250+
{
251+
cout << "Unsigned DWord: " << variableValue << endl;
252+
}
253+
void test_unsigned_qword_consumer(const string& variableName, unsigned long long variableValue)
254+
{
255+
cout << "Unsigned QWord: " << variableValue << endl;
256+
}
257+
void test_single_consumer(const string& variableName, float variableValue)
258+
{
259+
cout << "Single: " << variableValue << endl;
260+
}
261+
void test_double_consumer(const string& variableName, double variableValue)
262+
{
263+
cout << "Double: " << variableValue << endl;
264+
}
265+
void test_bytes_consumer(const string& variableName, unsigned char* buffer, int dataSize)
266+
{
267+
cout << "Raw Bytes: ";
268+
269+
for (size_t i = 0; i < dataSize; i++)
270+
{
271+
cout << (int)buffer[i] << " ";
272+
}
273+
274+
cout << endl;
275+
}

0 commit comments

Comments
 (0)