00001 /* 00002 * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA) 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 00018 #ifndef LMS1XX_H_ 00019 #define LMS1XX_H_ 00020 00021 #include <string> 00022 #include <stdint.h> 00023 00030 typedef struct _scanCfg { 00035 int scaningFrequency; 00036 00041 int angleResolution; 00042 00047 int startAngle; 00048 00053 int stopAngle; 00054 } scanCfg; 00055 00062 typedef struct _scanDataCfg { 00063 00068 int outputChannel; 00069 00074 bool remission; 00075 00080 int resolution; 00081 00086 int encoder; 00087 00092 bool position; 00093 00098 bool deviceName; 00099 00100 bool timestamp; 00101 00111 int outputInterval; 00112 } scanDataCfg; 00113 00120 typedef struct _scanData { 00121 00126 int dist_len1; 00127 00132 uint16_t dist1[1082]; 00133 00138 int dist_len2; 00139 00144 uint16_t dist2[1082]; 00145 00150 int rssi_len1; 00151 00156 uint16_t rssi1[1082]; 00157 00162 int rssi_len2; 00163 00168 uint16_t rssi2[1082]; 00169 } scanData; 00170 00171 typedef enum { 00172 undefined = 0, 00173 initialisation = 1, 00174 configuration = 2, 00175 idle = 3, 00176 rotated = 4, 00177 in_preparation = 5, 00178 ready = 6, 00179 ready_for_measurement = 7 00180 } status_t; 00181 00189 class LMS1xx { 00190 public: 00191 LMS1xx(); 00192 virtual ~LMS1xx(); 00193 00199 void connect(std::string host, int port = 2111); 00200 00204 void disconnect(); 00205 00210 bool isConnected(); 00211 00216 void startMeas(); 00217 00222 void stopMeas(); 00223 00228 status_t queryStatus(); 00229 00234 void login(); 00235 00245 scanCfg getScanCfg() const; 00246 00256 void setScanCfg(const scanCfg &cfg); 00257 00263 void setScanDataCfg(const scanDataCfg &cfg); 00264 00270 void scanContinous(int start); 00271 00277 bool getData(scanData& data); 00278 00284 void saveConfig(); 00285 00290 void startDevice(); 00291 00292 private: 00293 bool connected; 00294 bool debug; 00295 00296 int sockDesc; 00297 }; 00298 00299 #endif /* LMS1XX_H_ */