Robotics Library  0.7.0
MitsubishiR3.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2009, Markus Rickert
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 //
8 // * Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright notice,
11 // this list of conditions and the following disclaimer in the documentation
12 // and/or other materials provided with the distribution.
13 //
14 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
18 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 // POSSIBILITY OF SUCH DAMAGE.
25 //
26 
27 #ifndef RL_HAL_MITSUBISHIR3_H
28 #define RL_HAL_MITSUBISHIR3_H
29 
30 #include <array>
31 #include <cstdint>
32 #include <string>
33 
34 #include "Com.h"
35 #include "ComException.h"
36 #include "Socket.h"
37 
38 namespace rl
39 {
40  namespace hal
41  {
45  class MitsubishiR3 : public Com
46  {
47  public:
48  enum HandSts
49  {
54  HANDSTS_CLOSED = 2
55  };
56 
57  enum HandType
58  {
63  HANDTYPE_DOUBLE = 1
64  };
65 
66  enum TaskCond
67  {
74  };
75 
76  struct EditSts
77  {
79  bool isEditing;
81  bool isRunning;
83  bool isChanged;
84  };
85 
86  class Exception : public ComException
87  {
88  public:
89  Exception(const int& errorNo, const ::std::string& what_arg);
90 
91  virtual ~Exception() throw();
92 
93  int getErrorNo() const;
94 
95  protected:
96 
97  private:
98  int errorNo;
99  };
100 
101  struct Hand
102  {
104  int outputNo;
109  };
110 
112  typedef bool MechInfo[3];
113 
114  struct RunSts
115  {
117  bool isRepeat;
121  bool isMlockOn;
123  bool isTeach;
127  bool isServoOn;
129  bool isRun;
132  };
133 
134  struct StopSts
135  {
137  bool isEmgStop;
139  bool isStop;
141  bool isWait;
147  bool isReserve;
150  };
151 
152  struct CalibState
153  {
155  bool isDefined;
157  bool isAxis[8];
158  };
159 
160  struct RunState
161  {
163  char programName[256];
165  int lineNo;
167  int override;
175  int errorNo;
177  int stepNo;
181  char taskPrgName[256];
187  int taskPri;
189  int mechNo;
190  };
191 
193  {
195  bool isTb;
197  bool isPc;
199  bool isIo;
201  bool isOp;
203  bool isIoEmg;
205  bool isOpEmg;
207  bool isTbEmg;
208  };
209 
210  struct StopState
211  {
217  int errorNo;
219  int stepNo;
221  int mechNo;
222  };
223 
224  MitsubishiR3(
225  const ::std::string& address,
226  const unsigned short int& port = 10001
227  );
228 
229  virtual ~MitsubishiR3();
230 
231  void close();
232 
238  void doCalib(CalibState& state);
239 
248  void doCntl(const bool& doOn);
249 
261  void doDatinst(const ::std::string& j1, const ::std::string& j2, const ::std::string& j3, const ::std::string& j4, const ::std::string& j5, const ::std::string& j6, const ::std::string& checksum);
262 
277  void doDatinst(const ::std::string& j1, const ::std::string& j2, const ::std::string& j3, const ::std::string& j4, const ::std::string& j5, const ::std::string& j6, const ::std::string& j7, const ::std::string& j8, const ::std::string& checksum);
278 
285 
291  void doEclr();
292 
300  void doEmdat(const ::std::string& program);
301 
308  ::std::string doErrormes(const int& errorNo);
309 
315  void doExec(const ::std::string& instruction);
316 
323  void doHnd(const bool& doOpen, const int& handNo);
324 
330  ::std::array<Hand, 8> doHndsts();
331 
338  void doInEquals(const ::std::size_t& inNo, const ::std::string& inVal);
339 
345  void doLoad(const ::std::string& programName);
346 
350  void doNew();
351 
358  void doOutEquals(const ::std::size_t& outNo, const ::std::string& outVal);
359 
363  void doRstalrm();
364 
368  void doRstpwr();
369 
376  void doRun(const ::std::string& programName, const bool& doModeCycle = false);
377 
381  void doSave();
382 
386  void doSlotinit();
387 
393  void doSrv(const bool& doOn);
394 
400  RunState doState();
401 
405  void doStop();
406 
413 
414  void loadProgram(const ::std::string& name, const ::std::string& program);
415 
416  void open();
417 
418  void startProgram(const ::std::string& name);
419 
420  void stopProgram();
421 
422  protected:
423 
424  private:
426  };
427  }
428 }
429 
430 #endif // RL_HAL_MITSUBISHIR3_H
rl::hal::MitsubishiR3::doRun
void doRun(const ::std::string &programName, const bool &doModeCycle=false)
The program is started.
Definition: MitsubishiR3.cpp:616
rl::hal::MitsubishiR3::StopSignalState::isTb
bool isTb
T/B (RS-422).
Definition: MitsubishiR3.h:195
rl::hal::MitsubishiR3::doInEquals
void doInEquals(const ::std::size_t &inNo, const ::std::string &inVal)
The input signal is pseudo-input.
Definition: MitsubishiR3.cpp:517
rl::hal::MitsubishiR3::StopSignalState::isPc
bool isPc
P/C (RS-232C).
Definition: MitsubishiR3.h:197
rl::hal::MitsubishiR3::HANDTYPE_NOTUSED
@ HANDTYPE_NOTUSED
Definition: MitsubishiR3.h:59
rl::hal::MitsubishiR3::CalibState::isDefined
bool isDefined
Install status.
Definition: MitsubishiR3.h:155
rl::hal::Socket
Definition: Socket.h:48
rl::hal::MitsubishiR3::HANDTYPE_DOUBLE
@ HANDTYPE_DOUBLE
Double-solenoid.
Definition: MitsubishiR3.h:63
rl::hal::MitsubishiR3::doStpsig
StopSignalState doStpsig()
The state of the stop signal is read.
Definition: MitsubishiR3.cpp:872
rl::hal::MitsubishiR3::Hand::handSts
HandSts handSts
Hand output status.
Definition: MitsubishiR3.h:106
rl::hal::MitsubishiR3::RunSts::isServoOn
bool isServoOn
Servo OFF / Servo ON.
Definition: MitsubishiR3.h:127
rl::hal::MitsubishiR3::StopSignalState::isOp
bool isOp
O/P.
Definition: MitsubishiR3.h:201
rl::hal::MitsubishiR3::RunState::mechInfo
MechInfo mechInfo
Mech info.
Definition: MitsubishiR3.h:179
rl::hal::MitsubishiR3::Exception::errorNo
int errorNo
Definition: MitsubishiR3.h:98
rl::hal::MitsubishiR3::TASKCOND_ERROR
@ TASKCOND_ERROR
ERROR.
Definition: MitsubishiR3.h:73
rl::hal::MitsubishiR3::RunState::programName
char programName[256]
Program name loaded into task slot.
Definition: MitsubishiR3.h:163
rl::hal::MitsubishiR3::doLoad
void doLoad(const ::std::string &programName)
Open the program for edit.
Definition: MitsubishiR3.cpp:535
rl::hal::MitsubishiR3::loadProgram
void loadProgram(const ::std::string &name, const ::std::string &program)
Definition: MitsubishiR3.cpp:943
Com.h
rl::hal::MitsubishiR3::HandSts
HandSts
Definition: MitsubishiR3.h:49
rl::hal::MitsubishiR3::RunState::stopSts
StopSts stopSts
Stop status.
Definition: MitsubishiR3.h:173
rl::hal::MitsubishiR3::doDatinst
void doDatinst(const ::std::string &j1, const ::std::string &j2, const ::std::string &j3, const ::std::string &j4, const ::std::string &j5, const ::std::string &j6, const ::std::string &checksum)
The origin is set by the data input.
Definition: MitsubishiR3.cpp:133
rl::hal::MitsubishiR3::Hand::outputNo
int outputNo
Signal number allocated in hand (-1: not used).
Definition: MitsubishiR3.h:104
rl::hal::MitsubishiR3::HANDSTS_CLOSED
@ HANDSTS_CLOSED
Hand closed.
Definition: MitsubishiR3.h:54
rl::hal::MitsubishiR3::MitsubishiR3
MitsubishiR3(const ::std::string &address, const unsigned short int &port=10001)
Definition: MitsubishiR3.cpp:47
rl::hal::MitsubishiR3::EditSts::isChanged
bool isChanged
Changed.
Definition: MitsubishiR3.h:83
rl::hal::MitsubishiR3::StopSts::isPseudoInput
bool isPseudoInput
Pseudo input.
Definition: MitsubishiR3.h:149
rl::hal::MitsubishiR3::RunState::taskPrgName
char taskPrgName[256]
Program name of slot table.
Definition: MitsubishiR3.h:181
rl::hal::MitsubishiR3::EditSts::isEditing
bool isEditing
Editing.
Definition: MitsubishiR3.h:79
rl::hal::MitsubishiR3::StopSignalState
Definition: MitsubishiR3.h:193
rl::hal::MitsubishiR3::RunSts::isOperationEnable
bool isOperationEnable
Operation disable / Operation enable.
Definition: MitsubishiR3.h:131
rl::hal::MitsubishiR3::StopSignalState::isTbEmg
bool isTbEmg
T/B EMG.
Definition: MitsubishiR3.h:207
rl::hal::MitsubishiR3::StopState
Definition: MitsubishiR3.h:211
rl::hal::MitsubishiR3::doRstalrm
void doRstalrm()
The error is reset.
Definition: MitsubishiR3.cpp:586
rl::hal::MitsubishiR3::RunState::taskPri
int taskPri
Priority of slot table (1 - 31).
Definition: MitsubishiR3.h:187
rl::hal::MitsubishiR3::startProgram
void startProgram(const ::std::string &name)
Definition: MitsubishiR3.cpp:961
rl::hal::MitsubishiR3::StopState::errorNo
int errorNo
Error number (0: no error).
Definition: MitsubishiR3.h:217
rl::hal::MitsubishiR3::StopSignalState::isIoEmg
bool isIoEmg
I/O EMG.
Definition: MitsubishiR3.h:203
rl::hal::MitsubishiR3::HANDSTS_NOTUSED
@ HANDSTS_NOTUSED
Definition: MitsubishiR3.h:50
rl::hal::MitsubishiR3::RunState::taskCond
TaskCond taskCond
Stating conditions of slot table.
Definition: MitsubishiR3.h:185
rl::hal::MitsubishiR3::StopSts::isStop
bool isStop
STOP.
Definition: MitsubishiR3.h:139
rl::hal::MitsubishiR3::stopProgram
void stopProgram()
Definition: MitsubishiR3.cpp:970
rl::hal::MitsubishiR3::doHndsts
::std::array< Hand, 8 > doHndsts()
The setting and the output of the hand are read.
Definition: MitsubishiR3.cpp:429
rl::hal::MitsubishiR3::Exception::getErrorNo
int getErrorNo() const
Definition: MitsubishiR3.cpp:986
rl::hal::MitsubishiR3::RunState::errorNo
int errorNo
Error number (0: no error).
Definition: MitsubishiR3.h:175
rl::hal::MitsubishiR3::HANDSTS_OPEN
@ HANDSTS_OPEN
Hand open.
Definition: MitsubishiR3.h:52
rl::hal::MitsubishiR3::StopSts::isProgramSelectEnable
bool isProgramSelectEnable
Program select enable.
Definition: MitsubishiR3.h:145
rl::hal::MitsubishiR3::RunSts::isRun
bool isRun
STOP / RUN.
Definition: MitsubishiR3.h:129
rl::hal::MitsubishiR3::doExec
void doExec(const ::std::string &instruction)
The instruction is executed directly.
Definition: MitsubishiR3.cpp:391
rl::hal::MitsubishiR3::RunSts::isCycleStopOff
bool isCycleStopOff
Cycle stop ON / Cycle stop OFF.
Definition: MitsubishiR3.h:119
rl::hal::MitsubishiR3::Exception::~Exception
virtual ~Exception()
Definition: MitsubishiR3.cpp:981
rl::hal::MitsubishiR3::StopSts::isEmgStop
bool isEmgStop
EMG STOP.
Definition: MitsubishiR3.h:137
rl::hal::MitsubishiR3::RunState
Definition: MitsubishiR3.h:161
rl::hal::MitsubishiR3::StopState::runSts
RunSts runSts
Run status.
Definition: MitsubishiR3.h:213
rl::hal::MitsubishiR3::doErrormes
::std::string doErrormes(const int &errorNo)
The content of the error is read.
Definition: MitsubishiR3.cpp:371
rl::hal::MitsubishiR3::doCntl
void doCntl(const bool &doOn)
Operation enable or disable.
Definition: MitsubishiR3.cpp:115
rl::hal::MitsubishiR3::doEclr
void doEclr()
Clear program contents.
Definition: MitsubishiR3.cpp:273
rl::hal::MitsubishiR3::doSlotinit
void doSlotinit()
The program resets all slots.
Definition: MitsubishiR3.cpp:649
rl::hal::MitsubishiR3::doNew
void doNew()
The program is closed annulling the content of the edit.
Definition: MitsubishiR3.cpp:553
rl::hal::MitsubishiR3::EditSts::isRunning
bool isRunning
Running.
Definition: MitsubishiR3.h:81
rl::hal::MitsubishiR3::RunState::stepNo
int stepNo
Execution step number.
Definition: MitsubishiR3.h:177
rl::hal::MitsubishiR3::TaskCond
TaskCond
Definition: MitsubishiR3.h:67
rl::hal::MitsubishiR3::StopSts::isReserve
bool isReserve
(reserve).
Definition: MitsubishiR3.h:147
rl::hal::MitsubishiR3::CalibState::isAxis
bool isAxis[8]
Completion axis pattern (J1, J2, J3, J4, J5, J6, J7, J8).
Definition: MitsubishiR3.h:157
rl::hal::MitsubishiR3::HANDTYPE_SINGLE
@ HANDTYPE_SINGLE
Single-solenoid.
Definition: MitsubishiR3.h:61
rl::hal::MitsubishiR3::MechInfo
bool MechInfo[3]
Mech info (Mech 1, Mech 2, Mech 3).
Definition: MitsubishiR3.h:112
rl::hal::MitsubishiR3::doEmdat
void doEmdat(const ::std::string &program)
More line and position are registered in the program.
Definition: MitsubishiR3.cpp:288
rl::hal::MitsubishiR3::Exception::Exception
Exception(const int &errorNo, const ::std::string &what_arg)
Definition: MitsubishiR3.cpp:975
rl::hal::MitsubishiR3::RunState::editSts
EditSts editSts
Edit status.
Definition: MitsubishiR3.h:169
rl::hal::MitsubishiR3::doSave
void doSave()
The content of the edit is preserved and the program is closed.
Definition: MitsubishiR3.cpp:634
rl::hal::MitsubishiR3::socket
Socket socket
Definition: MitsubishiR3.h:425
rl::hal::MitsubishiR3::~MitsubishiR3
virtual ~MitsubishiR3()
Definition: MitsubishiR3.cpp:56
rl::hal::MitsubishiR3::StopSignalState::isIo
bool isIo
I/O.
Definition: MitsubishiR3.h:199
rl::hal::MitsubishiR3::TASKCOND_START
@ TASKCOND_START
START.
Definition: MitsubishiR3.h:69
rl::hal::Com
Definition: Com.h:35
rl::hal::MitsubishiR3::StopSignalState::isOpEmg
bool isOpEmg
O/P EMG.
Definition: MitsubishiR3.h:205
rl::hal::MitsubishiR3::doState
RunState doState()
The run state is read.
Definition: MitsubishiR3.cpp:682
rl::hal::MitsubishiR3::doCalib
void doCalib(CalibState &state)
The install status is read.
Definition: MitsubishiR3.cpp:68
rl::hal::MitsubishiR3::Hand::handType
HandType handType
Hand type.
Definition: MitsubishiR3.h:108
rl::hal::MitsubishiR3::doDstate
StopState doDstate()
The stop state is read.
Definition: MitsubishiR3.cpp:169
rl::hal::MitsubishiR3::StopState::stopSts
StopSts stopSts
Stop status.
Definition: MitsubishiR3.h:215
rl::hal::MitsubishiR3::CalibState
Definition: MitsubishiR3.h:153
rl::hal::MitsubishiR3::doRstpwr
void doRstpwr()
Power supply reset (reboot) of the controller is executed.
Definition: MitsubishiR3.cpp:601
rl::hal::MitsubishiR3::RunSts::isRepeat
bool isRepeat
Cycle / Repeat.
Definition: MitsubishiR3.h:117
ComException.h
rl::hal::MitsubishiR3
Mitsubishi Electric R3 protocol.
Definition: MitsubishiR3.h:46
rl::hal::MitsubishiR3::StopSts::isStopSignalOff
bool isStopSignalOff
STOP signal ON /OFF.
Definition: MitsubishiR3.h:143
rl::hal::MitsubishiR3::StopSts
Definition: MitsubishiR3.h:135
rl::hal::MitsubishiR3::doOutEquals
void doOutEquals(const ::std::size_t &outNo, const ::std::string &outVal)
The output signal is compelling output.
Definition: MitsubishiR3.cpp:568
rl::hal::MitsubishiR3::close
void close()
Definition: MitsubishiR3.cpp:61
rl::hal::MitsubishiR3::StopState::mechNo
int mechNo
Mech number under use.
Definition: MitsubishiR3.h:221
rl::hal::MitsubishiR3::RunSts::isMlockOn
bool isMlockOn
MLOCK OFF / MLOCK ON.
Definition: MitsubishiR3.h:121
rl::hal::MitsubishiR3::StopState::stepNo
int stepNo
Execution step number.
Definition: MitsubishiR3.h:219
rl::hal::MitsubishiR3::RunSts
Definition: MitsubishiR3.h:115
rl::hal::MitsubishiR3::doSrv
void doSrv(const bool &doOn)
The servo power supply is turned on and off.
Definition: MitsubishiR3.cpp:664
rl::hal::MitsubishiR3::RunSts::isTeachRunning
bool isTeachRunning
Running of Teach mode.
Definition: MitsubishiR3.h:125
rl::hal::MitsubishiR3::doHnd
void doHnd(const bool &doOpen, const int &handNo)
The hand is openend and closed.
Definition: MitsubishiR3.cpp:409
rl::hal::MitsubishiR3::Exception
Definition: MitsubishiR3.h:87
rl::hal::MitsubishiR3::open
void open()
Definition: MitsubishiR3.cpp:953
rl::hal::MitsubishiR3::EditSts
Definition: MitsubishiR3.h:77
rl::hal::MitsubishiR3::TASKCOND_ALWAYS
@ TASKCOND_ALWAYS
ALWAYS.
Definition: MitsubishiR3.h:71
rl::hal::MitsubishiR3::RunState::mechNo
int mechNo
Mech number under use.
Definition: MitsubishiR3.h:189
rl::hal::MitsubishiR3::Hand
Definition: MitsubishiR3.h:102
rl::hal::MitsubishiR3::RunState::runSts
RunSts runSts
Run status.
Definition: MitsubishiR3.h:171
rl::hal::MitsubishiR3::RunSts::isTeach
bool isTeach
Auto / Teach.
Definition: MitsubishiR3.h:123
Socket.h
rl::hal::MitsubishiR3::StopSts::isWait
bool isWait
WAIT.
Definition: MitsubishiR3.h:141
rl::hal::MitsubishiR3::HandType
HandType
Definition: MitsubishiR3.h:58
rl::hal::MitsubishiR3::doStop
void doStop()
The start is stopped.
Definition: MitsubishiR3.cpp:857
rl::hal::ComException
Definition: ComException.h:37
rl::hal::MitsubishiR3::RunState::isTaskModeCycle
bool isTaskModeCycle
Operation mode of slot table (REP / CYC).
Definition: MitsubishiR3.h:183
rl::hal::MitsubishiR3::RunState::lineNo
int lineNo
Execution line number.
Definition: MitsubishiR3.h:165
rl
Robotics Library.
Definition: AnalogInput.cpp:30