lase_edl_aqt.h

00001 
00002 /***************************************************************************
00003  * lase_edl_aqt.cpp - Thread to retrieves laser data from Lase LD A OEM
00004  *
00005  *  Created: Wed Oct 08 13:41:02 2008
00006  *  Copyright  2002       Christian Fritz
00007  *             2008-2009  Tim Niemueller [www.niemueller.de]
00008  *
00009  ****************************************************************************/
00010 
00011 /*  This program is free software; you can redistribute it and/or modify
00012  *  it under the terms of the GNU General Public License as published by
00013  *  the Free Software Foundation; either version 2 of the License, or
00014  *  (at your option) any later version.
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL file in the doc directory.
00022  */
00023 
00024 #ifndef HAVE_LIBPCAN
00025 #  error "Cannot use Lase EDL driver without libpcan"
00026 #endif
00027 
00028 #ifndef __PLUGINS_LASER_LASE_EDL_AQT_H_
00029 #define __PLUGINS_LASER_LASE_EDL_AQT_H_
00030 
00031 #include "acquisition_thread.h"
00032 
00033 #include <libpcan.h>
00034 #include <string>
00035 
00036 class LaseEdlAcquisitionThread : public LaserAcquisitionThread
00037 {
00038  public:
00039   LaseEdlAcquisitionThread(std::string &cfg_name, std::string &cfg_prefix);
00040 
00041   // from LaserAcquisitionThread
00042   virtual void pre_init(fawkes::Configuration *config, fawkes::Logger *logger);
00043 
00044   virtual void init();
00045   virtual void finalize();
00046   virtual void loop();
00047 
00048  private:
00049   static const WORD  RESETLEVEL_RESET;
00050   static const WORD  RESETLEVEL_RESTART;
00051   static const WORD  RESETLEVEL_HALT_IDLE;
00052   static const WORD  RESETLEVEL_RELOAD_VOLTSET;
00053   static const WORD  CONFIGITEM_ARCNET_HISTORIC;
00054   static const WORD  CONFIGITEM_RS232_RS422;
00055   static const WORD  CONFIGITEM_CAN;
00056   static const WORD  CONFIGITEM_SPI;
00057   static const WORD  CONFIGITEM_ARCNET;
00058   static const WORD  CONFIGITEM_GLOBAL;
00059   static const WORD  CONFIGDATA_LENGTH_RS232_RS422;
00060   static const WORD  CONFIGDATA_LENGTH_CAN;
00061   static const WORD  CONFIGDATA_LENGTH_ARCNET;
00062   static const WORD  CONFIGDATA_LENGTH_GLOBAL;
00063   static const WORD  SECTOR_0;
00064   static const WORD  SECTOR_1;
00065   static const WORD  SECTOR_2;
00066   static const WORD  SECTOR_3;
00067   static const WORD  SECTOR_4;
00068   static const WORD  SECTOR_5;
00069   static const WORD  SECTOR_6;
00070   static const WORD  SECTOR_7;
00071   static const WORD  SECTORFUNC_NOT_INITIALIZED;
00072   static const WORD  SECTORFUNC_NO_MEASUREMENT;
00073   static const WORD  SECTORFUNC_DUMMY_MEASUREMENT;
00074   static const WORD  SECTORFUNC_NORMAL_MEASUREMENT;
00075   static const WORD  SECTORFUNC_REFERENCE_TARGET;
00076   static const WORD  FLASH_YES;
00077   static const WORD  FLASH_NO;
00078   static const WORD  PROFILENUM_CONTINUOUS;
00079   static const WORD  PROFILEFORMAT_NUMBER;
00080   static const WORD  PROFILEFORMAT_COUNTER;
00081   static const WORD  PROFILEFORMAT_LAYER;
00082   static const WORD  PROFILEFORMAT_SECTOR;
00083   static const WORD  PROFILEFORMAT_ANGLE_STEP;
00084   static const WORD  PROFILEFORMAT_NUM_SECT_POINTS;
00085   static const WORD  PROFILEFORMAT_TIMESTAMP_START;
00086   static const WORD  PROFILEFORMAT_START_DIRECTION;
00087   static const WORD  PROFILEFORMAT_DISTANCE;
00088   static const WORD  PROFILEFORMAT_DIRECTION;
00089   static const WORD  PROFILEFORMAT_ECHO_AMPLITUDE;
00090   static const WORD  PROFILEFORMAT_TIMESTAMP_END;
00091   static const WORD  PROFILEFORMAT_END_DIRECTION;
00092   static const WORD  PROFILEFORMAT_SENSOR_MODE;
00093   static const WORD  SERVICEGROUP_STATUS;
00094   static const WORD  CMD_GET_IDENTIFICATION;
00095   static const WORD  CMD_GET_STATUS;
00096   static const WORD  CMD_GET_ERROR;
00097   static const WORD  CMD_GET_SIGNAL;
00098   static const WORD  CMD_SET_SIGNAL;
00099   static const WORD  CMD_REGISTER_APPLICATION;
00100   static const WORD  SERVICEGROUP_CONFIG;
00101   static const WORD  CMD_SET_CONFIG;
00102   static const WORD  CMD_GET_CONFIG;
00103   static const WORD  CMD_SET_SYNC_ABS;
00104   static const WORD  CMD_SET_SYNC_REL;
00105   static const WORD  CMD_SET_SYNC_CLOCK;
00106   static const WORD  CMD_SET_ZONE;
00107   static const WORD  CMD_GET_ZONE;
00108   static const WORD  CMD_RELEASE_ZONE;
00109   static const WORD  CMD_SET_FILTER;
00110   static const WORD  CMD_SET_FUNCTION;
00111   static const WORD  CMD_GET_FUNCTION;
00112   static const WORD  SERVICEGROUP_MEASUREMENT;
00113   static const WORD  CMD_GET_PROFILE;
00114   static const WORD  CMD_CANCEL_PROFILE;
00115   static const WORD  SERVICEGROUP_WORKING;
00116   static const WORD  CMD_DO_RESET;
00117   static const WORD  CMD_TRANS_IDLE;
00118   static const WORD  CMD_TRANS_ROTATE;
00119   static const WORD  CMD_TRANS_MEASURE;
00120   static const WORD  SERVICEGROUP_MAINTENANCE;
00121   static const WORD  CMD_DO_ADJUST;
00122   static const WORD  CMD_DO_TEST;
00123   static const WORD  SERVICEGROUP_INTERFACE_ROUTING;
00124   static const WORD  CMD_COM_ATTACH;
00125   static const WORD  CMD_COM_DETACH;
00126   static const WORD  CMD_COM_INIT;
00127   static const WORD  CMD_COM_OUTPUT;
00128   static const WORD  CMD_COM_DATA;
00129   static const WORD  SERVICEGROUP_FILE;
00130   static const WORD  CMD_DIR;
00131   static const WORD  CMD_SAVE;
00132   static const WORD  CMD_LOAD;
00133   static const WORD  CMD_DELETE;
00134   static const WORD  SERVICEGROUP_MONITOR;
00135   static const WORD  CMD_MONITOR_ENABLE_LOG;
00136   static const WORD  CMD_MONITOR_DISABLE_LOG;
00137   //static const WORD  SERVICEGROUP_APPLICATION; 0x1000 to 0x3F00
00138   static const WORD  SERVICEGROUP_ADJUST;
00139   static const WORD  SERVICEGROUP_SPECIAL;
00140   static const WORD  CMD_SERVICE_FAILURE;
00141   static const WORD  RESPONSE_BIT;
00142   static const float DISTANCE_FACTOR;
00143 
00144  private:
00145   unsigned int calc_angle_step(unsigned int rotation_freq, unsigned int max_pulse_freq);
00146   inline WORD respcode(WORD cmd) { return cmd | RESPONSE_BIT; }
00147   void init_bus();
00148   void send(WORD *data, int n);
00149   int  recv(WORD **data, bool allocate = true);
00150 
00151   void send_and_check(WORD *command_data, int command_length,
00152                       WORD *expected_response, int n,
00153                       WORD **real_response = NULL, int *response_size = NULL);
00154 
00155   inline void append_to_msg(WORD word, TPCANMsg *msg);
00156   inline void append_to_msg(BYTE byte, TPCANMsg *msg);
00157   inline WORD get_word_from_msg(TPCANMsg *msg, int *index);
00158   WORD * make_word_array(int count, ...);
00159   int compare_word_arrays(int count, WORD* a, WORD* b);
00160   void print_word_array(int count, WORD* a);
00161   void print_message(TPCANMsg *m);
00162 
00163   void process_profiles();
00164 
00165   void SET_CONFIG(WORD config_item, int k, ...);
00166   void SET_FUNCTION(WORD sect_num, WORD sect_func, WORD sect_stop, WORD flash);
00167   void GET_PROFILE(WORD prof_num, WORD prof_format);
00168   void CANCEL_PROFILE();
00169   void DO_RESET(WORD reset_level);
00170   void TRANS_IDLE();
00171   void TRANS_ROTATE(WORD frequency);
00172   void TRANS_MEASURE();
00173 
00174 
00175 
00176  private:
00177   HANDLE __handle;
00178   bool         __pre_init_done;
00179 
00180   std::string  __cfg_name;
00181   std::string  __cfg_prefix;
00182 
00183   bool         __cfg_use_default;
00184   bool         __cfg_set_default;
00185   unsigned int __cfg_rotation_freq;
00186   unsigned int __cfg_angle_step;
00187   unsigned int __cfg_max_pulse_freq;
00188   unsigned int __cfg_profile_format;
00189   unsigned int __cfg_can_id;
00190   unsigned int __cfg_can_id_resp;
00191   unsigned int __cfg_sensor_id;
00192   unsigned int __cfg_sensor_id_resp;
00193   unsigned int __cfg_interface_type;
00194   unsigned int __cfg_btr0btr1;
00195   unsigned int __cfg_port;
00196   unsigned int __cfg_irq;
00197   unsigned int __cfg_num_init_tries;
00198   float        __cfg_mount_rotation;
00199 
00200   unsigned int __min_angle_step;
00201   unsigned int __number_of_values;
00202   
00203 };
00204 
00205 
00206 #endif

Generated on Tue Feb 22 13:32:30 2011 for Fawkes API by  doxygen 1.4.7