Isomet Modular Synthesiser (iMS) API  v1.4.2
iMS API
IMSTypeDefs.h
Go to the documentation of this file.
1 /*-----------------------------------------------------------------------------
2 / Title : iMS Useful Type Defines Header
3 / Project : Isomet Modular Synthesiser System
4 /------------------------------------------------------------------------------
5 / File : $URL: http://nutmeg.qytek.lan/svn/sw/trunk/09-Isomet/iMS_SDK/API/Other/h/IMSTypeDefs.h $
6 / Author : $Author: dave $
7 / Company : Isomet (UK) Ltd
8 / Created : 2015-04-09
9 / Last update: $Date: 2017-09-11 23:55:34 +0100 (Mon, 11 Sep 2017) $
10 / Platform :
11 / Standard : C++11
12 / Revision : $Rev: 300 $
13 /------------------------------------------------------------------------------
14 / Description:
15 /------------------------------------------------------------------------------
16 / Copyright (c) 2015 Isomet (UK) Ltd. All Rights Reserved.
17 /------------------------------------------------------------------------------
18 / Revisions :
19 / Date Version Author Description
20 / 2015-04-09 1.0 dc Created
21 /
22 /----------------------------------------------------------------------------*/
23 
35 
36 #ifndef IMS_IMSTYPEDEFS_H__
37 #define IMS_IMSTYPEDEFS_H__
38 
39 #include <cmath>
40 #include <stdexcept>
41 #include <cstdint>
42 #include <vector>
43 
45 #if defined _WIN32 || defined __CYGWIN__
46  #ifdef __GNUC__
47  #define DLL_EXPORT __attribute__ ((dllexport))
48  #define DLL_IMPORT __attribute__ ((dllimport))
49  #else
50  #define DLL_EXPORT __declspec(dllexport) // Note: actually gcc seems to also supports this syntax.
51  #define DLL_IMPORT __declspec(dllimport) // Note: actually gcc seems to also supports this syntax.
52  #endif
53  #define DLL_LOCAL
54 #else
55  #if __GNUC__ >= 4
56  #define DLL_EXPORT __attribute__ ((visibility ("default")))
57  #define DLL_IMPORT __attribute__ ((visibility ("default")))
58  #define DLL_LOCAL __attribute__ ((visibility ("hidden")))
59  #else
60  #define DLL_EXPORT
61  #define DLL_IMPORT
62  #define DLL_LOCAL
63  #endif
64 #endif
65 
66 #if defined(_EXPORTING_IMS)
67  #define LIBSPEC DLL_EXPORT
68  #define LIBLOCAL DLL_LOCAL
69  #define EXPIMP_TEMPLATE
70 #elif defined(_STATIC_IMS)
71  #define LIBSPEC
72  #define LIBLOCAL
73  #define EXPIMP_TEMPLATE
74 #else
75  #define LIBSPEC DLL_IMPORT
76  #define LIBLOCAL DLL_LOCAL
77  #define EXPIMP_TEMPLATE extern
78 #endif
79 
81 namespace iMS
82 {
83 
84  // Forward Declaration
85  class IMSSystem;
86 
96  class LIBSPEC Frequency {
97  protected:
98  double value;
99 
100  public:
104  Frequency(double arg = 0.0) : value(arg) {}
105 
114  Frequency& operator = (double arg) {
115  value = arg;
116  return *this;
117  }
118 
130  operator double() const { return value; }
131 
136  static unsigned int RenderAsPointRate(const IMSSystem&, const Frequency, const bool PrescalerDisable = false);
137  };
138 
148  class LIBSPEC kHz : public Frequency {
149  public:
153  kHz(double arg) : Frequency(arg * 1000.0) {};
154 
163  kHz& operator = (double arg) {
164  value = 1000.0 * arg;
165  return *this;
166  }
167 
179  operator double() const { return (value / 1000.0); }
180  };
181 
191  class LIBSPEC MHz : public Frequency {
192  public:
196  MHz(double arg) : Frequency(arg * 1000000.0) {};
197 
206  MHz& operator = (double arg) {
207  value = 1000000.0 * arg;
208  return *this;
209  }
210 
222  operator double() const { return (value / 1000000.0); }
223 
228  static unsigned int RenderAsImagePoint(const IMSSystem&, const MHz);
229  };
230 
241  class LIBSPEC Percent{
242  double value;
243 
244  public:
247  Percent() : value(0.0) {};
253  Percent(double arg) : value(arg) {
254  if (arg < 0.0) value = 0.0;
255  if (arg > 100.0) value = 100.0;
256  }
257 
272  Percent& operator = (double arg) {
273  if (arg < 0.0) value = 0.0;
274  else if (arg > 100.0) value = 100.0;
275  else value = arg;
276  return *this;
277  }
278 
281  operator double() const { return value; }
282 
287  static unsigned int RenderAsImagePoint(const IMSSystem&, const Percent);
288 
293  static unsigned int RenderAsCompensationPoint(const IMSSystem&, const Percent);
294 
301  static unsigned int RenderAsCalibrationTone(const IMSSystem&, const Percent);
302  };
303 
314  class LIBSPEC Degrees {
315  double value;
316 
317  public:
323  Degrees(double arg) {
324  value = std::fmod(arg, 360.0);
325  }
326 
345  Degrees& operator = (double arg) {
346  value = std::fmod(arg, 360.0);
347  return *this;
348  }
349 
352  operator double() const { return value; }
353 
358  static unsigned int RenderAsImagePoint(const IMSSystem&, const Degrees);
359 
364  static unsigned int RenderAsCompensationPoint(const IMSSystem&, const Degrees);
365 
372  static unsigned int RenderAsCalibrationTone(const IMSSystem&, const Degrees);
373  };
374 
387  struct LIBSPEC FAP
388  {
395 
397  FAP() : freq(0.0), ampl(0.0), phase(0.0) {};
399  FAP(double f, double a, double p) : freq(f), ampl(a), phase(p) {};
401  FAP(MHz f, Percent a, Degrees p) : freq(f), ampl(a), phase(p) {};
402 
404 
405  bool operator==(const FAP &other) const;
409  bool operator!=(const FAP &other) const;
410  };
412 
425  class LIBSPEC RFChannel {
426  int value;
427 
428  public:
431  RFChannel() : value(1) {};
439  RFChannel(int arg) : value(arg) {
440  if (arg < 1 || arg > 4) {
441  value = 1;
442  throw std::invalid_argument("Invalid RF Channel Number");
443  }
444  }
445 
455  RFChannel& operator = (int arg) {
456  if (arg < 1 || arg > 4) {
457  value = 1;
458  throw std::invalid_argument("Invalid RF Channel Number");
459  }
460  else value = arg;
461  return *this;
462  }
463 
465 
466  RFChannel& operator++() {
469  if (value<4) value++;
470  return *this;
471  }
472 
473  RFChannel operator++(int) {
474  RFChannel temp = *this;
475  ++(*this);
476  return temp;
477  }
478 
479  RFChannel& operator--() {
480  if (value>1) value--;
481  return *this;
482  }
483 
484  RFChannel operator--(int) {
485  RFChannel temp = *this;
486  --(*this);
487  return temp;
488  }
490 
493  operator int() const { return value; }
494  };
495 
496 }
497 
498 #undef EXPIMP_TEMPLATE
499 #undef LIBSPEC
500 #endif
FAP(double f, double a, double p)
Construct a FAP object from raw double precision input data.
Definition: IMSTypeDefs.h:399
RFChannel()
Default construct an RF Channel object initialised to the first RF Channel.
Definition: IMSTypeDefs.h:431
FAP(MHz f, Percent a, Degrees p)
Construct a FAP object from pre-existing MHz, Percent and Degrees objects.
Definition: IMSTypeDefs.h:401
Type Definition for all operations that require an angle specification in degrees.
Definition: IMSTypeDefs.h:314
Percent ampl
The RF Channel Output Amplitude.
Definition: IMSTypeDefs.h:392
kHz(double arg)
Construct a kHz object from a double argument representing kiloHertz.
Definition: IMSTypeDefs.h:153
Percent(double arg)
Construct a Percent object from a double argument and check its value is within the range 0...
Definition: IMSTypeDefs.h:253
RFChannel(int arg)
Construct an RF Channel object and check that it is being created with an integer value within the ra...
Definition: IMSTypeDefs.h:439
MHz(double arg)
Construct a MHz object from a double argument representing MegaHertz.
Definition: IMSTypeDefs.h:196
Percent()
Default Constructor assigns 0.0%.
Definition: IMSTypeDefs.h:247
An object representing the overall configuration of an attached iMS System and permits applications t...
Definition: IMSSystem.h:361
FAP (Frequency/Amplitude/Phase) triad stores the instantaneous definition of a single RF output...
Definition: IMSTypeDefs.h:387
The entire API is encapsulated by the iMS namespace.
Definition: Auxiliary.h:95
Type that represents the integer values 1, 2, 3 and 4, one each for the RF Channels of an iMS Synthes...
Definition: IMSTypeDefs.h:425
MHz freq
The RF Channel Output Frequency.
Definition: IMSTypeDefs.h:390
Type Definition for all operations that require a percentage specification.
Definition: IMSTypeDefs.h:241
Type Definition for all operations that require a frequency specification in MegaHertz.
Definition: IMSTypeDefs.h:191
FAP()
Default construct a FAP object with zero data.
Definition: IMSTypeDefs.h:397
Degrees(double arg)
Construct a Degrees object from a double argument and check its value is within the range 0...
Definition: IMSTypeDefs.h:323
Type Definition for all operations that require a frequency specification in kiloHertz.
Definition: IMSTypeDefs.h:148
Frequency(double arg=0.0)
Construct a Frequency object from a double argument representing Hertz.
Definition: IMSTypeDefs.h:104
Degrees phase
The RF Channel Output Phase.
Definition: IMSTypeDefs.h:394
Type Definition for all operations that require a frequency specification.
Definition: IMSTypeDefs.h:96