YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
SystemInfoSerializer.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
8
11#include <yarp/os/SystemInfo.h>
12
13using namespace yarp::os;
14
15
38
40 memory(SystemInfo::MemoryInfo{0, 0}),
41 storage(SystemInfo::StorageInfo{0, 0}),
42 load(SystemInfo::LoadInfo{.0, .0, .0, 0}),
43 mPriv(new Private(this))
44{
45}
46
51
53{
54 // reading memory
55 memory.totalSpace = connection.expectInt32();
56 memory.freeSpace = connection.expectInt32();
57
58 // reading storage
59 storage.totalSpace = connection.expectInt32();
60 storage.freeSpace = connection.expectInt32();
61
62 // reading network
63 //network.mac = connection.expectText();
64 //network.ip4 = connection.expectText();
65 //network.ip6 = connection.expectText();
66
67 // reading processor
68 processor.architecture = connection.expectText();
69 processor.model = connection.expectText();
70 processor.vendor = connection.expectText();
71 processor.family = connection.expectInt32();
72 processor.modelNumber = connection.expectInt32();
73 processor.cores = connection.expectInt32();
74 processor.siblings = connection.expectInt32();
75 processor.frequency = connection.expectFloat64();
76
77 // reading load
78 load.cpuLoad1 = connection.expectFloat64();
79 load.cpuLoad5 = connection.expectFloat64();
80 load.cpuLoad15 = connection.expectFloat64();
81 load.cpuLoadInstant = connection.expectInt32();
82
83 // reading platform
84 platform.name = connection.expectText();
85 platform.distribution = connection.expectText();
86 platform.release = connection.expectText();
87 platform.codename = connection.expectText();
88 platform.kernel = connection.expectText();
90
91 // reading user
92 user.userName = connection.expectText();
93 user.realName = connection.expectText();
94 user.homeDir = connection.expectText();
95 user.userID = connection.expectInt32();
96 return true;
97}
98
99
101{
102 mPriv->updateSystemInfo();
103
104 // serializing memory
105 connection.appendInt32(memory.totalSpace);
106 connection.appendInt32(memory.freeSpace);
107
108 // serializing storage
109 connection.appendInt32(storage.totalSpace);
110 connection.appendInt32(storage.freeSpace);
111
112 // serializing network
113 //connection.appendText(network.mac);
114 //connection.appendText(network.ip4);
115 //connection.appendText(network.ip6);
116
117 // serializing processor
119 connection.appendText(processor.model);
120 connection.appendText(processor.vendor);
121 connection.appendInt32(processor.family);
122 connection.appendInt32(processor.modelNumber);
123 connection.appendInt32(processor.cores);
124 connection.appendInt32(processor.siblings);
125 connection.appendFloat64(processor.frequency);
126
127 // serializing load
128 connection.appendFloat64(load.cpuLoad1);
129 connection.appendFloat64(load.cpuLoad5);
130 connection.appendFloat64(load.cpuLoad15);
131 connection.appendInt32(load.cpuLoadInstant);
132
133 // serializing platform
134 connection.appendText(platform.name);
135 connection.appendText(platform.distribution);
136 connection.appendText(platform.release);
137 connection.appendText(platform.codename);
138 connection.appendText(platform.kernel);
140
141 // serializing user
142 connection.appendText(user.userName);
143 connection.appendText(user.realName);
144 connection.appendText(user.homeDir);
145 connection.appendInt32(user.userID);
146
147 return !connection.isError();
148}
A mini-server for performing network communication in the background.
An interface for reading from a network connection.
An interface for writing to a network connection.
std::string toString() const override
Return a standard text representation of the content of the object.
void fromString(const std::string &txt, bool wipe=true)
Interprets a string as a list of properties.
A helper class to pass the SystemInfo object around the YARP network.
yarp::os::SystemInfo::LoadInfo load
current cpu load information
bool read(yarp::os::ConnectionReader &connection) override
reads from a ConnectionReader and fill into the SystemInfo structs.
yarp::os::SystemInfo::UserInfo user
current user information
virtual ~SystemInfoSerializer()
~SystemInfoSerializer deconstructor
yarp::os::SystemInfo::StorageInfo storage
system storage information
bool write(yarp::os::ConnectionWriter &connection) const override
write the SystemInfo structs using a ConnectionWriter.
yarp::os::SystemInfo::PlatformInfo platform
operating system information
SystemInfoSerializer()
SystemInfoSerializer constructor.
yarp::os::SystemInfo::MemoryInfo memory
system memory information
yarp::os::SystemInfo::ProcessorInfo processor
system processor type information
A class to get the system (platform) status such as available memory, storage, CPU load and etc.
Definition SystemInfo.h:25
static MemoryInfo getMemoryInfo()
getMemoryInfo
static PlatformInfo getPlatformInfo()
getPlatformInfo
static UserInfo getUserInfo()
getUserInfo
static LoadInfo getLoadInfo()
getLoadInfo
static StorageInfo getStorageInfo()
getStorageInfo
static ProcessorInfo getProcessorInfo()
getProcessorInfo
An interface to the operating system, including Port based communication.
yarp::os::Property environmentVars
Definition SystemInfo.h:86