sys_stat.cpp
Go to the documentation of this file.
1 /*********************************************************************
2 * FSRobo-R Package BSDL
3 * ---------
4 * Copyright (C) 2019 FUJISOFT. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without modification,
7 * are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation and/or
12 * other materials provided with the distribution.
13 * 3. Neither the name of the copyright holder nor the names of its contributors
14 * may be used to endorse or promote products derived from this software without
15 * specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
21 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *********************************************************************/
28 
32 #include <vector>
33 
35 using std::vector;
36 
37 namespace fsrobo_r_driver
38 {
39 namespace simple_message
40 {
41 namespace sys_stat
42 {
43 
45 {
46  this->init();
47 }
48 
50 {
51 }
52 
54 {
55  // TODO: is '0' a good initial value?
56  this->init(0, 0);
57 }
58 
59 void SysStat::init(shared_int stat_type, shared_int result)
60 {
61  this->setStatType(stat_type);
62  this->setResult(result);
63 }
64 
66 {
67  this->setStatType(src.getStatType());
68  this->setResult(src.getResult());
69 }
70 
72 {
73  bool rslt = this->stat_type_ == rhs.stat_type_ &&
74  this->result_ == rhs.result_;
75 
76  return rslt;
77 }
78 
80 {
81  LOG_COMM("Executing SysStat command load");
82 
83  if (!buffer->load(this->stat_type_))
84  {
85  LOG_ERROR("Failed to load SysStat stat type");
86  return false;
87  }
88 
89  if (!buffer->load(this->result_))
90  {
91  LOG_ERROR("Failed to load SysStat result");
92  return false;
93  }
94 
95  LOG_COMM("SysStat data successfully loaded");
96  return true;
97 }
98 
100 {
101  LOG_COMM("Executing SysStat command unload");
102 
103  if (!buffer->unload(this->result_))
104  {
105  LOG_ERROR("Failed to unload SysStat result");
106  return false;
107  }
108 
109  if (!buffer->unload(this->stat_type_))
110  {
111  LOG_ERROR("Failed to unload SysStat stat type");
112  return false;
113  }
114 
115  LOG_COMM("SysStat data successfully unloaded");
116  return true;
117 }
118 
119 }
120 }
121 }
bool unload(industrial::byte_array::ByteArray *buffer)
Definition: sys_stat.cpp:99
void setResult(industrial::shared_types::shared_int result)
Sets result.
Definition: sys_stat.h:124
industrial::shared_types::shared_int stat_type_
Value of SysStat element.
Definition: sys_stat.h:175
void init()
Initializes a empty write single io command.
Definition: sys_stat.cpp:53
#define LOG_COMM(format,...)
bool load(industrial::shared_types::shared_bool value)
#define LOG_ERROR(format,...)
industrial::shared_types::shared_int getResult()
Returns the value of the SysStat element.
Definition: sys_stat.h:144
void setStatType(industrial::shared_types::shared_int stat_type)
Sets stat type.
Definition: sys_stat.h:114
bool load(industrial::byte_array::ByteArray *buffer)
Definition: sys_stat.cpp:79
industrial::shared_types::shared_int getStatType()
Returns the value of the SysStat element.
Definition: sys_stat.h:134
void copyFrom(SysStat &src)
Copies the passed in value.
Definition: sys_stat.cpp:65
bool operator==(SysStat &rhs)
== operator implementation
Definition: sys_stat.cpp:71
bool unload(industrial::shared_types::shared_bool &value)
Class encapsulated write single io data. FSRobo-R specific interface to set IO element on the control...
Definition: sys_stat.h:81
industrial::shared_types::shared_int result_
Address of SysStat element.
Definition: sys_stat.h:180


fsrobo_r_driver
Author(s): F-ROSROBO
autogenerated on Sun Feb 9 2020 03:58:29