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 __PLUGINS_LASER_LASE_EDL_AQT_H_
00025 #define __PLUGINS_LASER_LASE_EDL_AQT_H_
00026 
00027 #include "acquisition_thread.h"
00028
00029 #include <libpcan.h>
00030
00031 class LaseEdlAcquisitionThread : public LaserAcquisitionThread
00032 {
00033  public:
00034   LaseEdlAcquisitionThread();
00035
00036   // from LaserAcquisitionThread
00037   virtual void pre_init(fawkes::Configuration *config, fawkes::Logger *logger);
00038
00039   virtual void init();
00040   virtual void finalize();
00041   virtual void loop();
00042
00043  private:
00044   static const WORD  RESETLEVEL_RESET;
00045   static const WORD  RESETLEVEL_RESTART;
00046   static const WORD  RESETLEVEL_HALT_IDLE;
00047   static const WORD  RESETLEVEL_RELOAD_VOLTSET;
00048   static const WORD  CONFIGITEM_ARCNET_HISTORIC;
00049   static const WORD  CONFIGITEM_RS232_RS422;
00050   static const WORD  CONFIGITEM_CAN;
00051   static const WORD  CONFIGITEM_SPI;
00052   static const WORD  CONFIGITEM_ARCNET;
00053   static const WORD  CONFIGITEM_GLOBAL;
00054   static const WORD  CONFIGDATA_LENGTH_RS232_RS422;
00055   static const WORD  CONFIGDATA_LENGTH_CAN;
00056   static const WORD  CONFIGDATA_LENGTH_ARCNET;
00057   static const WORD  CONFIGDATA_LENGTH_GLOBAL;
00058   static const WORD  SECTOR_0;
00059   static const WORD  SECTOR_1;
00060   static const WORD  SECTOR_2;
00061   static const WORD  SECTOR_3;
00062   static const WORD  SECTOR_4;
00063   static const WORD  SECTOR_5;
00064   static const WORD  SECTOR_6;
00065   static const WORD  SECTOR_7;
00066   static const WORD  SECTORFUNC_NOT_INITIALIZED;
00067   static const WORD  SECTORFUNC_NO_MEASUREMENT;
00068   static const WORD  SECTORFUNC_DUMMY_MEASUREMENT;
00069   static const WORD  SECTORFUNC_NORMAL_MEASUREMENT;
00070   static const WORD  SECTORFUNC_REFERENCE_TARGET;
00071   static const WORD  FLASH_YES;
00072   static const WORD  FLASH_NO;
00073   static const WORD  PROFILENUM_CONTINUOUS;
00074   static const WORD  PROFILEFORMAT_NUMBER;
00075   static const WORD  PROFILEFORMAT_COUNTER;
00076   static const WORD  PROFILEFORMAT_LAYER;
00077   static const WORD  PROFILEFORMAT_SECTOR;
00078   static const WORD  PROFILEFORMAT_ANGLE_STEP;
00079   static const WORD  PROFILEFORMAT_NUM_SECT_POINTS;
00080   static const WORD  PROFILEFORMAT_TIMESTAMP_START;
00081   static const WORD  PROFILEFORMAT_START_DIRECTION;
00082   static const WORD  PROFILEFORMAT_DISTANCE;
00083   static const WORD  PROFILEFORMAT_DIRECTION;
00084   static const WORD  PROFILEFORMAT_ECHO_AMPLITUDE;
00085   static const WORD  PROFILEFORMAT_TIMESTAMP_END;
00086   static const WORD  PROFILEFORMAT_END_DIRECTION;
00087   static const WORD  PROFILEFORMAT_SENSOR_MODE;
00088   static const WORD  SERVICEGROUP_STATUS;
00089   static const WORD  CMD_GET_IDENTIFICATION;
00090   static const WORD  CMD_GET_STATUS;
00091   static const WORD  CMD_GET_ERROR;
00092   static const WORD  CMD_GET_SIGNAL;
00093   static const WORD  CMD_SET_SIGNAL;
00094   static const WORD  CMD_REGISTER_APPLICATION;
00095   static const WORD  SERVICEGROUP_CONFIG;
00096   static const WORD  CMD_SET_CONFIG;
00097   static const WORD  CMD_GET_CONFIG;
00098   static const WORD  CMD_SET_SYNC_ABS;
00099   static const WORD  CMD_SET_SYNC_REL;
00100   static const WORD  CMD_SET_SYNC_CLOCK;
00101   static const WORD  CMD_SET_ZONE;
00102   static const WORD  CMD_GET_ZONE;
00103   static const WORD  CMD_RELEASE_ZONE;
00104   static const WORD  CMD_SET_FILTER;
00105   static const WORD  CMD_SET_FUNCTION;
00106   static const WORD  CMD_GET_FUNCTION;
00107   static const WORD  SERVICEGROUP_MEASUREMENT;
00108   static const WORD  CMD_GET_PROFILE;
00109   static const WORD  CMD_CANCEL_PROFILE;
00110   static const WORD  SERVICEGROUP_WORKING;
00111   static const WORD  CMD_DO_RESET;
00112   static const WORD  CMD_TRANS_IDLE;
00113   static const WORD  CMD_TRANS_ROTATE;
00114   static const WORD  CMD_TRANS_MEASURE;
00115   static const WORD  SERVICEGROUP_MAINTENANCE;
00116   static const WORD  CMD_DO_ADJUST;
00117   static const WORD  CMD_DO_TEST;
00118   static const WORD  SERVICEGROUP_INTERFACE_ROUTING;
00119   static const WORD  CMD_COM_ATTACH;
00120   static const WORD  CMD_COM_DETACH;
00121   static const WORD  CMD_COM_INIT;
00122   static const WORD  CMD_COM_OUTPUT;
00123   static const WORD  CMD_COM_DATA;
00124   static const WORD  SERVICEGROUP_FILE;
00125   static const WORD  CMD_DIR;
00126   static const WORD  CMD_SAVE;
00127   static const WORD  CMD_LOAD;
00128   static const WORD  CMD_DELETE;
00129   static const WORD  SERVICEGROUP_MONITOR;
00130   static const WORD  CMD_MONITOR_ENABLE_LOG;
00131   static const WORD  CMD_MONITOR_DISABLE_LOG;
00132   //static const WORD  SERVICEGROUP_APPLICATION; 0x1000 to 0x3F00
00133   static const WORD  SERVICEGROUP_ADJUST;
00134   static const WORD  SERVICEGROUP_SPECIAL;
00135   static const WORD  CMD_SERVICE_FAILURE;
00136   static const WORD  RESPONSE_BIT;
00137   static const float DISTANCE_FACTOR;
00138
00139  private:
00140   unsigned int calc_angle_step(unsigned int rotation_freq, unsigned int max_pulse_freq);
00141   inline WORD respcode(WORD cmd) { return cmd | RESPONSE_BIT; }
00142   void init_bus();
00143   void send(WORD *data, int n);
00144   int  recv(WORD **data, bool allocate = true);
00145
00146   void send_and_check(WORD *command_data, int command_length,
00147                       WORD *expected_response, int n,
00148                       WORD **real_response = NULL, int *response_size = NULL);
00149
00150   inline void append_to_msg(WORD word, TPCANMsg *msg);
00151   inline void append_to_msg(BYTE byte, TPCANMsg *msg);
00152   inline WORD get_word_from_msg(TPCANMsg *msg, int *index);
00153   WORD * make_word_array(int count, ...);
00154   int compare_word_arrays(int count, WORD* a, WORD* b);
00155   void print_word_array(int count, WORD* a);
00156   void print_message(TPCANMsg *m);
00157
00158   void process_profiles();
00159
00160   void SET_CONFIG(WORD config_item, int k, ...);
00161   void SET_FUNCTION(WORD sect_num, WORD sect_func, WORD sect_stop, WORD flash);
00162   void GET_PROFILE(WORD prof_num, WORD prof_format);
00163   void CANCEL_PROFILE();
00164   void DO_RESET(WORD reset_level);
00165   void TRANS_IDLE();
00166   void TRANS_ROTATE(WORD frequency);
00167   void TRANS_MEASURE();
00168
00169
00170
00171  private:
00172   HANDLE __handle;
00173   bool         __pre_init_done;
00174
00175   bool         __cfg_use_default;
00176   bool         __cfg_set_default;
00177   unsigned int __cfg_rotation_freq;
00178   unsigned int __cfg_angle_step;
00179   unsigned int __cfg_max_pulse_freq;
00180   unsigned int __cfg_profile_format;
00181   unsigned int __cfg_can_id;
00182   unsigned int __cfg_can_id_resp;
00183   unsigned int __cfg_sensor_id;
00184   unsigned int __cfg_sensor_id_resp;
00185   unsigned int __cfg_interface_type;
00186   unsigned int __cfg_btr0btr1;
00187   unsigned int __cfg_port;
00188   unsigned int __cfg_irq;
00189   unsigned int __cfg_num_init_tries;
00190   float        __cfg_mount_rotation;
00191
00192   unsigned int __min_angle_step;
00193   unsigned int __number_of_values;
00194
00195 };
00196
00197
00198 #endif