3131
3232#define TOTAL_BYTES_IN_FIELD " total_bytes_in"
3333#define TOTAL_BYTES_OUT_FIELD " total_bytes_out"
34+ #define COST_FIELD " cost"
3435
3536namespace fastotv {
3637namespace commands_info {
@@ -49,7 +50,8 @@ MachineInfo::MachineInfo()
4950 current_ts_(0 ),
5051 uptime_(0 ),
5152 net_total_bytes_recv_(0 ),
52- net_total_bytes_send_(0 ) {}
53+ net_total_bytes_send_(0 ),
54+ cost_(0 ) {}
5355
5456MachineInfo::MachineInfo (cpu_load_t cpu_load,
5557 gpu_load_t gpu_load,
@@ -63,7 +65,8 @@ MachineInfo::MachineInfo(cpu_load_t cpu_load,
6365 time_t uptime,
6466 fastotv::timestamp_t timestamp,
6567 size_t net_total_bytes_recv,
66- size_t net_total_bytes_send)
68+ size_t net_total_bytes_send,
69+ cost_t cost)
6770 : base_class(),
6871 cpu_load_(cpu_load),
6972 gpu_load_(gpu_load),
@@ -77,7 +80,8 @@ MachineInfo::MachineInfo(cpu_load_t cpu_load,
7780 current_ts_(timestamp),
7881 uptime_(uptime),
7982 net_total_bytes_recv_(net_total_bytes_recv),
80- net_total_bytes_send_(net_total_bytes_send) {}
83+ net_total_bytes_send_(net_total_bytes_send),
84+ cost_(cost) {}
8185
8286common::Error MachineInfo::SerializeFields (json_object* out) const {
8387 ignore_result (SetDoubleField (out, CPU_FIELD, cpu_load_));
@@ -93,6 +97,7 @@ common::Error MachineInfo::SerializeFields(json_object* out) const {
9397 ignore_result (SetInt64Field (out, TIMESTAMP_FIELD, current_ts_));
9498 ignore_result (SetUInt64Field (out, TOTAL_BYTES_IN_FIELD, net_total_bytes_recv_));
9599 ignore_result (SetUInt64Field (out, TOTAL_BYTES_OUT_FIELD, net_total_bytes_send_));
100+ ignore_result (SetDoubleField (out, COST_FIELD, cost_));
96101 return common::Error ();
97102}
98103
@@ -136,9 +141,12 @@ common::Error MachineInfo::DoDeSerialize(json_object* serialized) {
136141 uint64_t net_total_bytes_send = 0 ;
137142 ignore_result (GetUint64Field (serialized, TOTAL_BYTES_OUT_FIELD, &net_total_bytes_send));
138143
144+ cost_t cost = 0 ;
145+ ignore_result (GetDoubleField (serialized, COST_FIELD, &cost));
146+
139147 *this =
140148 MachineInfo (cpu_load, gpu_load, load_average, ram_bytes_total, ram_bytes_free, hdd_bytes_total, hdd_bytes_free,
141- net_bytes_recv, net_bytes_send, uptime, current_ts, net_total_bytes_recv, net_total_bytes_send);
149+ net_bytes_recv, net_bytes_send, uptime, current_ts, net_total_bytes_recv, net_total_bytes_send, cost );
142150 return common::Error ();
143151}
144152
@@ -194,13 +202,18 @@ size_t MachineInfo::GetNetTotalBytesSend() const {
194202 return net_total_bytes_send_;
195203}
196204
205+ MachineInfo::cost_t MachineInfo::GetCost () const {
206+ return cost_;
207+ }
208+
197209bool MachineInfo::Equals (const MachineInfo& mach) const {
198210 return mach.cpu_load_ == cpu_load_ && mach.gpu_load_ == gpu_load_ && mach.load_average_ == load_average_ &&
199211 mach.ram_bytes_total_ == ram_bytes_total_ && mach.ram_bytes_free_ == ram_bytes_free_ &&
200212 mach.hdd_bytes_total_ == hdd_bytes_total_ && mach.hdd_bytes_free_ == hdd_bytes_free_ &&
201213 mach.net_bytes_recv_ == net_bytes_recv_ && mach.net_bytes_send_ == net_bytes_send_ &&
202214 mach.uptime_ == uptime_ && mach.current_ts_ == current_ts_ &&
203- mach.net_total_bytes_recv_ == net_total_bytes_recv_ && mach.net_total_bytes_send_ == net_total_bytes_send_;
215+ mach.net_total_bytes_recv_ == net_total_bytes_recv_ && mach.net_total_bytes_send_ == net_total_bytes_send_ &&
216+ mach.cost_ == cost_;
204217}
205218
206219} // namespace commands_info
0 commit comments