ARTSAT API  2.7.1
 全て クラス ファイル 関数 変数 型定義 列挙型 列挙型の値 マクロ定義 ページ
ofxInvaderSAT.h
説明を見る。
1 /*
2 ** ARTSAT Project
3 **
4 ** Original Copyright (C) 2011 - 2012 HORIGUCHI Junshi.
5 ** http://iridium.jp/
6 ** zap00365@nifty.com
7 ** Portions Copyright (C) <year> <author>
8 ** <website>
9 ** <e-mail>
10 ** Version openFrameworks
11 ** Website http://artsat.jp/
12 ** E-mail info@artsat.jp
13 **
14 ** This source code is for Xcode.
15 ** Xcode 4.2 (LLVM compiler 3.0)
16 **
17 ** ofxInvaderSAT.h
18 **
19 ** ------------------------------------------------------------------------
20 **
21 ** THE SOURCE CODE AND THE BINARY OF ARTSAT API IS DISTRIBUTED UNDER THE MIT LICENSE WRITTEN BELOW.
22 ** THE LICENSE OF ANY DATA GOTTEN THROUGH ARTSAT API FOLLOWS PROVIDED LICENSE ON EACH SATELLITE.
23 **
24 ** ARTSAT API のソースコードとバイナリは下記に示す MIT ライセンスの元で配布されます。
25 ** ARTSAT API を通して取得できるデータのライセンスに関してはデータの提供元となる各衛星の定めるライセンスに準じます。
26 **
27 ** The MIT License (MIT)
28 **
29 ** Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
30 ** associated documentation files (the "Software"), to deal in the Software without restriction,
31 ** including without limitation the rights to use, copy, modify, merge, publish, distribute,
32 ** sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
33 ** furnished to do so, subject to the following conditions:
34 ** The above copyright notice and this permission notice shall be included in all copies or
35 ** substantial portions of the Software.
36 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
37 ** BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
38 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
39 ** WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
40 ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41 **
42 ** 以下に定める条件に従い、本ソフトウェアおよび関連文書のファイル(以下「ソフトウェア」)の複製を
43 ** 取得するすべての人に対し、ソフトウェアを無制限に扱うことを無償で許可します。
44 ** これには、ソフトウェアの複製を使用、複写、変更、結合、掲載、頒布、サブライセンス、および、または販売する権利、
45 ** およびソフトウェアを提供する相手に同じことを許可する権利も無制限に含まれます。
46 ** 上記の著作権表示および本許諾表示を、ソフトウェアのすべての複製または重要な部分に記載するものとします。
47 ** ソフトウェアは「現状のまま」で、明示であるか暗黙であるかを問わず、何らの保証もなく提供されます。
48 ** ここでいう保証とは、商品性、特定の目的への適合性、および権利非侵害についての保証も含みますが、それに限定されるものではありません。
49 ** 作者または著作権者は、契約行為、不法行為、またはそれ以外であろうと、ソフトウェアに起因または関連し、
50 ** あるいはソフトウェアの使用またはその他の扱いによって生じる一切の請求、損害、その他の義務について何らの責任も負わないものとします。
51 */
52 
53 #ifndef __OFX_INVADERSAT_H
54 #define __OFX_INVADERSAT_H
55 
61 #include "ofxSATType.h"
62 #include "ofxSATRemoteDB.h"
63 #include "ofThread.h"
64 #include "ofxXmlSettings.h"
65 
67 
159 class ofxInvaderSAT : public ofxSATRemoteDB, private ofThread {
160  public:
164  typedef ofxInvaderSAT self;
169 
170  public:
175  enum SensorEnum {
218  // default
221  };
222 
223  public:
225  struct TableRec {
226  FormatEnum format;
227  UnitEnum unit;
228  char query[32];
229  union {
230  struct {
231  char no[32];
232  char yes[32];
233  } boolHint;
234  struct {
235  int lower;
236  int upper;
237  } intHint;
238  struct {
239  double lower;
240  double upper;
241  } doubleHint;
242  struct {
243  char format[32];
244  } ofxSATTimeHint;
245  };
246  };
248 
249  private:
250  mutable ofMutex _mutexCrawl;
251  mutable bool _crawl;
252  mutable bool _immediate;
253  ofxSATTimeDiff _update;
254  ofxSATTimeDiff _retry;
255 
256  public:
261  explicit ofxInvaderSAT (void);
266  virtual ~ofxInvaderSAT (void);
280  ofxSATTimeDiff const& getUpdateInterval (void) const;
294  ofxSATTimeDiff const& getRetryInterval (void) const;
307  virtual ofxSATError getAvailableCount (int* result) const;
323  virtual ofxSATError getAvailableCount (ofxSATTime const& begin, ofxSATTime const& end, int* result) const;
351  virtual ofxSATError getAvailableTime (std::vector<ofxSATTime>* result) const;
388  virtual ofxSATError getAvailableTime (ofxSATTime const& begin, ofxSATTime const& end, std::vector<ofxSATTime>* result) const;
398  virtual ofxSATError getSensorFormat (SensorType sensor, FormatEnum* result) const;
408  virtual ofxSATError getSensorUnit (SensorType sensor, UnitEnum* result) const;
421  virtual ofxSATError getSensorMinimum (SensorType sensor, void* result, int size) const;
434  virtual ofxSATError getSensorMaximum (SensorType sensor, void* result, int size) const;
490  virtual ofxSATError getSensorData (SensorType sensor, ofxSATTime const& time, void* result, int size, bool* simulation = NULL) const;
512  ofxSATError getSensorTimeOBC (ofxSATTime const& time, int* result, bool* simulation = NULL) const;
534  ofxSATError getSensorPowerSolarPX (ofxSATTime const& time, double* result, bool* simulation = NULL) const;
556  ofxSATError getSensorPowerSolarMX (ofxSATTime const& time, double* result, bool* simulation = NULL) const;
578  ofxSATError getSensorPowerSolarPY (ofxSATTime const& time, double* result, bool* simulation = NULL) const;
600  ofxSATError getSensorPowerSolarMY (ofxSATTime const& time, double* result, bool* simulation = NULL) const;
622  ofxSATError getSensorPowerSolarPZ (ofxSATTime const& time, double* result, bool* simulation = NULL) const;
644  ofxSATError getSensorPowerSolarMZ (ofxSATTime const& time, double* result, bool* simulation = NULL) const;
666  ofxSATError getSensorPowerBattery (ofxSATTime const& time, double* result, bool* simulation = NULL) const;
688  ofxSATError getSensorTemperatureSolarPX (ofxSATTime const& time, double* result, bool* simulation = NULL) const;
710  ofxSATError getSensorTemperatureSolarMX (ofxSATTime const& time, double* result, bool* simulation = NULL) const;
732  ofxSATError getSensorTemperatureSolarPY (ofxSATTime const& time, double* result, bool* simulation = NULL) const;
754  ofxSATError getSensorTemperatureSolarMY (ofxSATTime const& time, double* result, bool* simulation = NULL) const;
776  ofxSATError getSensorTemperatureSolarPZ (ofxSATTime const& time, double* result, bool* simulation = NULL) const;
798  ofxSATError getSensorTemperatureSolarMZ (ofxSATTime const& time, double* result, bool* simulation = NULL) const;
820  ofxSATError getSensorTemperatureBattery (ofxSATTime const& time, double* result, bool* simulation = NULL) const;
842  ofxSATError getSensorGyroX (ofxSATTime const& time, double* result, bool* simulation = NULL) const;
864  ofxSATError getSensorGyroY (ofxSATTime const& time, double* result, bool* simulation = NULL) const;
886  ofxSATError getSensorGyroZ (ofxSATTime const& time, double* result, bool* simulation = NULL) const;
908  ofxSATError getSensorMagnetometerX (ofxSATTime const& time, double* result, bool* simulation = NULL) const;
930  ofxSATError getSensorMagnetometerY (ofxSATTime const& time, double* result, bool* simulation = NULL) const;
952  ofxSATError getSensorMagnetometerZ (ofxSATTime const& time, double* result, bool* simulation = NULL) const;
959  virtual ofxSATError setup (void);
964  virtual void cleanup (void);
972  virtual ofxSATError update (ofxSATTime const& time = ofxSATTime::currentTime());
973  private:
974  virtual void threadedFunction (void);
975  ofxSATError getAvailableCount (bool range, ofxSATTime const& begin, ofxSATTime const& end, int* result) const;
976  ofxSATError getAvailableTime (bool range, ofxSATTime const& begin, ofxSATTime const& end, std::vector<ofxSATTime>* result) const;
977  TableRec const* getTableBySensor (SensorType sensor) const;
978  ofxSATError receiveLatest (time_t* result);
979  ofxSATError receiveSpan (time_t begin, time_t end, time_t* result);
980  ofxSATError fetchXML (std::string const& query, ofxXmlSettings* result) const;
981  void waitRetry (void);
982  void pushCrawl (bool immediate) const;
983  bool popCrawl (void) const;
984  bool remainsCrawl (void) const;
985  bool isImmediate (void) const;
986  static std::string convertToUNIXTime (ofxSATTime const& time);
987  static std::string convertToUNIXTime (time_t time);
988  static std::string convertToUNIXTime (ofxSATTime const& begin, ofxSATTime const& end);
989  static std::string convertToUNIXTime (time_t begin, time_t end);
990  static ofxSATError convertUNIXTimeTo (std::string const& string, ofxSATTime* result);
991  static ofxSATError convertUNIXTimeTo (std::string const& string, time_t* result);
992  private:
993  ofxInvaderSAT (ofxInvaderSAT const&);
994  ofxInvaderSAT& operator= (ofxInvaderSAT const&);
995 };
996 
997 /*public */inline ofxSATTimeDiff const& ofxInvaderSAT::getUpdateInterval(void) const
998 {
999  return _update;
1000 }
1001 
1002 /*public */inline ofxSATTimeDiff const& ofxInvaderSAT::getRetryInterval(void) const
1003 {
1004  return _retry;
1005 }
1006 
1007 /*public */inline ofxSATError ofxInvaderSAT::getSensorTimeOBC(ofxSATTime const& time, int* result, bool* simulation) const
1008 {
1009  return getSensorData(SENSOR_TIME_OBC, time, result, sizeof(*result), simulation);
1010 }
1011 
1012 /*public */inline ofxSATError ofxInvaderSAT::getSensorPowerSolarPX(ofxSATTime const& time, double* result, bool* simulation) const
1013 {
1014  return getSensorData(SENSOR_POWER_SOLARPX, time, result, sizeof(*result), simulation);
1015 }
1016 
1017 /*public */inline ofxSATError ofxInvaderSAT::getSensorPowerSolarMX(ofxSATTime const& time, double* result, bool* simulation) const
1018 {
1019  return getSensorData(SENSOR_POWER_SOLARMX, time, result, sizeof(*result), simulation);
1020 }
1021 
1022 /*public */inline ofxSATError ofxInvaderSAT::getSensorPowerSolarPY(ofxSATTime const& time, double* result, bool* simulation) const
1023 {
1024  return getSensorData(SENSOR_POWER_SOLARPY, time, result, sizeof(*result), simulation);
1025 }
1026 
1027 /*public */inline ofxSATError ofxInvaderSAT::getSensorPowerSolarMY(ofxSATTime const& time, double* result, bool* simulation) const
1028 {
1029  return getSensorData(SENSOR_POWER_SOLARMY, time, result, sizeof(*result), simulation);
1030 }
1031 
1032 /*public */inline ofxSATError ofxInvaderSAT::getSensorPowerSolarPZ(ofxSATTime const& time, double* result, bool* simulation) const
1033 {
1034  return getSensorData(SENSOR_POWER_SOLARPZ, time, result, sizeof(*result), simulation);
1035 }
1036 
1037 /*public */inline ofxSATError ofxInvaderSAT::getSensorPowerSolarMZ(ofxSATTime const& time, double* result, bool* simulation) const
1038 {
1039  return getSensorData(SENSOR_POWER_SOLARMZ, time, result, sizeof(*result), simulation);
1040 }
1041 
1042 /*public */inline ofxSATError ofxInvaderSAT::getSensorPowerBattery(ofxSATTime const& time, double* result, bool* simulation) const
1043 {
1044  return getSensorData(SENSOR_POWER_BATTERY, time, result, sizeof(*result), simulation);
1045 }
1046 
1047 /*public */inline ofxSATError ofxInvaderSAT::getSensorTemperatureSolarPX(ofxSATTime const& time, double* result, bool* simulation) const
1048 {
1049  return getSensorData(SENSOR_TEMPERATURE_SOLARPX, time, result, sizeof(*result), simulation);
1050 }
1051 
1052 /*public */inline ofxSATError ofxInvaderSAT::getSensorTemperatureSolarMX(ofxSATTime const& time, double* result, bool* simulation) const
1053 {
1054  return getSensorData(SENSOR_TEMPERATURE_SOLARMX, time, result, sizeof(*result), simulation);
1055 }
1056 
1057 /*public */inline ofxSATError ofxInvaderSAT::getSensorTemperatureSolarPY(ofxSATTime const& time, double* result, bool* simulation) const
1058 {
1059  return getSensorData(SENSOR_TEMPERATURE_SOLARPY, time, result, sizeof(*result), simulation);
1060 }
1061 
1062 /*public */inline ofxSATError ofxInvaderSAT::getSensorTemperatureSolarMY(ofxSATTime const& time, double* result, bool* simulation) const
1063 {
1064  return getSensorData(SENSOR_TEMPERATURE_SOLARMY, time, result, sizeof(*result), simulation);
1065 }
1066 
1067 /*public */inline ofxSATError ofxInvaderSAT::getSensorTemperatureSolarPZ(ofxSATTime const& time, double* result, bool* simulation) const
1068 {
1069  return getSensorData(SENSOR_TEMPERATURE_SOLARPZ, time, result, sizeof(*result), simulation);
1070 }
1071 
1072 /*public */inline ofxSATError ofxInvaderSAT::getSensorTemperatureSolarMZ(ofxSATTime const& time, double* result, bool* simulation) const
1073 {
1074  return getSensorData(SENSOR_TEMPERATURE_SOLARMZ, time, result, sizeof(*result), simulation);
1075 }
1076 
1077 /*public */inline ofxSATError ofxInvaderSAT::getSensorTemperatureBattery(ofxSATTime const& time, double* result, bool* simulation) const
1078 {
1079  return getSensorData(SENSOR_TEMPERATURE_BATTERY, time, result, sizeof(*result), simulation);
1080 }
1081 
1082 /*public */inline ofxSATError ofxInvaderSAT::getSensorGyroX(ofxSATTime const& time, double* result, bool* simulation) const
1083 {
1084  return getSensorData(SENSOR_GYRO_X, time, result, sizeof(*result), simulation);
1085 }
1086 
1087 /*public */inline ofxSATError ofxInvaderSAT::getSensorGyroY(ofxSATTime const& time, double* result, bool* simulation) const
1088 {
1089  return getSensorData(SENSOR_GYRO_Y, time, result, sizeof(*result), simulation);
1090 }
1091 
1092 /*public */inline ofxSATError ofxInvaderSAT::getSensorGyroZ(ofxSATTime const& time, double* result, bool* simulation) const
1093 {
1094  return getSensorData(SENSOR_GYRO_Z, time, result, sizeof(*result), simulation);
1095 }
1096 
1097 /*public */inline ofxSATError ofxInvaderSAT::getSensorMagnetometerX(ofxSATTime const& time, double* result, bool* simulation) const
1098 {
1099  return getSensorData(SENSOR_MAGNETOMETER_X, time, result, sizeof(*result), simulation);
1100 }
1101 
1102 /*public */inline ofxSATError ofxInvaderSAT::getSensorMagnetometerY(ofxSATTime const& time, double* result, bool* simulation) const
1103 {
1104  return getSensorData(SENSOR_MAGNETOMETER_Y, time, result, sizeof(*result), simulation);
1105 }
1106 
1107 /*public */inline ofxSATError ofxInvaderSAT::getSensorMagnetometerZ(ofxSATTime const& time, double* result, bool* simulation) const
1108 {
1109  return getSensorData(SENSOR_MAGNETOMETER_Z, time, result, sizeof(*result), simulation);
1110 }
1111 
1112 #endif