verion which did not include the handling in RTService wth creating the
Json file
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
/vrpmdvdata.cpython-310.pyc
|
||||
/vrpmdvmonitoring.cpython-310.pyc
|
||||
/vrpmdvmonitoringschema.cpython-310.pyc
|
||||
/vrpmdvmonreq.cpython-310.pyc
|
||||
/vrpmdvmonreqschema.cpython-310.pyc
|
||||
/vrpmdvmonitoringState.cpython-310.pyc
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
|
After Width: | Height: | Size: 99 KiB |
@@ -0,0 +1,42 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Markus Lehr | VR Predictive Maintenance Device."
|
||||
/>
|
||||
<meta
|
||||
data-rh="true"
|
||||
property="og:image"
|
||||
content="https://refine.dev/img/refine_social.png"
|
||||
/>
|
||||
<meta
|
||||
data-rh="true"
|
||||
name="twitter:image"
|
||||
content="https://refine.dev/img/refine_social.png"
|
||||
/>
|
||||
<title>
|
||||
Markus Lehr | VR Predictive Maintenance Device.
|
||||
</title>
|
||||
<script type="module" crossorigin src="/assets/index-40b528e3.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
|
||||
<!--
|
||||
This HTML file is a template.
|
||||
If you open it directly in the browser, you will see an empty page.
|
||||
|
||||
You can add webfonts, meta tags, or analytics to this file.
|
||||
The build step will place the bundled scripts into the <body> tag.
|
||||
|
||||
To begin the development, run `npm dev` or `yarn start`.
|
||||
To create a production bundle, use `npm run build` or `yarn build`.
|
||||
-->
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
@@ -0,0 +1,77 @@
|
||||
# ========================= eCAL LICENSE =================================
|
||||
#
|
||||
# Copyright (C) 2016 - 2019 Continental Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# ========================= eCAL LICENSE =================================
|
||||
|
||||
project(core_pb)
|
||||
|
||||
find_package(Protobuf REQUIRED)
|
||||
|
||||
set(ProtoFiles
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/ecal/core/pb/ecal.proto
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/ecal/core/pb/host.proto
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/ecal/core/pb/layer.proto
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/ecal/core/pb/monitoring.proto
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/ecal/core/pb/process.proto
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/ecal/core/pb/service.proto
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/ecal/core/pb/topic.proto
|
||||
)
|
||||
|
||||
# Compile statically on Windows and shared for all other systems.
|
||||
#
|
||||
# We compile shared on Linux etc., as we must only load the proto descriptors
|
||||
# once; otherwise, protobuf would throw an exception on runtime. A shared object
|
||||
# achieves that, as it is only loaded into memory once, even when being linked
|
||||
# against from different libraries.
|
||||
# We don't have to do that on Windows, as we compile against protobuf statically
|
||||
# and therefore each .dll has it's own descriptor pool. Having a static lib here
|
||||
# also has the advantage that we need to export the symbols, which is default
|
||||
# disabled on Windows.
|
||||
#
|
||||
# TODO: Having code like that probably isn't the best solution ever. We should
|
||||
# maybe always link against protobuf statically. Currently the reason why we
|
||||
# don't do that is, that the default Ubuntu libprotobuf.a doesn't contain
|
||||
# position independent code and can therefore not be statically compiled into a
|
||||
# shared object library.
|
||||
if (WIN32)
|
||||
ecal_add_static_library(${PROJECT_NAME} src/core_pb.cpp)
|
||||
else()
|
||||
ecal_add_shared_library(${PROJECT_NAME} src/core_pb.cpp)
|
||||
endif()
|
||||
|
||||
add_library(eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
|
||||
|
||||
protobuf_target_cpp(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src INSTALL_FOLDER include ${ProtoFiles})
|
||||
|
||||
target_compile_options(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
$<$<CXX_COMPILER_ID:MSVC>:/wd4505 /wd4592 /wd4189>
|
||||
$<$<CXX_COMPILER_ID:GNU>:-Wno-unused-parameter>)
|
||||
|
||||
set_property(TARGET ${PROJECT_NAME} PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} protobuf::libprotobuf)
|
||||
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_14)
|
||||
|
||||
ecal_install_library(${PROJECT_NAME})
|
||||
|
||||
if(BUILD_PY_BINDING)
|
||||
protobuf_generate_python_ext(python_sources ${PYTHON_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src ${ProtoFiles})
|
||||
target_sources(${PROJECT_NAME} PRIVATE ${python_sources})
|
||||
set_source_files_properties(${python_sources} PROPERTIES HEADER_FILE_ONLY TRUE)
|
||||
endif()
|
||||
|
||||
set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER ecal/core_pb)
|
||||
@@ -0,0 +1 @@
|
||||
// dummy file to force VS to create a library
|
||||
@@ -0,0 +1,71 @@
|
||||
/* ========================= eCAL LICENSE =================================
|
||||
*
|
||||
* Copyright (C) 2016 - 2019 Continental Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ========================= eCAL LICENSE =================================
|
||||
*/
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
import "ecal/core/pb/host.proto";
|
||||
import "ecal/core/pb/process.proto";
|
||||
import "ecal/core/pb/service.proto";
|
||||
import "ecal/core/pb/topic.proto";
|
||||
|
||||
package eCAL.pb;
|
||||
|
||||
message Content // topic content
|
||||
{
|
||||
int64 id = 1; // sample id
|
||||
int64 clock = 2; // internal used clock
|
||||
int64 time = 3; // time the content was updated
|
||||
bytes payload = 4; // octet stream
|
||||
int32 size = 6; // size (redundant for compatibility)
|
||||
int64 hash = 7; // unique hash for that sample
|
||||
}
|
||||
|
||||
enum eCmdType // command type
|
||||
{
|
||||
bct_none = 0; // undefined command
|
||||
bct_set_sample = 1; // set sample content
|
||||
bct_reg_publisher = 2; // register publisher
|
||||
bct_reg_subscriber = 3; // register subscriber
|
||||
bct_reg_process = 4; // register process
|
||||
bct_reg_service = 5; // register service
|
||||
bct_reg_client = 6; // register client
|
||||
|
||||
bct_unreg_publisher = 12; // unregister publisher
|
||||
bct_unreg_subscriber = 13; // unregister subscriber
|
||||
bct_unreg_process = 14; // unregister process
|
||||
bct_unreg_service = 15; // unregister service
|
||||
bct_unreg_client = 16; // unregister client
|
||||
}
|
||||
|
||||
message Sample // a sample is a topic, it's descriptions and it's content
|
||||
{
|
||||
eCmdType cmd_type = 1; // sample command type
|
||||
Host host = 2; // host information
|
||||
Process process = 3; // process information
|
||||
Service service = 4; // service information
|
||||
Client client = 7; // client information
|
||||
Topic topic = 5; // topic information
|
||||
Content content = 6; // topic content
|
||||
bytes padding = 8; // padding to artificially increase the size of the message. This is a workaround for TCP topics, to get the actual user-payload 8-byte-aligned. REMOVE ME IN ECAL6
|
||||
}
|
||||
|
||||
message SampleList
|
||||
{
|
||||
repeated Sample samples = 1;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/* ========================= eCAL LICENSE =================================
|
||||
*
|
||||
* Copyright (C) 2016 - 2019 Continental Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ========================= eCAL LICENSE =================================
|
||||
*/
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package eCAL.pb;
|
||||
|
||||
message OSInfo // operating system details
|
||||
{
|
||||
string osname = 1; // name
|
||||
}
|
||||
|
||||
message Host // eCAL host
|
||||
{
|
||||
string hname = 1; // host name
|
||||
OSInfo os = 2; // operating system details
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/* ========================= eCAL LICENSE =================================
|
||||
*
|
||||
* Copyright (C) 2016 - 2019 Continental Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ========================= eCAL LICENSE =================================
|
||||
*/
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package eCAL.pb;
|
||||
|
||||
message LayerParUdpMC
|
||||
{
|
||||
}
|
||||
|
||||
message LayerParShm
|
||||
{
|
||||
repeated string memory_file_list = 1; // list of memory file names
|
||||
}
|
||||
|
||||
message LayerParInproc
|
||||
{
|
||||
}
|
||||
|
||||
message LayerParTcp
|
||||
{
|
||||
int32 port = 1; // tcp writers port number
|
||||
}
|
||||
|
||||
message ConnnectionPar // connection parameter for reader / writer
|
||||
{
|
||||
LayerParUdpMC layer_par_udpmc = 1; // parameter for ecal udp multicast
|
||||
LayerParShm layer_par_shm = 2; // parameter for ecal shared memory
|
||||
LayerParInproc layer_par_inproc = 3; // parameter for ecal inner process
|
||||
LayerParTcp layer_par_tcp = 4; // parameter for ecal tcp
|
||||
}
|
||||
|
||||
enum eTLayerType // transport layer
|
||||
{
|
||||
tl_none = 0; // undefined
|
||||
tl_ecal_udp_mc = 1; // ecal udp multicast
|
||||
// 2 = ecal udp unicast (not supported anymore)
|
||||
// 3 = ecal udp metal (not supported anymore)
|
||||
tl_ecal_shm = 4; // ecal shared memory
|
||||
tl_ecal_tcp = 5; // ecal tcp
|
||||
tl_inproc = 42; // inproc (inner process)
|
||||
tl_all = 255; // all layer
|
||||
}
|
||||
|
||||
message TLayer
|
||||
{
|
||||
eTLayerType type = 1; // transport layer type
|
||||
int32 version = 2; // transport layer version
|
||||
bool confirmed = 3; // transport layer used ?
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// REMOVE ME IN ECAL6
|
||||
// ----------------------------------------------------------------------
|
||||
bytes par_shm = 4; // transport layer parameter (shm only, deprecated)
|
||||
// ----------------------------------------------------------------------
|
||||
// REMOVE ME IN ECAL6
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
ConnnectionPar par_layer = 5; // transport layer parameter
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/* ========================= eCAL LICENSE =================================
|
||||
*
|
||||
* Copyright (C) 2016 - 2019 Continental Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ========================= eCAL LICENSE =================================
|
||||
*/
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
import "ecal/core/pb/host.proto";
|
||||
import "ecal/core/pb/process.proto";
|
||||
import "ecal/core/pb/service.proto";
|
||||
import "ecal/core/pb/topic.proto";
|
||||
|
||||
package eCAL.pb;
|
||||
|
||||
message LogMessage // eCAL monitoring log message
|
||||
{
|
||||
int64 time = 1; // time
|
||||
string hname = 2; // host name
|
||||
int32 pid = 3; // process id
|
||||
string pname = 4; // process name
|
||||
string uname = 5; // unit name
|
||||
int32 level = 6; // message level
|
||||
string content = 7; // message content
|
||||
}
|
||||
|
||||
message Monitoring // eCAL monitoring information
|
||||
{
|
||||
repeated Host hosts = 1; // hosts
|
||||
repeated Process processes = 2; // processes
|
||||
repeated Service services = 3; // services
|
||||
repeated Client clients = 5; // clients
|
||||
repeated Topic topics = 4; // topics
|
||||
}
|
||||
|
||||
message Logging // eCAL logging information
|
||||
{
|
||||
repeated LogMessage logs = 1; // log messages
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/* ========================= eCAL LICENSE =================================
|
||||
*
|
||||
* Copyright (C) 2016 - 2019 Continental Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ========================= eCAL LICENSE =================================
|
||||
*/
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package eCAL.pb;
|
||||
|
||||
enum eProcessSeverity // process severity
|
||||
{
|
||||
proc_sev_unknown = 0; // condition unknown
|
||||
proc_sev_healthy = 1; // process healthy
|
||||
proc_sev_warning = 2; // process warning level
|
||||
proc_sev_critical = 3; // process critical
|
||||
proc_sev_failed = 4; // process failed
|
||||
}
|
||||
|
||||
enum eProcessSeverityLevel // process severity level
|
||||
{
|
||||
proc_sev_level_unknown = 0; // condition unknown
|
||||
proc_sev_level1 = 1; // default severity level 1
|
||||
proc_sev_level2 = 2; // severity level 2
|
||||
proc_sev_level3 = 3; // severity level 3
|
||||
proc_sev_level4 = 4; // severity level 4
|
||||
proc_sev_level5 = 5; // severity level 5
|
||||
}
|
||||
|
||||
message ProcessState // process state
|
||||
{
|
||||
eProcessSeverity severity = 1; // severity
|
||||
eProcessSeverityLevel severity_level = 3; // severity level
|
||||
string info = 2; // info string
|
||||
}
|
||||
|
||||
enum eTSyncState // time synchronisation
|
||||
{
|
||||
tsync_none = 0; // not synchronized
|
||||
tsync_realtime = 1; // real time sync mode
|
||||
tsync_replay = 2; // replay time sync mode
|
||||
}
|
||||
|
||||
message Process // process
|
||||
{
|
||||
int32 rclock = 1; // registration clock
|
||||
string hname = 2; // host name
|
||||
string hgname = 18; // host group name
|
||||
int32 pid = 3; // process id
|
||||
string pname = 4; // process name
|
||||
string uname = 5; // unit name
|
||||
string pparam = 6; // process parameter
|
||||
int64 pmemory = 7; // process memory
|
||||
float pcpu = 8; // process cpu usage
|
||||
float usrptime = 9; // process user time
|
||||
int64 datawrite = 10; // data write bytes per sec
|
||||
int64 dataread = 11; // data read bytes per sec
|
||||
ProcessState state = 12; // process state info
|
||||
eTSyncState tsync_state = 13; // time synchronization state
|
||||
string tsync_mod_name = 14; // time synchronization module name
|
||||
int32 component_init_state = 15; // eCAL component initialization state (eCAL::Initialize(..))
|
||||
string component_init_info = 16; // like comp_init_state as human readable string (pub|sub|srv|mon|log|time|proc)
|
||||
string ecal_runtime_version = 17; // loaded / runtime eCAL version of a component
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/* ========================= eCAL LICENSE =================================
|
||||
*
|
||||
* Copyright (C) 2016 - 2019 Continental Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ========================= eCAL LICENSE =================================
|
||||
*/
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package eCAL.pb;
|
||||
|
||||
message ServiceHeader
|
||||
{
|
||||
enum eCallState
|
||||
{
|
||||
none = 0;
|
||||
executed = 1;
|
||||
failed = 2;
|
||||
}
|
||||
|
||||
string hname = 1; // host name
|
||||
string sname = 2; // service name
|
||||
string sid = 7; // service id
|
||||
string mname = 3; // method name
|
||||
string error = 4; // error message
|
||||
int32 id = 5; // session id
|
||||
eCallState state = 6; // method call state
|
||||
}
|
||||
|
||||
message Request // client request
|
||||
{
|
||||
ServiceHeader header = 1; // common service header
|
||||
bytes request = 2; // request payload
|
||||
}
|
||||
|
||||
message Response // server response
|
||||
{
|
||||
ServiceHeader header = 1; // common service header
|
||||
bytes response = 2; // response payload
|
||||
int64 ret_state = 3; // callback return state
|
||||
}
|
||||
|
||||
message Method // method
|
||||
{
|
||||
string mname = 1; // method name
|
||||
string req_type = 2; // request type
|
||||
bytes req_desc = 5; // request descriptor
|
||||
string resp_type = 3; // response type
|
||||
bytes resp_desc = 6; // response descriptor
|
||||
int64 call_count = 4; // call counter
|
||||
}
|
||||
|
||||
message Service // service
|
||||
{
|
||||
int32 rclock = 1; // registration clock
|
||||
string hname = 2; // host name
|
||||
string pname = 3; // process name
|
||||
string uname = 4; // unit name
|
||||
int32 pid = 5; // process id
|
||||
string sname = 6; // service name
|
||||
string sid = 9; // service id
|
||||
repeated Method methods = 8; // list of methods
|
||||
|
||||
// transport specific parameter (for internal use)
|
||||
uint32 version = 10; // service protocol version
|
||||
uint32 tcp_port_v0 = 7; // the tcp port used for that service
|
||||
uint32 tcp_port_v1 = 11; // the tcp port used for that service
|
||||
}
|
||||
|
||||
message Client // client
|
||||
{
|
||||
int32 rclock = 1; // registration clock
|
||||
string hname = 2; // host name
|
||||
string pname = 3; // process name
|
||||
string uname = 4; // unit name
|
||||
int32 pid = 5; // process id
|
||||
string sname = 6; // service name
|
||||
string sid = 7; // service id
|
||||
|
||||
// transport specific parameter (for internal use)
|
||||
uint32 version = 8; // client protocol version
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/* ========================= eCAL LICENSE =================================
|
||||
*
|
||||
* Copyright (C) 2016 - 2019 Continental Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ========================= eCAL LICENSE =================================
|
||||
*/
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
import "ecal/core/pb/layer.proto";
|
||||
|
||||
package eCAL.pb;
|
||||
|
||||
message QOS // quality of service
|
||||
{
|
||||
enum eQOSPolicy_Reliability
|
||||
{
|
||||
best_effort_reliability_qos = 0; // best effort reliability (default for Subscribers)
|
||||
reliable_reliability_qos = 1; // reliable reliability (default for Publishers)
|
||||
}
|
||||
|
||||
enum eQOSPolicy_HistoryKind
|
||||
{
|
||||
keep_last_history_qos = 0; // keep only a number of samples, default value
|
||||
keep_all_history_qos = 1; // keep all samples until the ResourceLimitsQosPolicy are exhausted
|
||||
}
|
||||
|
||||
eQOSPolicy_Reliability reliability = 1; // qos reliability (reliable / best effort)
|
||||
eQOSPolicy_HistoryKind history = 2; // qos history kind (keep last / all)
|
||||
int32 history_depth = 3; // number of samples for history kind "keep last"
|
||||
}
|
||||
|
||||
message DataTypeInformation
|
||||
{
|
||||
string name = 1; // name of the datatype
|
||||
string encoding = 2; // encoding of the datatype (e.g. protobuf, flatbuffers, capnproto)
|
||||
bytes desc = 3; // descriptor information of the datatype (necessary for reflection)
|
||||
}
|
||||
|
||||
message Topic // eCAL topic
|
||||
{
|
||||
int32 rclock = 1; // registration clock (heart beat)
|
||||
int32 hid = 26; // host id
|
||||
string hname = 2; // host name
|
||||
string hgname = 28; // host group name
|
||||
int32 pid = 3; // process id
|
||||
string pname = 4; // process name
|
||||
string uname = 5; // unit name
|
||||
string tid = 6; // topic id
|
||||
string tname = 7; // topic name
|
||||
string direction = 8; // direction (publisher, subscriber)
|
||||
string ttype = 9; // topic type + topic encoding (deprecated)
|
||||
bytes tdesc = 10; // topic description (protocol descriptor) (deprecated)
|
||||
|
||||
DataTypeInformation tdatatype = 30; // topic datatype information (encoding & type & description)
|
||||
|
||||
QOS tqos = 11; // topic quality of service
|
||||
repeated TLayer tlayer = 12; // active topic transport layers and it's specific parameter
|
||||
int32 tsize = 13; // topic size
|
||||
|
||||
int32 connections_loc = 16; // number of local connected entities
|
||||
int32 connections_ext = 17; // number of external connected entities
|
||||
int32 message_drops = 18; // dropped messages
|
||||
|
||||
int64 did = 19; // data send id (publisher setid)
|
||||
int64 dclock = 20; // data clock (send / receive action)
|
||||
int32 dfreq = 21; // data frequency (send / receive samples per second) [mHz]
|
||||
|
||||
map<string, string> attr = 27; // generic topic description
|
||||
}
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
[{"id": "7c7a3fd8-0951-491c-bcf2-dc917058f60e", "created_at": "03/31/2024, 13:39", "name": "MM56", "samplerate": 3000, "sampleperiod": 2, "downtime": 7, "owner": "ML1", "status": "off"}, {"id": "4c17fd91-e273-4c1b-8561-5d2506c0f8b0", "created_at": "03/31/2024, 13:39", "name": "MM2", "samplerate": 7000, "sampleperiod": 1, "downtime": 5, "owner": "ML1", "status": "off"}, {"id": "13277d6a-4654-4448-8162-c057e8e03eac", "created_at": "03/31/2024, 13:48", "name": "MM1", "samplerate": 10000, "sampleperiod": 1, "downtime": 0, "owner": "ML1", "status": "stopped"}, {"id": "a412c952-cff7-4a4d-a064-214f4edbaac8", "created_at": "03/31/2024, 13:48", "name": "MM30", "samplerate": 3000, "sampleperiod": 2, "downtime": 30, "owner": "ML3", "status": "started"}, {"id": "a0d2fe83-f507-41c6-a833-283cf3ad69cf", "created_at": "03/31/2024, 13:48", "name": "MM37", "samplerate": 3000, "sampleperiod": 2, "downtime": 4, "owner": "ML35", "status": "started"}]
|
||||
[{"no": 0, "id": "cb842c0d-51fc-433f-baf4-0f45af0fc0c5", "created_at": "06/14/2024, 16:30", "name": "MM1", "samplerate": 500, "sampleperiod": 1, "downtime": 10, "owner": "ML", "status": "stopped"}]
|
||||
@@ -0,0 +1,74 @@
|
||||
/* ========================= LICENSE =================================
|
||||
*
|
||||
* Copyright (C) 2024 Markus Lehr
|
||||
*
|
||||
+ closed License property of Markus Lehr
|
||||
*
|
||||
* ========================= LICENSE =================================
|
||||
*/
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
option py_generic_services = true;
|
||||
|
||||
package proto_messages;
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
// RT Service
|
||||
///////////////////////////////////////////////////////
|
||||
message SCreateIn
|
||||
{
|
||||
string name = 1;
|
||||
string id = 2;
|
||||
int64 samplerate = 3;
|
||||
int64 sampleperiod = 4;
|
||||
int64 downtime = 5;
|
||||
string status = 6;
|
||||
}
|
||||
|
||||
message SDeleteIn
|
||||
{
|
||||
string id = 1;
|
||||
}
|
||||
|
||||
message SMonStateIn
|
||||
{
|
||||
string id = 1;
|
||||
}
|
||||
|
||||
message SMonStatesIn
|
||||
{
|
||||
string query = 1;
|
||||
}
|
||||
|
||||
|
||||
message SSetMonStateIn
|
||||
{
|
||||
string id = 1;
|
||||
string status = 2;
|
||||
}
|
||||
|
||||
|
||||
message SResult
|
||||
{
|
||||
bool result = 1;
|
||||
|
||||
}
|
||||
|
||||
message SStateResult
|
||||
{
|
||||
repeated string result = 1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
service RTService
|
||||
{
|
||||
rpc CreateMonitoring(SCreateIn) returns (SResult);
|
||||
rpc DeleteMonitoring (SDeleteIn) returns (SResult);
|
||||
rpc GetMonitoringState (SMonStateIn) returns (SResult);
|
||||
rpc GetMonitoringStates (SMonStatesIn) returns (SStateResult);
|
||||
rpc SetMonitoringState (SSetMonStateIn) returns (SResult);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: RTService.proto
|
||||
# Protobuf Python Version: 5.26.1
|
||||
"""Generated protocol buffer code."""
|
||||
from google.protobuf import descriptor as _descriptor
|
||||
from google.protobuf import descriptor_pool as _descriptor_pool
|
||||
from google.protobuf import symbol_database as _symbol_database
|
||||
from google.protobuf.internal import builder as _builder
|
||||
# @@protoc_insertion_point(imports)
|
||||
|
||||
_sym_db = _symbol_database.Default()
|
||||
|
||||
|
||||
|
||||
|
||||
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0fRTService.proto\x12\x0eproto_messages\"q\n\tSCreateIn\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\n\n\x02id\x18\x02 \x01(\t\x12\x12\n\nsamplerate\x18\x03 \x01(\x03\x12\x14\n\x0csampleperiod\x18\x04 \x01(\x03\x12\x10\n\x08\x64owntime\x18\x05 \x01(\x03\x12\x0e\n\x06status\x18\x06 \x01(\t\"\x17\n\tSDeleteIn\x12\n\n\x02id\x18\x01 \x01(\t\"\x19\n\x0bSMonStateIn\x12\n\n\x02id\x18\x01 \x01(\t\"\x1d\n\x0cSMonStatesIn\x12\r\n\x05query\x18\x01 \x01(\t\",\n\x0eSSetMonStateIn\x12\n\n\x02id\x18\x01 \x01(\t\x12\x0e\n\x06status\x18\x02 \x01(\t\"\x19\n\x07SResult\x12\x0e\n\x06result\x18\x01 \x01(\x08\"\x1e\n\x0cSStateResult\x12\x0e\n\x06result\x18\x01 \x03(\t2\x89\x03\n\tRTService\x12\x46\n\x10\x43reateMonitoring\x12\x19.proto_messages.SCreateIn\x1a\x17.proto_messages.SResult\x12\x46\n\x10\x44\x65leteMonitoring\x12\x19.proto_messages.SDeleteIn\x1a\x17.proto_messages.SResult\x12J\n\x12GetMonitoringState\x12\x1b.proto_messages.SMonStateIn\x1a\x17.proto_messages.SResult\x12Q\n\x13GetMonitoringStates\x12\x1c.proto_messages.SMonStatesIn\x1a\x1c.proto_messages.SStateResult\x12M\n\x12SetMonitoringState\x12\x1e.proto_messages.SSetMonStateIn\x1a\x17.proto_messages.SResultB\x03\x90\x01\x01\x62\x06proto3')
|
||||
|
||||
_globals = globals()
|
||||
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
||||
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'RTService_pb2', _globals)
|
||||
if not _descriptor._USE_C_DESCRIPTORS:
|
||||
_globals['DESCRIPTOR']._loaded_options = None
|
||||
_globals['DESCRIPTOR']._serialized_options = b'\220\001\001'
|
||||
_globals['_SCREATEIN']._serialized_start=35
|
||||
_globals['_SCREATEIN']._serialized_end=148
|
||||
_globals['_SDELETEIN']._serialized_start=150
|
||||
_globals['_SDELETEIN']._serialized_end=173
|
||||
_globals['_SMONSTATEIN']._serialized_start=175
|
||||
_globals['_SMONSTATEIN']._serialized_end=200
|
||||
_globals['_SMONSTATESIN']._serialized_start=202
|
||||
_globals['_SMONSTATESIN']._serialized_end=231
|
||||
_globals['_SSETMONSTATEIN']._serialized_start=233
|
||||
_globals['_SSETMONSTATEIN']._serialized_end=277
|
||||
_globals['_SRESULT']._serialized_start=279
|
||||
_globals['_SRESULT']._serialized_end=304
|
||||
_globals['_SSTATERESULT']._serialized_start=306
|
||||
_globals['_SSTATERESULT']._serialized_end=336
|
||||
_globals['_RTSERVICE']._serialized_start=339
|
||||
_globals['_RTSERVICE']._serialized_end=732
|
||||
_builder.BuildServices(DESCRIPTOR, 'RTService_pb2', _globals)
|
||||
# @@protoc_insertion_point(module_scope)
|
||||
Binary file not shown.
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectHome>.</ProjectHome>
|
||||
<StartupFile>ecalhdf5_protobuf_rw.py</StartupFile>
|
||||
<SearchPath>..\..\..\lang\python\src</SearchPath>
|
||||
<WorkingDirectory>.</WorkingDirectory>
|
||||
<OutputPath>.</OutputPath>
|
||||
<Name>ecalhdf5_protobuf_rw</Name>
|
||||
<RootNamespace>measurement_read</RootNamespace>
|
||||
<ProjectGuid>{3b37f456-c807-3a24-9ba7-d4757cf4ca23}</ProjectGuid>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ecalhdf5_protobuf_rw.py" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Target Name="CoreCompile" />
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets" />
|
||||
</Project>
|
||||
@@ -1,13 +1,6 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_PROCESSOR armv7-a)
|
||||
|
||||
set(TOOLCHAIN_PREFIX home/markus/STM32MPU_workspace/STM32MP1-Ecosystem-V6.1.0/Distribution-Package-VRDevice/SDK/sysroots/x86_64-ostl_sdk-linux/usr/bin/arm-ostl-linux/)
|
||||
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc)
|
||||
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++)
|
||||
|
||||
#set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
|
||||
project(rt_service)
|
||||
|
||||
|
||||
# Find python and Boost - both are required dependencies
|
||||
@@ -31,7 +24,7 @@ add_library(rt_service MODULE rt_service.cpp)
|
||||
target_link_libraries(rt_service ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
|
||||
target_include_directories(rt_service PRIVATE ${PYTHON_INCLUDE_DIRS})
|
||||
|
||||
set(MY_RESOURCE_FILE rt_service.so)
|
||||
#set(MY_RESOURCE_FILE rt_service.so)
|
||||
#set_directory_properties(MY_EXTENSION_LIB /home/markus/git/vrpmwvweb/vrpmdvserver/extensions/)
|
||||
#file(COPY ${CMAKE_CURRENT_BINARY_DIR}/${MY_RESOURCE_FILE}
|
||||
# DESTINATION /home/markus/git/vrpmdvweb/vrpmdvserver/extensions/rt_service)
|
||||
@@ -1,69 +0,0 @@
|
||||
#include <boost/python.hpp>
|
||||
#include <boost/python/list.hpp>
|
||||
#include <boost/python/extract.hpp>
|
||||
#include <string>
|
||||
//#include <sstream>
|
||||
//#include <vector>
|
||||
|
||||
struct RTService
|
||||
{
|
||||
// private:
|
||||
// /* data */
|
||||
|
||||
// public:
|
||||
// RT_Service(/* args */) {}
|
||||
|
||||
// ~RT_Service() {}
|
||||
|
||||
bool createMonitoring(std::string id) {
|
||||
//TODO ML: add this to the M4Core
|
||||
return true;
|
||||
}
|
||||
|
||||
bool deleteMonitoring(std::string id) {
|
||||
//TODO ML: add this to the M4Core
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string getMonitoringState(std::string id) {
|
||||
//TODO ask the M4Core for the Monitpring Status
|
||||
return "Start";
|
||||
}
|
||||
|
||||
boost::python::list getMonitoringStates() {
|
||||
//TODO ask the M4Core for the Monitpring Status
|
||||
boost::python::list list;
|
||||
return list;
|
||||
}
|
||||
|
||||
bool setMonitoringStatus(std::string id, std::string status) {
|
||||
//set the Status
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
using namespace boost::python;
|
||||
|
||||
BOOST_PYTHON_MODULE(rt_service)
|
||||
{
|
||||
class_<RTService>("RT_Service")
|
||||
.def("createMonitoring", &RTService::createMonitoring)
|
||||
.def("getMonitoringStatus", &RTService::getMonitoringState)
|
||||
.def("getAllMonitoringStat", &RTService::getMonitoringStates)
|
||||
.def("setMonitoringStatus", &RTService::setMonitoringStatus)
|
||||
;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//examples
|
||||
// long l = len(msgs);
|
||||
// std::stringstream ss;
|
||||
// for (long i = 0; i<l; ++i) {
|
||||
// if (i>0) ss << ", ";
|
||||
// std::string s = boost::python::extract<std::string>(msgs[i]);
|
||||
// ss << s;
|
||||
// }
|
||||
// mMsg = ss.str();
|
||||
@@ -0,0 +1,119 @@
|
||||
#include <boost/python.hpp>
|
||||
#include <boost/python/list.hpp>
|
||||
#include <boost/python/extract.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <iostream>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include <boost/interprocess/ipc/message_queue.hpp>
|
||||
|
||||
//#include <sstream>
|
||||
//#include <vector>
|
||||
|
||||
struct RTService
|
||||
{
|
||||
private:
|
||||
/* data */
|
||||
const std::string RTSCOMMANDQUEUE = "RTSSERVICECOMMANDQUEUE";
|
||||
const int MAXMSGSIZE = 250;
|
||||
const int MAXMSGCOUNT = 25;
|
||||
boost::interprocess::message_queue m_mq;
|
||||
public:
|
||||
RTService(/* args */) :
|
||||
m_mq(boost::interprocess::open_or_create, RTSCOMMANDQUEUE.c_str(), MAXMSGCOUNT, MAXMSGSIZE)
|
||||
{
|
||||
}
|
||||
|
||||
~RTService() {}
|
||||
|
||||
bool createMonitoring(std::string id, int samplerate, int sampleperiod, int downtime, std::string status) {
|
||||
//TODO ML: add this to the M4Core
|
||||
boost::property_tree::ptree pt;
|
||||
pt.put("id", id);
|
||||
pt.put("samplerate", samplerate);
|
||||
pt.put("sampleperiod", sampleperiod);
|
||||
pt.put("downtime", downtime);
|
||||
pt.put("status", status);
|
||||
return executeCmd(pt);
|
||||
}
|
||||
|
||||
bool deleteMonitoring(std::string id) {
|
||||
//TODO ML: add this to the M4Core
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string getMonitoringState(std::string id) {
|
||||
//TODO ask the M4Core for the Monitpring Status
|
||||
return "Start";
|
||||
}
|
||||
|
||||
boost::python::list getMonitoringStates() {
|
||||
//TODO ask the M4Core for the Monitpring Status
|
||||
boost::python::list list;
|
||||
return list;
|
||||
}
|
||||
|
||||
bool setMonitoringStatus(std::string id, std::string status) {
|
||||
//set the Status
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
bool executeCmd(boost::property_tree::ptree pt) {
|
||||
BOOST_TRY{
|
||||
|
||||
bool bCmdQueueRun = true;
|
||||
unsigned int priority;
|
||||
boost::interprocess::message_queue::size_type recvd_size;
|
||||
|
||||
while (bCmdQueueRun) {
|
||||
char rtsCmdbuffer [MAXMSGSIZE];
|
||||
boost::property_tree::write_json(rtsCmdbuffer,pt);
|
||||
|
||||
m_mq.send(rtsCmdbuffer, MAXMSGSIZE, 0);
|
||||
|
||||
m_mq.receive(rtsCmdbuffer, sizeof(rtsCmdbuffer), recvd_size, priority);
|
||||
//read json and go to cmd execution
|
||||
boost::property_tree::read_json(rtsCmdbuffer,pt);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// //Send 100 numbers
|
||||
// for(int i = 0; i < 100; ++i){
|
||||
// mq.send(&i, sizeof(i), 0);
|
||||
// }
|
||||
}
|
||||
BOOST_CATCH(interprocess_exception &ex){
|
||||
std::cout << ex.what() << std::endl;
|
||||
} BOOST_CATCH_END
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
using namespace boost::python;
|
||||
|
||||
BOOST_PYTHON_MODULE(rt_service)
|
||||
{
|
||||
class_<RTService>("RT_Service")
|
||||
.def("createMonitoring", &RTService::createMonitoring)
|
||||
.def("getMonitoringStatus", &RTService::getMonitoringState)
|
||||
.def("getAllMonitoringStat", &RTService::getMonitoringStates)
|
||||
.def("setMonitoringStatus", &RTService::setMonitoringStatus)
|
||||
;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//examples
|
||||
// long l = len(msgs);
|
||||
// std::stringstream ss;
|
||||
// for (long i = 0; i<l; ++i) {
|
||||
// if (i>0) ss << ", ";
|
||||
// std::string s = boost::python::extract<std::string>(msgs[i]);
|
||||
// ss << s;
|
||||
// }
|
||||
// mMsg = ss.str();
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,11 @@
|
||||
|
||||
|
||||
|
||||
|
||||
class VRPMDV_CreateMonCmd:
|
||||
def __init__(self, samplerate, sampleperiod, downtime) :
|
||||
self.cmdid = 1
|
||||
self.samplerate = samplerate
|
||||
self.sampleperiod = sampleperiod
|
||||
self.downtime = downtime
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
import uuid
|
||||
import datetime as dt
|
||||
from marshmallow import Schema, fields, post_load, post_dump
|
||||
from vrpmdvcreatemoncmd import VRPMDV_CreateMonCmd
|
||||
|
||||
|
||||
|
||||
|
||||
# class VRPMDV_CreateMonSchema(Schema):
|
||||
# cmdid = fields.Integer()
|
||||
# id = fields.UUID()
|
||||
# samplerate = fields.Integer()
|
||||
# sampleperiod = fields.Integer()
|
||||
# downtime = fields.Integer()
|
||||
# status = fields.String()
|
||||
|
||||
# #monstate = fields.Enum(VRPMDVMonitoringState)
|
||||
|
||||
# # def get_envelope_key(self, many):
|
||||
# # """Helper to get the envelope key."""
|
||||
# # key = self.__envelope__["many"] if many else self.__envelope__["single"]
|
||||
# # assert key is not None, "Envelope key undefined"
|
||||
# # return key
|
||||
|
||||
# # @post_dump(pass_many=True)
|
||||
# # def wrap_with_envelope(self, data, many, **kwargs):
|
||||
# # key = self.get_envelope_key(many)
|
||||
# # return {key: data}
|
||||
|
||||
# @post_load
|
||||
# def make_vrpmdv_Monitoring(self, data, **kwargs):
|
||||
# mon = VRPMDV_Monitoring(**data)
|
||||
# return mon
|
||||
|
||||
|
||||
|
||||
class VRPMDV_CreateMonSchema(Schema):
|
||||
cmdid = fields.Integer()
|
||||
samplerate = fields.Integer()
|
||||
sampleperiod = fields.Integer()
|
||||
downtime = fields.Integer()
|
||||
|
||||
@post_load
|
||||
def make_vrpmdv_CreateMonitoring(self, data, **kwargs):
|
||||
mon = VRPMDV_CreateMonCmd(**data)
|
||||
return mon
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,335 @@
|
||||
from uuid import uuid4
|
||||
import uuid
|
||||
from flask import jsonify
|
||||
import json
|
||||
#import ecal.core.core as ecal_core
|
||||
#from proto_messages.RTService_pb2 import RTService as rts1
|
||||
#import proto_messages.RTService_pb2 as RTServicepb
|
||||
from vrpmdvdeletemoncmd import VRPMDV_DeleteMonCmd
|
||||
from vrpmdvdeletemonschema import VRPMDV_DeleteMonSchema
|
||||
from vrpmdvntlink import trySend
|
||||
|
||||
# from vrpmdvmonitoringschema import VRPMDV_MonitoringSchema
|
||||
# from vrpmdvmonitoring import VRPMDV_Monitoring
|
||||
|
||||
from vrpmdvmonitoringschema import VRPMDV_MonitoringSchema
|
||||
from vrpmdvmonitoring import VRPMDV_Monitoring
|
||||
from vrpmdvmonreqschema import VRPMDV_MonReqSchema
|
||||
from vrpmdvcreatemoncmd import VRPMDV_CreateMonCmd
|
||||
from vrpmdvcreatemonschema import VRPMDV_CreateMonSchema
|
||||
from extensions.rt_service import rt_service as rts
|
||||
from vrpmdvmonitoringState import VRPMDVMonitoringState
|
||||
from vrpmdvlogging import createCoproLoggingTask
|
||||
import logging
|
||||
|
||||
|
||||
class VRPMDV_Data:
|
||||
|
||||
def __init__(self):
|
||||
#self.loaded = False
|
||||
format = "%(asctime)s: %(message)s"
|
||||
logging.basicConfig(format=format, level=logging.INFO, datefmt="%H:%M:%S")
|
||||
self.mons:list = []
|
||||
self.rtservice = rts.RT_Service()
|
||||
self.rtservice.initCoproFW("home/root/elffile","zephyr_openamp_rsc_table.elf")
|
||||
self.logTask = createCoproLoggingTask()
|
||||
self.loaded = self.loadFile()
|
||||
#start the monitorings
|
||||
self.startMons();
|
||||
|
||||
|
||||
|
||||
def loadFile(self):
|
||||
try:
|
||||
with open('./mons.json', 'r') as f:
|
||||
fmons = f.read()
|
||||
|
||||
if not fmons:
|
||||
# return no Item
|
||||
return True
|
||||
else:
|
||||
# data = json.loads(fmons)
|
||||
schema = VRPMDV_MonitoringSchema(many=True)
|
||||
#res = schema.loads(fmons) # data
|
||||
self.mons = schema.loads(fmons) # .append(res)
|
||||
return True
|
||||
except:
|
||||
#nothing todo ML we should create a file later the database
|
||||
print("file not found")
|
||||
|
||||
def saveFile(self):
|
||||
try:
|
||||
with open('./mons.json', 'w') as f:
|
||||
schema = VRPMDV_MonitoringSchema()
|
||||
result = schema.dumps(self.mons, many=True)
|
||||
f.write(result)
|
||||
return True
|
||||
except:
|
||||
#nothing todo
|
||||
print("could not write file")
|
||||
|
||||
def startMons(self):
|
||||
try:
|
||||
for i, val in enumerate(self.mons):
|
||||
if val.status :
|
||||
self.rtservice.startMonitoring(val.samplerate,val.sampleperiod, val.downtime)
|
||||
except:
|
||||
print("could not start monitorings")
|
||||
|
||||
|
||||
|
||||
def findMon(mon):
|
||||
return mon
|
||||
|
||||
def getMonitorings(self):
|
||||
# 1st time read file
|
||||
# if not self.loaded :
|
||||
# self.loaded = self.loadFile()
|
||||
|
||||
schema = VRPMDV_MonitoringSchema()
|
||||
result = schema.dumps(self.mons, many=True)
|
||||
return result
|
||||
|
||||
def getMonitoring(self, vrpmid):
|
||||
try:
|
||||
matched_obj = next(x for x in self.mons if str(x.id) == vrpmid)
|
||||
except:
|
||||
return "no Item found"
|
||||
|
||||
# we find it and we return it
|
||||
schema = VRPMDV_MonitoringSchema()
|
||||
return schema.dumps(matched_obj)
|
||||
|
||||
|
||||
|
||||
def setMonitoring(self, id, request):
|
||||
try:
|
||||
matched_obj = next(x for x in self.mons if str(x.id) == id)
|
||||
except:
|
||||
return "no Item found"
|
||||
|
||||
if 'name' in request : matched_obj.name = request['name']
|
||||
if 'samplerate' in request : matched_obj.samplerate = request['samplerate']
|
||||
if 'sampleperiod' in request : matched_obj.sampleperiod = request['sampleperiod']
|
||||
if 'downtime' in request : matched_obj.downtime = request['downtime']
|
||||
if 'status' in request :
|
||||
matched_obj.setStatus(request['status'])
|
||||
if (request['status'] == 'started'):
|
||||
logging.info("MainThread: started %s", matched_obj.id)
|
||||
matched_obj.setStatus(self._startMonitoring(matched_obj))
|
||||
else :
|
||||
logging.info("MainThread: stopped %s", matched_obj.id)
|
||||
matched_obj.setStatus(self._stopMonitoring(matched_obj))
|
||||
|
||||
self.saveFile()
|
||||
|
||||
# we find it and we return it
|
||||
schema = VRPMDV_MonitoringSchema()
|
||||
return schema.dumps(matched_obj)
|
||||
|
||||
|
||||
def createMonitoring(self, request):
|
||||
id = uuid.uuid4()
|
||||
createjson = request.get_json()
|
||||
vrpmreq = VRPMDV_MonReqSchema().load(createjson)
|
||||
|
||||
mon = VRPMDV_Monitoring(id, vrpmreq.name, vrpmreq.samplerate, vrpmreq.sampleperiod, vrpmreq.downtime, vrpmreq.status, vrpmreq.owner)
|
||||
logging.info("Monitoring %s: starting", str(id))
|
||||
|
||||
# create Monitoring on the realtime side
|
||||
if (vrpmreq.status == 'started'):
|
||||
mon.setStatus(self._createMonOnDevice(mon))
|
||||
|
||||
self.mons.append(mon)
|
||||
#save to file
|
||||
self.saveFile()
|
||||
#create result Object in json
|
||||
schema = VRPMDV_MonitoringSchema()
|
||||
return schema.dumps(mon)
|
||||
|
||||
|
||||
def deleteMonitoring(self, vrpmid):
|
||||
# if not self.loaded :
|
||||
# self.loaded = self.loadFile()
|
||||
|
||||
# find monitoring with uuid
|
||||
#result = filter(lambda mon: str(mon.uuid) == vrpmid["uuid"], self.mons)
|
||||
try:
|
||||
matched_obj = next(x for x in self.mons if str(x.id) == vrpmid)
|
||||
except:
|
||||
return "no Item found"
|
||||
|
||||
|
||||
# we find it, delete on realtime side and now remove from list
|
||||
#matched_obj.deleteMonitoring()
|
||||
self.mons.remove(matched_obj)
|
||||
#save the list
|
||||
self.saveFile()
|
||||
#make result
|
||||
schema = VRPMDV_MonitoringSchema()
|
||||
return schema.dump(matched_obj)
|
||||
|
||||
|
||||
# internal helper function
|
||||
|
||||
def _createMonOnDevice(self, monitoring):
|
||||
|
||||
#call the start API of the c++ driver
|
||||
try:
|
||||
vrpmdCreateCmd = VRPMDV_CreateMonCmd(1, monitoring.no , monitoring.samplerate, monitoring.sampleperiod, monitoring.downtime, monitoring.status)
|
||||
schemaCreateCmd = VRPMDV_CreateMonSchema()
|
||||
|
||||
trySend(schemaCreateCmd.dumps(vrpmdCreateCmd))
|
||||
monitoring.startMonitoring()
|
||||
# set status if we have a success TODO
|
||||
except:
|
||||
return "stopped"
|
||||
return "started"
|
||||
|
||||
|
||||
def _stopMonitoring(self, monitoring):
|
||||
#call the stop API of the c++ driver
|
||||
try:
|
||||
logging.info("MainThread: stop monitoring")
|
||||
vrpmdDeleteCmd = VRPMDV_DeleteMonCmd(2, monitoring.id)
|
||||
schemaDeleteCmd = VRPMDV_DeleteMonSchema()
|
||||
|
||||
trySend(schemaDeleteCmd.dumps(vrpmdDeleteCmd))
|
||||
monitoring.stopMonitoring()
|
||||
logging.info("MainThread: stop monitoring done")
|
||||
|
||||
except:
|
||||
return "no Item found"
|
||||
|
||||
return monitoring.status
|
||||
|
||||
|
||||
# old impl ML
|
||||
#
|
||||
# def createMonitoring(self, request):
|
||||
# id = uuid.uuid4()
|
||||
|
||||
# createjson = request.get_json()
|
||||
# vrpmreq = VRPMDV_MonReqSchema().load(createjson)
|
||||
# vrpmdCreateCmd = VRPMDV_CreateMonCmd(1, id , vrpmreq.samplerate, vrpmreq.sampleperiod, vrpmreq.downtime, vrpmreq.status)
|
||||
# schemaCreateCmd = VRPMDV_CreateMonSchema()
|
||||
|
||||
# valstr = schemaCreateCmd.dumps(vrpmdCreateCmd)
|
||||
# trySend(schemaCreateCmd.dumps(vrpmdCreateCmd))
|
||||
|
||||
# mon = VRPMDV_Monitoring(id, vrpmreq.name, vrpmreq.samplerate, vrpmreq.sampleperiod, vrpmreq.downtime, vrpmreq.status, vrpmreq.owner)
|
||||
# logging.info("Monitoring %s: starting", str(id))
|
||||
# mon.startMonitoring()
|
||||
|
||||
# self.mons.append(mon)
|
||||
# #save to file
|
||||
# self.saveFile()
|
||||
# #create result Object in json
|
||||
# schema = VRPMDV_MonitoringSchema()
|
||||
# return schema.dumps(mon)
|
||||
|
||||
|
||||
|
||||
|
||||
# def createMonitoring(self, request):
|
||||
# id = uuid.uuid4()
|
||||
|
||||
# createjson = request.get_json()
|
||||
# vrpmreq = VRPMDV_MonReqSchema().load(createjson)
|
||||
# vrpmdCreateCmd = VRPMDV_CreateMonCmd(1, id , vrpmreq.samplerate, vrpmreq.sampleperiod, vrpmreq.downtime, vrpmreq.status)
|
||||
# schemaCreateCmd = VRPMDV_CreateMonSchema()
|
||||
|
||||
# valstr = schemaCreateCmd.dumps(vrpmdCreateCmd)
|
||||
# trySend(schemaCreateCmd.dumps(vrpmdCreateCmd))
|
||||
|
||||
# mon = VRPMDV_Monitoring(id, vrpmreq.name, vrpmreq.samplerate, vrpmreq.sampleperiod, vrpmreq.downtime, vrpmreq.status, vrpmreq.owner)
|
||||
# logging.info("Monitoring %s: starting", str(id))
|
||||
# mon.startMonitoring()
|
||||
|
||||
# self.mons.append(mon)
|
||||
# #save to file
|
||||
# self.saveFile()
|
||||
# #create result Object in json
|
||||
# schema = VRPMDV_MonitoringSchema()
|
||||
# return schema.dumps(mon)
|
||||
|
||||
|
||||
# def deleteMonitoring(self, vrpmid):
|
||||
# # if not self.loaded :
|
||||
# # self.loaded = self.loadFile()
|
||||
|
||||
# # find monitoring with uuid
|
||||
# #result = filter(lambda mon: str(mon.uuid) == vrpmid["uuid"], self.mons)
|
||||
# try:
|
||||
# matched_obj = next(x for x in self.mons if str(x.id) == vrpmid)
|
||||
# except:
|
||||
# return "no Item found"
|
||||
|
||||
|
||||
# # we find it, delete on realtime side and now remove from list
|
||||
# #matched_obj.deleteMonitoring()
|
||||
# self.mons.remove(matched_obj)
|
||||
# #save the list
|
||||
# self.saveFile()
|
||||
# #make result
|
||||
# schema = VRPMDV_MonitoringSchema()
|
||||
# return schema.dump(matched_obj)
|
||||
|
||||
|
||||
# def startMonitoring(self, vrpmid):
|
||||
# # if not self.loaded :
|
||||
# # self.loaded = self.loadFile()
|
||||
|
||||
# #call the start API of the c++ driver
|
||||
# try:
|
||||
# matched_obj = next(x for x in self.mons if str(x.id) == vrpmid)
|
||||
|
||||
# except:
|
||||
# return "no Item found"
|
||||
|
||||
# if matched_obj.startMonitoring() :
|
||||
# #TODO ML return the state
|
||||
# return "started"
|
||||
|
||||
# return "created"
|
||||
|
||||
# def stopMonitoring(self, vrpmid):
|
||||
# # if not self.loaded :
|
||||
# # self.loaded = self.loadFile()
|
||||
|
||||
# #call the stop API of the c++ driver
|
||||
# try:
|
||||
# matched_obj = next(x for x in self.mons if str(x.id) == vrpmid)
|
||||
# logging.info("MainThread: stop monitoring starting")
|
||||
# vrpmdDeleteCmd = VRPMDV_DeleteMonCmd(2, matched_obj.id)
|
||||
# schemaDeleteCmd = VRPMDV_DeleteMonSchema()
|
||||
# valstr = schemaDeleteCmd.dumps(vrpmdDeleteCmd)
|
||||
# trySend(schemaDeleteCmd.dumps(vrpmdDeleteCmd))
|
||||
# logging.info("MainThread: stop monitoring done")
|
||||
|
||||
# except:
|
||||
# return "no Item found"
|
||||
|
||||
# matched_obj.stopMonitoring()
|
||||
# return matched_obj.monstate.name
|
||||
|
||||
|
||||
def setStatus(self, id, vrpmStatus):
|
||||
if 'status' in vrpmStatus :
|
||||
# matched_obj = self.findMonitoring(id)
|
||||
#call the start API of the c++ driver
|
||||
if (vrpmStatus['status'] == 'started'):
|
||||
return self.startMonitoring(id)
|
||||
else :
|
||||
return self.stopMonitoring(id)
|
||||
|
||||
# return matched_obj.status
|
||||
|
||||
# return ""
|
||||
|
||||
def findMonitoring(self, id):
|
||||
try:
|
||||
return next(x for x in self.mons if str(x.id) == id)
|
||||
except:
|
||||
return "no Item found"
|
||||
|
||||
+214
-62
@@ -1,22 +1,39 @@
|
||||
import time
|
||||
from uuid import uuid4
|
||||
import uuid
|
||||
from flask import jsonify
|
||||
import json
|
||||
from extensions.rt_service import rt_service as rts
|
||||
|
||||
# from vrpmdvmonitoringschema import VRPMDV_MonitoringSchema
|
||||
# from vrpmdvmonitoring import VRPMDV_Monitoring
|
||||
|
||||
from vrpmdvmonitoringschema import VRPMDV_MonitoringSchema
|
||||
#from vrpmdvcreatemoncmd import VRPMDV_CreateMonCmd
|
||||
#from vrpmdvcreatemonschema import VRPMDV_CreateMonSchema
|
||||
#from vrpmdvdeletemoncmd import VRPMDV_DeleteMonCmd
|
||||
#from vrpmdvdeletemonschema import VRPMDV_DeleteMonSchema
|
||||
from vrpmdvmonitoring import VRPMDV_Monitoring
|
||||
from vrpmdvmonitoringschema import VRPMDV_MonitoringSchema
|
||||
from vrpmdvmonreqschema import VRPMDV_MonReqSchema
|
||||
from vrpmdvntlink import trySend
|
||||
|
||||
from extensions.rt_service import rt_service as rts
|
||||
from vrpmdvmonitoringState import VRPMDVMonitoringState
|
||||
#from vrpmdvlogging import createCoproLoggingTask
|
||||
import logging
|
||||
|
||||
|
||||
class VRPMDV_Data:
|
||||
|
||||
def __init__(self):
|
||||
#self.loaded = False
|
||||
format = "%(asctime)s: %(message)s"
|
||||
logging.basicConfig(format=format, level=logging.INFO, datefmt="%H:%M:%S")
|
||||
self.mons:list = []
|
||||
self.loaded = self.loadFile()
|
||||
self.rtservice = rts.RT_Service()
|
||||
self.rtservice.initCoproFW("home/root/elffile","zephyr_openamp_rsc_table.elf")
|
||||
self.logTask = None #createCoproLoggingTask()
|
||||
self.loaded = self.loadFile()
|
||||
#start the monitorings
|
||||
time.sleep(1)
|
||||
self.startMons();
|
||||
|
||||
|
||||
|
||||
def loadFile(self):
|
||||
try:
|
||||
@@ -47,6 +64,17 @@ class VRPMDV_Data:
|
||||
#nothing todo
|
||||
print("could not write file")
|
||||
|
||||
def startMons(self):
|
||||
try:
|
||||
logging.info("MainThread: startMons")
|
||||
# for i, val in enumerate(self.mons):
|
||||
# if (val.status == 'started') :
|
||||
# val.startMonitoring()
|
||||
except:
|
||||
print("could not start monitorings")
|
||||
|
||||
|
||||
|
||||
def findMon(mon):
|
||||
return mon
|
||||
|
||||
@@ -68,7 +96,9 @@ class VRPMDV_Data:
|
||||
# we find it and we return it
|
||||
schema = VRPMDV_MonitoringSchema()
|
||||
return schema.dumps(matched_obj)
|
||||
|
||||
|
||||
|
||||
|
||||
def setMonitoring(self, id, request):
|
||||
try:
|
||||
matched_obj = next(x for x in self.mons if str(x.id) == id)
|
||||
@@ -79,7 +109,16 @@ class VRPMDV_Data:
|
||||
if 'samplerate' in request : matched_obj.samplerate = request['samplerate']
|
||||
if 'sampleperiod' in request : matched_obj.sampleperiod = request['sampleperiod']
|
||||
if 'downtime' in request : matched_obj.downtime = request['downtime']
|
||||
if 'status' in request : matched_obj.setStatus(request['status'])
|
||||
if 'status' in request :
|
||||
if (request['status'] == 'started'):
|
||||
if (matched_obj.status == VRPMDVMonitoringState.STOPPED):
|
||||
logging.info("MainThread: started %s", matched_obj.id)
|
||||
matched_obj.startMonitoring()
|
||||
# matched_obj.setStatus(self.createMonOnDevice(matched_obj))
|
||||
elif (matched_obj.status == 'started') :
|
||||
logging.info("MainThread: stopped %s", matched_obj.id)
|
||||
# matched_obj.setStatus(self._stopMonitoring(matched_obj))
|
||||
matched_obj.stopMonitoring()
|
||||
self.saveFile()
|
||||
|
||||
# we find it and we return it
|
||||
@@ -87,34 +126,22 @@ class VRPMDV_Data:
|
||||
return schema.dumps(matched_obj)
|
||||
|
||||
|
||||
# try:
|
||||
# matched_obj = next(x for x in self.mons if str(x.id) == vrpmid)
|
||||
# matched_obj.name = request.name
|
||||
# matched_obj.samplerate = request.samplerate
|
||||
# matched_obj.sampleperiod = request.sampleperiod
|
||||
# matched_obj.downtime = request.downtime
|
||||
# self.saveFile()
|
||||
|
||||
# except:
|
||||
# return "no Item found"
|
||||
|
||||
|
||||
# # we find it and we return it
|
||||
# schema = VRPMDV_MonitoringSchema()
|
||||
# return schema.dumps(matched_obj)
|
||||
|
||||
|
||||
|
||||
def createMonitoring(self, request):
|
||||
#mon = VRPMDV_Monitoring(request["name"], request["samplerate"], request["sampleperiod"], request["downtime"], request["owner"])
|
||||
id = uuid.uuid4()
|
||||
mon = VRPMDV_Monitoring(id, request.name, request.samplerate, request.sampleperiod, request.downtime, request.status, request.owner)
|
||||
iscreated = mon.createMonitoring()
|
||||
#iscreated = self.rtservice.createMonitoring(str(id))
|
||||
createjson = request.get_json()
|
||||
vrpmreq = VRPMDV_MonReqSchema().load(createjson)
|
||||
|
||||
mon = VRPMDV_Monitoring(0, id, vrpmreq.name, vrpmreq.samplerate, vrpmreq.sampleperiod, vrpmreq.downtime, vrpmreq.status, vrpmreq.owner)
|
||||
logging.info("Monitoring %s: creating", str(id))
|
||||
|
||||
# create Monitoring on the realtime side
|
||||
if (vrpmreq.status == 'started'):
|
||||
logging.info("Monitoring %s: createMonOnDevice", str(id))
|
||||
mon.startMonitoring()
|
||||
# status = self.createMonOnDevice(mon)
|
||||
# logging.info("Monitoring %s: _start executed. status:%s", str(id), str(status))
|
||||
# mon.status = status
|
||||
|
||||
# if not self.loaded :
|
||||
# self.loaded = self.loadFile()
|
||||
# create monitoring
|
||||
self.mons.append(mon)
|
||||
#save to file
|
||||
self.saveFile()
|
||||
@@ -122,6 +149,7 @@ class VRPMDV_Data:
|
||||
schema = VRPMDV_MonitoringSchema()
|
||||
return schema.dumps(mon)
|
||||
|
||||
|
||||
def deleteMonitoring(self, vrpmid):
|
||||
# if not self.loaded :
|
||||
# self.loaded = self.loadFile()
|
||||
@@ -135,7 +163,7 @@ class VRPMDV_Data:
|
||||
|
||||
|
||||
# we find it, delete on realtime side and now remove from list
|
||||
matched_obj.deleteMonitoring()
|
||||
matched_obj.stopMonitoring()
|
||||
self.mons.remove(matched_obj)
|
||||
#save the list
|
||||
self.saveFile()
|
||||
@@ -144,48 +172,172 @@ class VRPMDV_Data:
|
||||
return schema.dump(matched_obj)
|
||||
|
||||
|
||||
def startMonitoring(self, vrpmid):
|
||||
# if not self.loaded :
|
||||
# self.loaded = self.loadFile()
|
||||
# internal helper function
|
||||
|
||||
#call the start API of the c++ driver
|
||||
try:
|
||||
matched_obj = next(x for x in self.mons if str(x.id) == vrpmid)
|
||||
except:
|
||||
return "no Item found"
|
||||
# ML: transfer to Monitoring class
|
||||
# def createMonOnDevice(self, monitoring):
|
||||
# #call the start API of the c++ driver
|
||||
# try:
|
||||
|
||||
# logging.info("MainThread: createMonOnDevice => before vrpmdCreateCmd samplerate:%d, samplerate:%d, samplerate:%d", monitoring.samplerate, monitoring.sampleperiod, monitoring.downtime)
|
||||
# vrpmdCreateCmd = VRPMDV_CreateMonCmd(monitoring.samplerate, monitoring.sampleperiod, monitoring.downtime)
|
||||
# logging.info("MainThread: createMonOnDevice => before schemaCreateCmd")
|
||||
# schemaCreateCmd = VRPMDV_CreateMonSchema()
|
||||
# logging.info("MainThread: try send start monitoring starting %s", schemaCreateCmd.dumps(vrpmdCreateCmd))
|
||||
# #res = trySend(schemaCreateCmd.dumps(vrpmdCreateCmd))
|
||||
# #logging.info("MainThread: try send start monitoring done %s", res)
|
||||
# self.status = "started"
|
||||
# # set status if we have a success TODO
|
||||
# except:
|
||||
# self.status = "stopped"
|
||||
# return "stopped"
|
||||
# return "started"
|
||||
|
||||
if matched_obj.startMonitoring() :
|
||||
#TODO ML return the state
|
||||
return "started"
|
||||
|
||||
return "created"
|
||||
# def _stopMonitoring(self, monitoring):
|
||||
# #call the stop API of the c++ driver
|
||||
# try:
|
||||
# logging.info("MainThread: stop monitoring")
|
||||
# vrpmdDeleteCmd = VRPMDV_DeleteMonCmd(2, monitoring.id)
|
||||
# schemaDeleteCmd = VRPMDV_DeleteMonSchema()
|
||||
|
||||
# #trySend(schemaDeleteCmd.dumps(vrpmdDeleteCmd))
|
||||
# self.status = "stopped"
|
||||
# logging.info("MainThread: stop monitoring done")
|
||||
|
||||
def stopMonitoring(self, vrpmid):
|
||||
# if not self.loaded :
|
||||
# self.loaded = self.loadFile()
|
||||
# except:
|
||||
# self.status = "started"
|
||||
# return "started"
|
||||
|
||||
#call the start API of the c++ driver
|
||||
try:
|
||||
matched_obj = next(x for x in self.mons if str(x.id) == vrpmid)
|
||||
except:
|
||||
return "no Item found"
|
||||
# return monitoring.status
|
||||
|
||||
matched_obj.startMonitoring()
|
||||
return matched_obj.monstate.name
|
||||
|
||||
# old impl ML
|
||||
#
|
||||
# def createMonitoring(self, request):
|
||||
# id = uuid.uuid4()
|
||||
|
||||
# createjson = request.get_json()
|
||||
# vrpmreq = VRPMDV_MonReqSchema().load(createjson)
|
||||
# vrpmdCreateCmd = VRPMDV_CreateMonCmd(1, id , vrpmreq.samplerate, vrpmreq.sampleperiod, vrpmreq.downtime, vrpmreq.status)
|
||||
# schemaCreateCmd = VRPMDV_CreateMonSchema()
|
||||
|
||||
# valstr = schemaCreateCmd.dumps(vrpmdCreateCmd)
|
||||
# trySend(schemaCreateCmd.dumps(vrpmdCreateCmd))
|
||||
|
||||
# mon = VRPMDV_Monitoring(id, vrpmreq.name, vrpmreq.samplerate, vrpmreq.sampleperiod, vrpmreq.downtime, vrpmreq.status, vrpmreq.owner)
|
||||
# logging.info("Monitoring %s: starting", str(id))
|
||||
# mon.startMonitoring()
|
||||
|
||||
# self.mons.append(mon)
|
||||
# #save to file
|
||||
# self.saveFile()
|
||||
# #create result Object in json
|
||||
# schema = VRPMDV_MonitoringSchema()
|
||||
# return schema.dumps(mon)
|
||||
|
||||
|
||||
|
||||
|
||||
# def createMonitoring(self, request):
|
||||
# id = uuid.uuid4()
|
||||
|
||||
# createjson = request.get_json()
|
||||
# vrpmreq = VRPMDV_MonReqSchema().load(createjson)
|
||||
# vrpmdCreateCmd = VRPMDV_CreateMonCmd(1, id , vrpmreq.samplerate, vrpmreq.sampleperiod, vrpmreq.downtime, vrpmreq.status)
|
||||
# schemaCreateCmd = VRPMDV_CreateMonSchema()
|
||||
|
||||
# valstr = schemaCreateCmd.dumps(vrpmdCreateCmd)
|
||||
# trySend(schemaCreateCmd.dumps(vrpmdCreateCmd))
|
||||
|
||||
# mon = VRPMDV_Monitoring(id, vrpmreq.name, vrpmreq.samplerate, vrpmreq.sampleperiod, vrpmreq.downtime, vrpmreq.status, vrpmreq.owner)
|
||||
# logging.info("Monitoring %s: starting", str(id))
|
||||
# mon.startMonitoring()
|
||||
|
||||
# self.mons.append(mon)
|
||||
# #save to file
|
||||
# self.saveFile()
|
||||
# #create result Object in json
|
||||
# schema = VRPMDV_MonitoringSchema()
|
||||
# return schema.dumps(mon)
|
||||
|
||||
|
||||
# def deleteMonitoring(self, vrpmid):
|
||||
# # if not self.loaded :
|
||||
# # self.loaded = self.loadFile()
|
||||
|
||||
# # find monitoring with uuid
|
||||
# #result = filter(lambda mon: str(mon.uuid) == vrpmid["uuid"], self.mons)
|
||||
# try:
|
||||
# matched_obj = next(x for x in self.mons if str(x.id) == vrpmid)
|
||||
# except:
|
||||
# return "no Item found"
|
||||
|
||||
|
||||
# # we find it, delete on realtime side and now remove from list
|
||||
# #matched_obj.deleteMonitoring()
|
||||
# self.mons.remove(matched_obj)
|
||||
# #save the list
|
||||
# self.saveFile()
|
||||
# #make result
|
||||
# schema = VRPMDV_MonitoringSchema()
|
||||
# return schema.dump(matched_obj)
|
||||
|
||||
|
||||
# def startMonitoring(self, vrpmid):
|
||||
# # if not self.loaded :
|
||||
# # self.loaded = self.loadFile()
|
||||
|
||||
# #call the start API of the c++ driver
|
||||
# try:
|
||||
# matched_obj = next(x for x in self.mons if str(x.id) == vrpmid)
|
||||
|
||||
# except:
|
||||
# return "no Item found"
|
||||
|
||||
# if matched_obj.startMonitoring() :
|
||||
# #TODO ML return the state
|
||||
# return "started"
|
||||
|
||||
# return "created"
|
||||
|
||||
# def stopMonitoring(self, vrpmid):
|
||||
# # if not self.loaded :
|
||||
# # self.loaded = self.loadFile()
|
||||
|
||||
# #call the stop API of the c++ driver
|
||||
# try:
|
||||
# matched_obj = next(x for x in self.mons if str(x.id) == vrpmid)
|
||||
# logging.info("MainThread: stop monitoring starting")
|
||||
# vrpmdDeleteCmd = VRPMDV_DeleteMonCmd(2, matched_obj.id)
|
||||
# schemaDeleteCmd = VRPMDV_DeleteMonSchema()
|
||||
# valstr = schemaDeleteCmd.dumps(vrpmdDeleteCmd)
|
||||
# trySend(schemaDeleteCmd.dumps(vrpmdDeleteCmd))
|
||||
# logging.info("MainThread: stop monitoring done")
|
||||
|
||||
# except:
|
||||
# return "no Item found"
|
||||
|
||||
# matched_obj.stopMonitoring()
|
||||
# return matched_obj.monstate.name
|
||||
|
||||
|
||||
def setStatus(self, id, vrpmStatus):
|
||||
if 'status' in vrpmStatus :
|
||||
matched_obj = self.findMonitoring(id)
|
||||
# matched_obj = self.findMonitoring(id)
|
||||
#call the start API of the c++ driver
|
||||
matched_obj.setStatus(vrpmStatus['status'])
|
||||
return matched_obj.status
|
||||
if (vrpmStatus['status'] == 'started'):
|
||||
return self.startMonitoring(id)
|
||||
else :
|
||||
return self.stopMonitoring(id)
|
||||
|
||||
# return matched_obj.status
|
||||
|
||||
return ""
|
||||
# return ""
|
||||
|
||||
def findMonitoring(self, id):
|
||||
try:
|
||||
return next(x for x in self.mons if str(x.id) == id)
|
||||
except:
|
||||
return "no Item found"
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import datetime as dt
|
||||
|
||||
|
||||
|
||||
class VRPMDV_DeleteMonCmd:
|
||||
def __init__(self, id ) :
|
||||
self.cmdid = 2
|
||||
self.id = id
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import uuid
|
||||
import datetime as dt
|
||||
from marshmallow import Schema, fields, post_load, post_dump
|
||||
from vrpmdvdeletemoncmd import VRPMDV_DeleteMonCmd
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class VRPMDV_DeleteMonSchema(Schema):
|
||||
cmdid = fields.Integer()
|
||||
id = fields.UUID()
|
||||
|
||||
|
||||
@post_load
|
||||
def make_vrpmdv_DeleteMonitoring(self, data, **kwargs):
|
||||
mon = VRPMDV_DeleteMonCmd(**data)
|
||||
return mon
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import datetime as dt
|
||||
|
||||
|
||||
# generic command for delete, start, stop of the monitoring
|
||||
class VRPMDV_GenericMonCmd:
|
||||
def __init__(self, id , cmdId) :
|
||||
self.id = id
|
||||
self.cmdId = cmdId
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
from extensions.rt_service import rt_service as rts
|
||||
import logging
|
||||
import threading
|
||||
import time
|
||||
|
||||
|
||||
|
||||
|
||||
def thread_function(name):
|
||||
|
||||
logging.info("Thread %s: starting", name)
|
||||
rtserv = rts.RT_Service()
|
||||
isok = rtserv.initLogChannel()
|
||||
if (not isok):
|
||||
logging.info("Thread %s: could not open the logport", name)
|
||||
|
||||
while (isok):
|
||||
msg = rtserv.readLogChannel()
|
||||
logging.info(msg)
|
||||
if (msg == 'noResult'):
|
||||
break
|
||||
|
||||
logging.info("Thread %s: finishing", name)
|
||||
|
||||
|
||||
|
||||
def createCoproLoggingTask():
|
||||
format = "%(asctime)s: %(message)s"
|
||||
logging.basicConfig(format=format, level=logging.INFO, datefmt="%H:%M:%S")
|
||||
x = threading.Thread(target=thread_function, args=(1,))
|
||||
|
||||
x.start()
|
||||
return x
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
from extensions.rt_service import rt_service as rts
|
||||
import logging
|
||||
import threading
|
||||
import time
|
||||
|
||||
|
||||
|
||||
|
||||
def thread_function(name):
|
||||
|
||||
logging.info("MonThread %s: starting", name)
|
||||
rtserv = rts.RT_Service()
|
||||
isok = rtserv.openDataChannel('/dev/mon-datafile')
|
||||
if (not isok):
|
||||
logging.info("MonThread %s: could not open the logport", name)
|
||||
|
||||
while (isok):
|
||||
msg = rtserv.readDataChannel()
|
||||
logging.info(msg)
|
||||
if (msg == 'noResult'):
|
||||
break
|
||||
|
||||
logging.info("MonThread %s: finishing", name)
|
||||
rtserv.closeDataChannel()
|
||||
|
||||
|
||||
|
||||
def createCoproLoggingTask():
|
||||
format = "%(asctime)s: %(message)s"
|
||||
logging.basicConfig(format=format, level=logging.INFO, datefmt="%H:%M:%S")
|
||||
x = threading.Thread(target=thread_function, args=(1,))
|
||||
|
||||
x.start()
|
||||
return x
|
||||
|
||||
@@ -2,58 +2,192 @@ import uuid
|
||||
import datetime as dt
|
||||
from marshmallow import Schema, fields, post_load
|
||||
|
||||
from vrpmdvcreatemoncmd import VRPMDV_CreateMonCmd
|
||||
from vrpmdvcreatemonschema import VRPMDV_CreateMonSchema
|
||||
from vrpmdvdeletemoncmd import VRPMDV_DeleteMonCmd
|
||||
from vrpmdvdeletemonschema import VRPMDV_DeleteMonSchema
|
||||
from vrpmdvmonreq import VRPMDV_MonReq
|
||||
from extensions.rt_service import rt_service as rts
|
||||
from vrpmdvmonitoringState import VRPMDVMonitoringState
|
||||
from vrpmdvmondata import createCoproLoggingTask
|
||||
from vrpmdvntlink import trySend
|
||||
import logging
|
||||
import threading
|
||||
import time
|
||||
|
||||
import io
|
||||
import fcntl
|
||||
import mmap
|
||||
|
||||
from vrpmdvstatusmoncmd import VRPMDV_StatusMonCmd
|
||||
from vrpmdvstatusmonschema import VRPMDV_StatusMonSchema
|
||||
|
||||
|
||||
# def thread_function(name):
|
||||
|
||||
# logging.info("MonThread %s: starting", name)
|
||||
# fdesc = -1
|
||||
# rtMon = rts.RTSMonitoringTask()
|
||||
# fdesc = rtMon.openChannel('/dev/mon-datafile')
|
||||
|
||||
# # write loginfos to Buffer
|
||||
# msg = rtMon.getLogMsg()
|
||||
# for msgstr in msg:
|
||||
# logging.info(str(msgstr))
|
||||
|
||||
# while ((fdesc >= 0) && ()):
|
||||
# msg = rtMon.readChannel(fdesc)
|
||||
# # write loginfos to Buffer
|
||||
# logmsg = rtMon.getLogMsg()
|
||||
# for msgstr in logmsg:
|
||||
# logging.info(str(msgstr))
|
||||
|
||||
# logging.info(msg)
|
||||
# if (msg == 'noResult'):
|
||||
# break
|
||||
|
||||
# logging.info("MonThread %s: finishing", name)
|
||||
# rtMon.closeChannel(fdesc)
|
||||
|
||||
# if (res):
|
||||
# props = res.getMsg()
|
||||
# #props = res.getProps()
|
||||
# if (res.getResCode() == 'error'):
|
||||
# try:
|
||||
# logging.info(props)
|
||||
# # for key, value in props.items():
|
||||
# # logging.info(key+" "+ str(value))
|
||||
# except:
|
||||
# logging.info("MonThread %s: could not open the channel", name)
|
||||
# else:
|
||||
# try:
|
||||
# logging.info(props)
|
||||
# # for key, value in props.items():
|
||||
# # logging.info(key+" "+ str(value))
|
||||
# except:
|
||||
# logging.info("MonThread %s: could read fdesc of the channel", name)
|
||||
# else :
|
||||
# logging.info("MonThread %s: result = None", name)
|
||||
|
||||
|
||||
|
||||
|
||||
# class VRPMDV_MonReq:
|
||||
# def __init__(self, name , samplerate, sampleperiod, downtime, owner) :
|
||||
# self.name = name
|
||||
# self.samplerate = samplerate
|
||||
# self.sampleperiod = sampleperiod
|
||||
# self.downtime = downtime
|
||||
# self.owner = owner
|
||||
|
||||
class VRPMDV_Monitoring(VRPMDV_MonReq):
|
||||
|
||||
def __init__(self, id, name , samplerate, sampleperiod, downtime, status, owner="None", created_at=dt.datetime.now()) :
|
||||
def __init__(self, no, id, name , samplerate, sampleperiod, downtime, status, owner="None", created_at=dt.datetime.now()) :
|
||||
self.no = no
|
||||
self.id = id
|
||||
self.created_at = created_at
|
||||
self.rtservice = rts.RT_Service()
|
||||
self.rtMon = rts.RTSMonitoringTask()
|
||||
self.monTask = None
|
||||
self.run_thread = False
|
||||
self.fdesc = -1
|
||||
super().__init__(name, samplerate, sampleperiod, downtime, owner, status)
|
||||
|
||||
def createMonitoring(self) :
|
||||
if self.status != VRPMDVMonitoringState.OFF:
|
||||
iscreated = self.rtservice.createMonitoring(str(self.id))
|
||||
if not iscreated :
|
||||
self.status = VRPMDVMonitoringState.OFF
|
||||
return True
|
||||
return False
|
||||
|
||||
def deleteMonitoring(self) :
|
||||
isdeleted = self.rtservice.deleteMonitoring(str(self.id))
|
||||
if (isdeleted) :
|
||||
self.monstate = VRPMDVMonitoringState.OFF
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def startMonitoring(self) :
|
||||
isstarted = self.rtservice.setMonitoringState(str(self.id), VRPMDVMonitoringState.started)
|
||||
if (isstarted) :
|
||||
self.monstate = VRPMDVMonitoringState.STARTED
|
||||
return True
|
||||
return False
|
||||
#send create command to M4
|
||||
try :
|
||||
logging.basicConfig(format=format, level=logging.INFO, datefmt="%H:%M:%S")
|
||||
logging.info("MainThread: createMonOnDevice => before vrpmdCreateCmd samplerate:%d, samplerate:%d, samplerate:%d", self.samplerate, self.sampleperiod, self.downtime)
|
||||
vrpmdCreateCmd = VRPMDV_CreateMonCmd(self.samplerate, self.sampleperiod, self.downtime)
|
||||
logging.info("MainThread: createMonOnDevice => before schemaCreateCmd")
|
||||
schemaCreateCmd = VRPMDV_CreateMonSchema()
|
||||
logging.info("MainThread: try send start monitoring starting %s", schemaCreateCmd.dumps(vrpmdCreateCmd))
|
||||
res = trySend(schemaCreateCmd.dumps(vrpmdCreateCmd))
|
||||
logging.info("MainThread: try send start monitoring done %s", res)
|
||||
|
||||
# start the receiving thread
|
||||
logging.info("MainThread %s: open", str(self.id))
|
||||
# self.fdesc = self.rtMon.openChannel('/dev/mon-datafile')
|
||||
|
||||
# self.run_thread = True
|
||||
# self.monTask = threading.Thread(target=self.run, args=())
|
||||
# self.monTask.start()
|
||||
# logging.info("MainThread: strated Mon Thread %s started", self.id)
|
||||
self.status = 'started'
|
||||
return self.status
|
||||
except :
|
||||
self.status = "stopped"
|
||||
return self.status
|
||||
|
||||
def stopMonitoring(self) :
|
||||
isstopped = self.rtservice.setMonitoringState(str(self.id), VRPMDVMonitoringState.stopped)
|
||||
if (isstopped) :
|
||||
self.monstate = VRPMDVMonitoringState.STOPPED
|
||||
return True
|
||||
return False
|
||||
# isstopped = self.rtservice.setMonitoringState(str(self.id), VRPMDVMonitoringState.stopped)
|
||||
logging.basicConfig(format=format, level=logging.INFO, datefmt="%H:%M:%S")#
|
||||
logging.info("MainThread: stopping Mon Thread %s ", self.id)
|
||||
#send delete cmd to M4
|
||||
logging.info("MainThread: stop monitoring")
|
||||
|
||||
|
||||
if (self.monTask != None) :
|
||||
# set the value Runthread to fals that the thread terminate
|
||||
self.run_thread = False
|
||||
self.monTask.join(None)
|
||||
self.monTask = None
|
||||
logging.info("MonThread %s: closing fdesc=%s", str(self.id), str(self.fdesc))
|
||||
self.rtMon.closeChannel(self.fdesc)
|
||||
logging.info("MonThread %s: closed fdesc=%s", str(self.id), str(self.fdesc))
|
||||
|
||||
logging.info("MainThread: stopped Mon Thread %s ", self.id)
|
||||
|
||||
vrpmdDeleteCmd = VRPMDV_DeleteMonCmd(self.no)
|
||||
schemaDeleteCmd = VRPMDV_DeleteMonSchema()
|
||||
res = trySend(schemaDeleteCmd.dumps(vrpmdDeleteCmd))
|
||||
logging.info("MainThread: try send stop monitoring done %s", res)
|
||||
|
||||
# if (isstopped) :
|
||||
self.status = 'stopped'
|
||||
return self.status
|
||||
|
||||
def setStatus(self, status) :
|
||||
isStatusSet = self.rtservice.setMonitoringStatus(str(self.id), status)
|
||||
if (isStatusSet) :
|
||||
self.status = status
|
||||
return True
|
||||
return False
|
||||
# def setStatus(self, status) :
|
||||
# # isStatusSet = self.rtservice.setMonitoringStatus(str(self.id), status)
|
||||
# logging.info("MainThread: set status ")
|
||||
# return True
|
||||
|
||||
def run(self):
|
||||
|
||||
# logging.info("MonThread %s: starting", str(self.id))
|
||||
# fdesc = -1
|
||||
# rtMon = rts.RTSMonitoringTask()
|
||||
# fdesc = rtMon.openChannel('/dev/mon-datafile')
|
||||
|
||||
# write loginfos to Buffer
|
||||
# msg = rtMon.getLogMsg()
|
||||
# for msgstr in msg:
|
||||
# logging.info(str(msgstr))
|
||||
|
||||
count = 0;
|
||||
if (self.fdesc >= 0) :
|
||||
while (self.run_thread):
|
||||
# check if the thread is running
|
||||
# if (count == 50):
|
||||
# vrpmdStatusCmd = VRPMDV_StatusMonCmd(self.no)
|
||||
# schemaStatusCmd = VRPMDV_StatusMonSchema()
|
||||
# res = trySend(schemaStatusCmd.dumps(vrpmdStatusCmd))
|
||||
# logging.info("MainThread: try send stop monitoring done %s", res)
|
||||
# count = 0
|
||||
#count = count +1
|
||||
|
||||
msg = self.rtMon.readChannel(self.fdesc)
|
||||
logging.info("MonThread %s: running", str(self.id))
|
||||
logging.info("Result: %s", msg)
|
||||
#time.sleep(1)
|
||||
|
||||
# write loginfos to Buffer
|
||||
# logmsg = rtMon.getLogMsg()
|
||||
# for msgstr in logmsg:
|
||||
# logging.info(str(msgstr))
|
||||
|
||||
# logging.info(msg)
|
||||
# if (msg == 'noResult'):
|
||||
# break
|
||||
|
||||
# logging.info("MonThread %s: finishing", str(self.id))
|
||||
# rtMon.closeChannel(fdesc)
|
||||
logging.info("MonThread %s: finished", str(self.id))
|
||||
# msg = rtMon.getLogMsg()
|
||||
# for msgstr in msg:
|
||||
# logging.info(str(msgstr))
|
||||
else:
|
||||
logging.info("MonThread %s: opening failed fdesc <= 0", str(self.id))
|
||||
|
||||
@@ -5,21 +5,20 @@ from marshmallow import Schema, fields, post_load
|
||||
|
||||
|
||||
class VRPMDVMonitoringState():
|
||||
OFF = "off"
|
||||
CREATED = "created"
|
||||
STARTED = "started"
|
||||
STOPPED = "stopped"
|
||||
STARTED = 'started'
|
||||
STOPPED = 'stopped'
|
||||
|
||||
def __init__(self, state = OFF):
|
||||
NCREATE = 0
|
||||
NDELETE = 1
|
||||
|
||||
def __init__(self, state = STOPPED):
|
||||
self.state = state
|
||||
|
||||
|
||||
class VRPMDVMonitoringStateSchema(Schema):
|
||||
monstate = fields.String()
|
||||
|
||||
@post_load
|
||||
def make_vrpmdv_MonitoringState(self, data, **kwargs):
|
||||
return VRPMDVMonitoringState(**data)
|
||||
def get(self) :
|
||||
if (self.state == self.STARTED) :
|
||||
return self.NCREATE
|
||||
else :
|
||||
return self.NDELETE
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#from enum import Enum
|
||||
from marshmallow import Schema, fields, post_load
|
||||
|
||||
|
||||
|
||||
|
||||
class VRPMDVMonitoringState():
|
||||
OFF = "off"
|
||||
CREATED = "created"
|
||||
STARTED = "started"
|
||||
STOPPED = "stopped"
|
||||
|
||||
def __init__(self, state = OFF):
|
||||
self.state = state
|
||||
|
||||
|
||||
class VRPMDVMonitoringStateSchema(Schema):
|
||||
monstate = fields.String()
|
||||
|
||||
@post_load
|
||||
def make_vrpmdv_MonitoringState(self, data, **kwargs):
|
||||
return VRPMDVMonitoringState(**data)
|
||||
|
||||
|
||||
|
||||
|
||||
# class VRPMDVMonitoringState(Enum):
|
||||
# off = 1
|
||||
# created = 2
|
||||
# started = 3
|
||||
# stopped = 4
|
||||
@@ -2,11 +2,11 @@ import uuid
|
||||
import datetime as dt
|
||||
from marshmallow import Schema, fields, post_load, post_dump
|
||||
from vrpmdvmonitoring import VRPMDV_Monitoring
|
||||
from vrpmdvmonitoringState import VRPMDVMonitoringStateSchema
|
||||
|
||||
|
||||
|
||||
class VRPMDV_MonitoringSchema(Schema):
|
||||
no = fields.Integer()
|
||||
id = fields.UUID()
|
||||
created_at = fields.DateTime("%m/%d/%Y, %H:%M")
|
||||
name = fields.String()
|
||||
@@ -16,24 +16,11 @@ class VRPMDV_MonitoringSchema(Schema):
|
||||
owner = fields.String()
|
||||
status = fields.String()
|
||||
|
||||
#monstate = fields.Enum(VRPMDVMonitoringState)
|
||||
|
||||
# def get_envelope_key(self, many):
|
||||
# """Helper to get the envelope key."""
|
||||
# key = self.__envelope__["many"] if many else self.__envelope__["single"]
|
||||
# assert key is not None, "Envelope key undefined"
|
||||
# return key
|
||||
|
||||
# @post_dump(pass_many=True)
|
||||
# def wrap_with_envelope(self, data, many, **kwargs):
|
||||
# key = self.get_envelope_key(many)
|
||||
# return {key: data}
|
||||
|
||||
@post_load
|
||||
def make_vrpmdv_Monitoring(self, data, **kwargs):
|
||||
mon = VRPMDV_Monitoring(**data)
|
||||
#create the monitoring on the realtime side
|
||||
mon.createMonitoring()
|
||||
# mon.createMonitoring()
|
||||
return mon
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import traceback
|
||||
from pyroute2.netlink import NLM_F_REQUEST
|
||||
from pyroute2.netlink import genlmsg
|
||||
from pyroute2.netlink.generic import GenericNetlinkSocket
|
||||
import sys
|
||||
|
||||
|
||||
RLINK_CMD_UNSPEC = 0
|
||||
RLINK_CMD_REQ = 1
|
||||
|
||||
|
||||
class rcmd(genlmsg):
|
||||
'''
|
||||
Message class that will be used to communicate
|
||||
with the kernel module
|
||||
'''
|
||||
|
||||
nla_map = (
|
||||
('RLINK_ATTR_UNSPEC', 'none'),
|
||||
('RLINK_ATTR_DATA', 'asciiz'),
|
||||
)
|
||||
|
||||
|
||||
class Rlink(GenericNetlinkSocket):
|
||||
def send_data(self, data):
|
||||
msg = rcmd()
|
||||
msg['cmd'] = RLINK_CMD_REQ
|
||||
msg['version'] = 1
|
||||
msg['attrs'] = [('RLINK_ATTR_DATA', data)]
|
||||
ret = self.nlm_request(msg, self.prid, msg_flags=NLM_F_REQUEST)[0]
|
||||
return ret.get_attr('RLINK_ATTR_DATA')
|
||||
|
||||
def trySend(data):
|
||||
# if __name__ == '__main__':
|
||||
try:
|
||||
# create protocol instance
|
||||
rlink = Rlink()
|
||||
rlink.bind('gnl-vrpmdv-mcmd', rcmd)
|
||||
#rlink.send_data(data)
|
||||
# request a method
|
||||
res = rlink.send_data(data)
|
||||
if res :
|
||||
print(res, file=sys.stdout)
|
||||
sys.stdout.flush()
|
||||
except:
|
||||
# if there was an error, log it to the console
|
||||
traceback.print_exc()
|
||||
finally:
|
||||
# finally -- release the instance
|
||||
rlink.close()
|
||||
return res
|
||||
@@ -5,6 +5,9 @@ from flask import Flask, request , send_from_directory , Response
|
||||
from flask_cors import CORS
|
||||
from vrpmdvdata import VRPMDV_Data
|
||||
from vrpmdvmonreqschema import VRPMDV_MonReqSchema
|
||||
# import ecal.core.core as ecal_core
|
||||
# from proto_messages.RTService_pb2 import _RTSERVICE as rtservice
|
||||
|
||||
|
||||
app = Flask(__name__, static_url_path='', static_folder='./build')
|
||||
CORS(app) #comment this on deployment
|
||||
@@ -39,8 +42,9 @@ def set_monitoring(id):
|
||||
|
||||
@app.route('/vrpmdvapi/1_0/monitorings', methods=['POST'])
|
||||
def create_monitoring():
|
||||
vrpmreq = VRPMDV_MonReqSchema().load(request.get_json())
|
||||
data = vrpmdvdata.createMonitoring(vrpmreq)
|
||||
#vrpmreq = VRPMDV_MonReqSchema().load(request.get_json())
|
||||
#data = vrpmdvdata.createMonitoring(vrpmreq)
|
||||
data = vrpmdvdata.createMonitoring(request)
|
||||
resp = Response(data, status=200, mimetype='application/json')
|
||||
return resp
|
||||
|
||||
@@ -78,5 +82,45 @@ def setStatus(id):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run()
|
||||
# initialize eCAL API. The name of our Process will be
|
||||
|
||||
# "Python Protobuf Subscriber"
|
||||
|
||||
#ecal_core.initialize(sys.argv, "Python Protobuf Subscriber")
|
||||
|
||||
app.run()
|
||||
|
||||
|
||||
|
||||
# if __name__ == "__main__":
|
||||
|
||||
|
||||
|
||||
# # Create a Protobuf Publisher that publishes on the topic
|
||||
|
||||
# # "hello_world_python_protobuf_topic". The second parameter tells eCAL which
|
||||
|
||||
# # datatype we are expecting to receive on that topic.
|
||||
|
||||
# sub = ProtoSubscriber("hello_world_python_protobuf_topic"
|
||||
|
||||
# , hello_world_pb2.HelloWorld)
|
||||
|
||||
|
||||
# # Set the Callback
|
||||
|
||||
# sub.set_callback(callback)
|
||||
|
||||
|
||||
|
||||
# # Just don't exit
|
||||
|
||||
# while ecal_core.ok():
|
||||
|
||||
# time.sleep(0.5)
|
||||
|
||||
|
||||
|
||||
# # finalize eCAL API
|
||||
|
||||
# ecal_core.finalize()
|
||||
@@ -0,0 +1,10 @@
|
||||
import datetime as dt
|
||||
|
||||
|
||||
|
||||
class VRPMDV_StatusMonCmd:
|
||||
def __init__(self, id ) :
|
||||
self.cmdid = 3
|
||||
self.id = id
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import uuid
|
||||
import datetime as dt
|
||||
from marshmallow import Schema, fields, post_load, post_dump
|
||||
from vrpmdvstatusmoncmd import VRPMDV_StatusMonCmd
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class VRPMDV_StatusMonSchema(Schema):
|
||||
cmdid = fields.Integer()
|
||||
id = fields.UUID()
|
||||
|
||||
|
||||
@post_load
|
||||
def make_vrpmdv_StatusMonitoring(self, data, **kwargs):
|
||||
mon = VRPMDV_StatusMonCmd(**data)
|
||||
return mon
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user