forked from Azure/iot-edge-v1
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Contains simulator module, metrics module, main application, and sample gateway.json files.
- Loading branch information
Showing
14 changed files
with
932 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#Copyright (c) Microsoft. All rights reserved. | ||
#Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
cmake_minimum_required(VERSION 2.8.12) | ||
|
||
include_directories(./inc) | ||
include_directories(${GW_INC}) | ||
|
||
set(simulator_sources | ||
./src/simulator.cpp | ||
) | ||
|
||
set(simulator_headers | ||
./inc/simulator.h | ||
) | ||
|
||
|
||
#this builds the simulator module | ||
add_library(simulator MODULE ${simulator_sources} ${simulator_headers}) | ||
target_link_libraries(simulator gateway) | ||
|
||
add_library(simulator_static STATIC ${simulator_sources} ${simulator_headers}) | ||
target_compile_definitions(simulator_static PRIVATE BUILD_MODULE_TYPE_STATIC) | ||
target_link_libraries(simulator_static gateway) | ||
|
||
linkSharedUtil(simulator) | ||
linkSharedUtil(simulator_static) | ||
|
||
add_module_to_solution(simulator) | ||
|
||
if(install_modules) | ||
install(TARGETS simulator LIBRARY DESTINATION "${LIB_INSTALL_DIR}/modules") | ||
endif() | ||
|
||
|
||
set(metrics_sources | ||
./src/metrics.cpp | ||
) | ||
|
||
set(metrics_headers | ||
./inc/metrics.h | ||
) | ||
|
||
|
||
#this builds the metrics module | ||
add_library(metrics MODULE ${metrics_sources} ${metrics_headers}) | ||
target_link_libraries(metrics gateway) | ||
|
||
add_library(metrics_static STATIC ${metrics_sources} ${metrics_headers}) | ||
target_compile_definitions(metrics_static PRIVATE BUILD_MODULE_TYPE_STATIC) | ||
target_link_libraries(metrics_static gateway) | ||
|
||
linkSharedUtil(metrics) | ||
linkSharedUtil(metrics_static) | ||
|
||
add_module_to_solution(metrics) | ||
|
||
if(install_modules) | ||
install(TARGETS metrics LIBRARY DESTINATION "${LIB_INSTALL_DIR}/modules") | ||
endif() | ||
|
||
|
||
set(performance_e2e_sources | ||
./src/main.cpp | ||
) | ||
if(WIN32) | ||
set(performance_e2e_sources | ||
${performance_e2e_sources} | ||
./src/performance_win.json | ||
) | ||
set_source_files_properties(./src/performance_win.json PROPERTIES HEADER_FILE_ONLY ON) | ||
else() | ||
set(performance_e2e_sources | ||
${performance_e2e_sources} | ||
./src/performance_lin.json | ||
) | ||
set_source_files_properties(./src/performance_lin.json PROPERTIES HEADER_FILE_ONLY ON) | ||
endif() | ||
|
||
add_executable(performance_e2e ${performance_e2e_sources}) | ||
|
||
add_dependencies(performance_e2e simulator metrics) | ||
|
||
target_link_libraries(performance_e2e gateway nanomsg) | ||
linkSharedUtil(performance_e2e) | ||
install_broker(performance_e2e ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ) | ||
copy_gateway_dll(performance_e2e ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration) ) | ||
|
||
set_target_properties(performance_e2e | ||
PROPERTIES | ||
FOLDER "tests/E2ETests") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
#ifndef METRICS_H | ||
#define METRICS_H | ||
|
||
#include "module.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" | ||
{ | ||
#endif | ||
|
||
MODULE_EXPORT const MODULE_API* MODULE_STATIC_GETAPI(METRICS_MODULE)(MODULE_API_VERSION gateway_api_version); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /*METRICS_H*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
#ifndef SIMULATOR_H | ||
#define SIMULATOR_H | ||
|
||
#include "module.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" | ||
{ | ||
#endif | ||
|
||
typedef struct SIMULATOR_MODULE_CONFIG_TAG | ||
{ | ||
char * device_id; | ||
size_t message_delay; | ||
size_t properties_count; | ||
size_t properties_size; | ||
size_t message_size; | ||
} SIMULATOR_MODULE_CONFIG; | ||
|
||
|
||
MODULE_EXPORT const MODULE_API* MODULE_STATIC_GETAPI(SIMULATOR_MODULE)(MODULE_API_VERSION gateway_api_version); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /*SIMULATOR_H*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
#include <iostream> | ||
#include <string> | ||
|
||
#include "gateway.h" | ||
#include "azure_c_shared_utility/threadapi.h" | ||
#include <nanomsg/nn.h> | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
int sleep_in_ms = 5000; | ||
GATEWAY_HANDLE gateway; | ||
if (argc != 2 && argc != 3) | ||
{ | ||
std::cout | ||
<< "usage: performance_sample configFile [duration]" << std::endl | ||
<< "where configFile is the name of the file that contains the gateway configuration" << std::endl | ||
<< "where duration is the length of time in seconds for the test to run" << std::endl; | ||
} | ||
else | ||
{ | ||
if (argc==3) | ||
{ | ||
sleep_in_ms = std::stoi(argv[2]) * 1000; | ||
} | ||
|
||
if ((gateway = Gateway_CreateFromJson(argv[1])) == NULL) | ||
{ | ||
std::cout << "failed to create the gateway from JSON" << std::endl; | ||
} | ||
else | ||
{ | ||
|
||
std::cout << "gateway successfully created from JSON" << std::endl; | ||
std::cout << "gateway shall run for " << sleep_in_ms/1000 << " seconds" << std::endl; | ||
ThreadAPI_Sleep(sleep_in_ms); | ||
|
||
Gateway_Destroy(gateway); | ||
} | ||
} | ||
return 0; | ||
} |
Oops, something went wrong.