Fawkes API  Fawkes Development Version
lase_edl_aqt.h
1 
2 /***************************************************************************
3  * lase_edl_aqt.cpp - Thread to retrieves laser data from Lase LD A OEM
4  *
5  * Created: Wed Oct 08 13:41:02 2008
6  * Copyright 2002 Christian Fritz
7  * 2008-2009 Tim Niemueller [www.niemueller.de]
8  *
9  ****************************************************************************/
10 
11 /* This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL file in the doc directory.
22  */
23 
24 #ifndef HAVE_LIBPCAN
25 # error "Cannot use Lase EDL driver without libpcan"
26 #endif
27 
28 #ifndef __PLUGINS_LASER_LASE_EDL_AQT_H_
29 #define __PLUGINS_LASER_LASE_EDL_AQT_H_
30 
31 #include "acquisition_thread.h"
32 
33 #include <libpcan.h>
34 #include <string>
35 
37 {
38  public:
39  LaseEdlAcquisitionThread(std::string &cfg_name, std::string &cfg_prefix);
40 
41  // from LaserAcquisitionThread
43 
44  virtual void init();
45  virtual void finalize();
46  virtual void loop();
47 
48  private:
49  static const WORD RESETLEVEL_RESET;
50  static const WORD RESETLEVEL_RESTART;
51  static const WORD RESETLEVEL_HALT_IDLE;
52  static const WORD RESETLEVEL_RELOAD_VOLTSET;
53  static const WORD CONFIGITEM_ARCNET_HISTORIC;
54  static const WORD CONFIGITEM_RS232_RS422;
55  static const WORD CONFIGITEM_CAN;
56  static const WORD CONFIGITEM_SPI;
57  static const WORD CONFIGITEM_ARCNET;
58  static const WORD CONFIGITEM_GLOBAL;
59  static const WORD CONFIGDATA_LENGTH_RS232_RS422;
60  static const WORD CONFIGDATA_LENGTH_CAN;
61  static const WORD CONFIGDATA_LENGTH_ARCNET;
62  static const WORD CONFIGDATA_LENGTH_GLOBAL;
63  static const WORD SECTOR_0;
64  static const WORD SECTOR_1;
65  static const WORD SECTOR_2;
66  static const WORD SECTOR_3;
67  static const WORD SECTOR_4;
68  static const WORD SECTOR_5;
69  static const WORD SECTOR_6;
70  static const WORD SECTOR_7;
71  static const WORD SECTORFUNC_NOT_INITIALIZED;
72  static const WORD SECTORFUNC_NO_MEASUREMENT;
73  static const WORD SECTORFUNC_DUMMY_MEASUREMENT;
74  static const WORD SECTORFUNC_NORMAL_MEASUREMENT;
75  static const WORD SECTORFUNC_REFERENCE_TARGET;
76  static const WORD FLASH_YES;
77  static const WORD FLASH_NO;
78  static const WORD PROFILENUM_CONTINUOUS;
79  static const WORD PROFILEFORMAT_NUMBER;
80  static const WORD PROFILEFORMAT_COUNTER;
81  static const WORD PROFILEFORMAT_LAYER;
82  static const WORD PROFILEFORMAT_SECTOR;
83  static const WORD PROFILEFORMAT_ANGLE_STEP;
84  static const WORD PROFILEFORMAT_NUM_SECT_POINTS;
85  static const WORD PROFILEFORMAT_TIMESTAMP_START;
86  static const WORD PROFILEFORMAT_START_DIRECTION;
87  static const WORD PROFILEFORMAT_DISTANCE;
88  static const WORD PROFILEFORMAT_DIRECTION;
89  static const WORD PROFILEFORMAT_ECHO_AMPLITUDE;
90  static const WORD PROFILEFORMAT_TIMESTAMP_END;
91  static const WORD PROFILEFORMAT_END_DIRECTION;
92  static const WORD PROFILEFORMAT_SENSOR_MODE;
93  static const WORD SERVICEGROUP_STATUS;
94  static const WORD CMD_GET_IDENTIFICATION;
95  static const WORD CMD_GET_STATUS;
96  static const WORD CMD_GET_ERROR;
97  static const WORD CMD_GET_SIGNAL;
98  static const WORD CMD_SET_SIGNAL;
99  static const WORD CMD_REGISTER_APPLICATION;
100  static const WORD SERVICEGROUP_CONFIG;
101  static const WORD CMD_SET_CONFIG;
102  static const WORD CMD_GET_CONFIG;
103  static const WORD CMD_SET_SYNC_ABS;
104  static const WORD CMD_SET_SYNC_REL;
105  static const WORD CMD_SET_SYNC_CLOCK;
106  static const WORD CMD_SET_ZONE;
107  static const WORD CMD_GET_ZONE;
108  static const WORD CMD_RELEASE_ZONE;
109  static const WORD CMD_SET_FILTER;
110  static const WORD CMD_SET_FUNCTION;
111  static const WORD CMD_GET_FUNCTION;
112  static const WORD SERVICEGROUP_MEASUREMENT;
113  static const WORD CMD_GET_PROFILE;
114  static const WORD CMD_CANCEL_PROFILE;
115  static const WORD SERVICEGROUP_WORKING;
116  static const WORD CMD_DO_RESET;
117  static const WORD CMD_TRANS_IDLE;
118  static const WORD CMD_TRANS_ROTATE;
119  static const WORD CMD_TRANS_MEASURE;
120  static const WORD SERVICEGROUP_MAINTENANCE;
121  static const WORD CMD_DO_ADJUST;
122  static const WORD CMD_DO_TEST;
123  static const WORD SERVICEGROUP_INTERFACE_ROUTING;
124  static const WORD CMD_COM_ATTACH;
125  static const WORD CMD_COM_DETACH;
126  static const WORD CMD_COM_INIT;
127  static const WORD CMD_COM_OUTPUT;
128  static const WORD CMD_COM_DATA;
129  static const WORD SERVICEGROUP_FILE;
130  static const WORD CMD_DIR;
131  static const WORD CMD_SAVE;
132  static const WORD CMD_LOAD;
133  static const WORD CMD_DELETE;
134  static const WORD SERVICEGROUP_MONITOR;
135  static const WORD CMD_MONITOR_ENABLE_LOG;
136  static const WORD CMD_MONITOR_DISABLE_LOG;
137  //static const WORD SERVICEGROUP_APPLICATION; 0x1000 to 0x3F00
138  static const WORD SERVICEGROUP_ADJUST;
139  static const WORD SERVICEGROUP_SPECIAL;
140  static const WORD CMD_SERVICE_FAILURE;
141  static const WORD RESPONSE_BIT;
142  static const float DISTANCE_FACTOR;
143 
144  private:
145  unsigned int calc_angle_step(unsigned int rotation_freq, unsigned int max_pulse_freq);
146  inline WORD respcode(WORD cmd) { return cmd | RESPONSE_BIT; }
147  void init_bus();
148  void send(WORD *data, int n);
149  int recv(WORD **data, bool allocate = true);
150 
151  void send_and_check(WORD *command_data, int command_length,
152  WORD *expected_response, int n,
153  WORD **real_response = NULL, int *response_size = NULL);
154 
155  inline void append_to_msg(WORD word, TPCANMsg *msg);
156  inline void append_to_msg(BYTE byte, TPCANMsg *msg);
157  inline WORD get_word_from_msg(TPCANMsg *msg, int *index);
158  WORD * make_word_array(int count, ...);
159  int compare_word_arrays(int count, WORD* a, WORD* b);
160  void print_word_array(int count, WORD* a);
161  void print_message(TPCANMsg *m);
162 
163  void process_profiles();
164 
165  void SET_CONFIG(WORD config_item, int k, ...);
166  void SET_FUNCTION(WORD sect_num, WORD sect_func, WORD sect_stop, WORD flash);
167  void GET_PROFILE(WORD prof_num, WORD prof_format);
168  void CANCEL_PROFILE();
169  void DO_RESET(WORD reset_level);
170  void TRANS_IDLE();
171  void TRANS_ROTATE(WORD frequency);
172  void TRANS_MEASURE();
173 
174 
175 
176  private:
177  HANDLE __handle;
178  bool __pre_init_done;
179 
180  std::string __cfg_name;
181  std::string __cfg_prefix;
182 
183  bool __cfg_use_default;
184  bool __cfg_set_default;
185  unsigned int __cfg_rotation_freq;
186  unsigned int __cfg_angle_step;
187  unsigned int __cfg_max_pulse_freq;
188  unsigned int __cfg_profile_format;
189  unsigned int __cfg_can_id;
190  unsigned int __cfg_can_id_resp;
191  unsigned int __cfg_sensor_id;
192  unsigned int __cfg_sensor_id_resp;
193  unsigned int __cfg_interface_type;
194  unsigned int __cfg_btr0btr1;
195  unsigned int __cfg_port;
196  unsigned int __cfg_irq;
197  unsigned int __cfg_num_init_tries;
198  float __cfg_mount_rotation;
199 
200  unsigned int __min_angle_step;
201  unsigned int __number_of_values;
202 
203 };
204 
205 
206 #endif
Laser acqusition thread for Lase EDL L A laser scanner.
Definition: lase_edl_aqt.h:36
LaseEdlAcquisitionThread(std::string &cfg_name, std::string &cfg_prefix)
Constructor.
Laser acqusition thread.
Logger * logger
This is the Logger member used to access the logger.
Definition: logging.h:44
virtual void loop()
Code to execute in the thread.
virtual void pre_init(fawkes::Configuration *config, fawkes::Logger *logger)
Pre initialization.
virtual void finalize()
Finalize the thread.
Configuration * config
This is the Configuration member used to access the configuration.
Definition: configurable.h:44
Interface for configuration handling.
Definition: config.h:67
virtual void init()
Initialize the thread.
Interface for logging.
Definition: logger.h:34