1 #ifndef CNOID_BODY_DIGITAL_IO_DEVICE_H
2 #define CNOID_BODY_DIGITAL_IO_DEVICE_H
6 #include "exportdecl.h"
18 virtual const char* typeName()
const override;
20 virtual void copyStateFrom(
const DeviceState& other)
override;
22 virtual void forEachActualType(std::function<
bool(
const std::type_info& type)> func)
override;
23 virtual int stateSize()
const override;
24 virtual const double* readState(
const double* buf)
override;
25 virtual double* writeState(
double* out_buf)
const override;
27 virtual bool on()
const override;
28 virtual void on(
bool on)
override;
31 void setNumSignalLines(
int n);
33 bool out(
int index)
const {
return out_[index]; }
34 void setOut(
int index,
bool on,
bool doNotify =
true);
35 bool in(
int index)
const {
return in_[index]; }
36 void setIn(
int index,
bool on,
bool doNotify =
true);
38 const std::string& outLabel(
int index)
const;
39 void setOutLabel(
int index,
const std::string& label);
40 std::vector<std::pair<int, std::string&>> getOutLabels()
const;
41 const std::string& inLabel(
int index)
const;
42 void setInLabel(
int index,
const std::string& label);
43 std::vector<std::pair<int, std::string&>> getInLabels()
const;
48 bool readDescription(
const Mapping* info);
49 bool readSpecifications(
const Mapping* info);
50 bool readConfiguration(
const Mapping* info);
51 bool writeDescription(
Mapping* info)
const;
52 bool writeSpecifications(
Mapping* info)
const;
53 bool writeConfiguration(
Mapping* info)
const;
56 void setInputToDeviceSwitchConnection(
int inputIndex,
const std::string& deviceName);
57 std::vector<std::pair<int, std::string&>> getInputToDeviceSwitchConnections()
const;
58 void removeInputToDeviceSwitchConnection(
int inputIndex);
59 void clearInputToDeviceSwitchConnections();
60 bool readInputToDeviceSwitchConnections(
const Mapping& archive);
67 std::vector<bool> out_;
68 std::vector<bool> in_;