vdr  2.2.0
positioner.h
Go to the documentation of this file.
1 /*
2  * positioner.h: Steerable dish positioning
3  *
4  * See the main source file 'vdr.c' for copyright information and
5  * how to reach the author.
6  *
7  * $Id: positioner.h 3.3 2013/12/28 11:15:56 kls Exp $
8  */
9 
10 #ifndef __POSITIONER_H
11 #define __POSITIONER_H
12 
13 #include "thread.h"
14 #include "tools.h"
15 
30 
31 class cPositioner {
32 private:
33  mutable cMutex mutex;
36  int frontend; // file descriptor of the DVB frontend
37  mutable int lastLongitude; // the longitude the dish has last been moved to
38  int targetLongitude; // the longitude the dish is supposed to be moved to
39  mutable int lastHourAngle; // the hour angle the positioner has last been moved to
40  int targetHourAngle; // the hour angle the positioner is supposed to be moved to
41  int swingTime;
43 protected:
44  cPositioner(void);
45  virtual ~cPositioner();
46  void SetCapabilities(int Capabilities) { capabilities = Capabilities; }
49  int Frontend(void) const { return frontend; }
53  static int CalcHourAngle(int Longitude);
62  static int CalcLongitude(int HourAngle);
65  void StartMovementTimer(int Longitude);
69 public:
71  pcCanNothing = 0x0000,
72  pcCanDrive = 0x0001,
73  pcCanStep = 0x0002,
74  pcCanHalt = 0x0004,
75  pcCanSetLimits = 0x0008,
81  pcCanGotoAngle = 0x0200,
82  };
84  static int NormalizeAngle(int Angle);
86  int Capabilities(void) const { return capabilities; }
89  void SetFrontend(int Frontend) { frontend = Frontend; }
92  static int HorizonLongitude(ePositionerDirection Direction);
98  int HardLimitLongitude(ePositionerDirection Direction) const;
103  int LastLongitude(void) const { return lastLongitude; }
105  int TargetLongitude(void) const { return targetLongitude; }
109  virtual cString Error(void) const { return NULL; }
113  virtual void Drive(ePositionerDirection Direction) {}
116  virtual void Step(ePositionerDirection Direction, uint Steps = 1) {}
122  virtual void Halt(void) {}
124  virtual void SetLimit(ePositionerDirection Direction) {}
127  virtual void DisableLimits(void) {}
129  virtual void EnableLimits(void) {}
131  virtual void StorePosition(uint Number) {}
135  virtual void RecalcPositions(uint Number) {}
139  virtual void GotoPosition(uint Number, int Longitude);
148  virtual void GotoAngle(int Longitude);
155  virtual int CurrentLongitude(void) const;
161  virtual bool IsMoving(void) const;
164  static cPositioner *GetPositioner(void);
167  static void DestroyPositioner(void);
169  };
170 
171 #endif //__POSITIONER_H
static int CalcHourAngle(int Longitude)
Takes the longitude and latitude of the dish location from the system setup and the given Longitude t...
Definition: positioner.c:51
virtual void Step(ePositionerDirection Direction, uint Steps=1)
Move the dish the given number of Steps in the given Direction.
Definition: positioner.h:116
int LastLongitude(void) const
Returns the longitude the dish has last been moved to.
Definition: positioner.h:103
static int NormalizeAngle(int Angle)
Normalizes the given Angle into the range -1800...1800.
Definition: positioner.c:42
virtual void EnableLimits(void)
Enables the soft limits for the dish movement.
Definition: positioner.h:129
int swingTime
Definition: positioner.h:41
virtual void GotoPosition(uint Number, int Longitude)
Move the dish to the satellite position stored under the given Number.
Definition: positioner.c:100
int TargetLongitude(void) const
Returns the longitude the dish is supposed to be moved to.
Definition: positioner.h:105
void SetFrontend(int Frontend)
This function is called whenever the positioner is connected to a DVB frontend.
Definition: positioner.h:89
int targetLongitude
Definition: positioner.h:38
static cPositioner * positioner
Definition: positioner.h:34
int targetHourAngle
Definition: positioner.h:40
static cPositioner * GetPositioner(void)
Returns a previously created positioner.
Definition: positioner.c:133
A steerable satellite dish generally points to the south on the northern hemisphere, and to the north on the southern hemisphere (unless you're located directly on the equator, in which case the general direction is "up").
Definition: positioner.h:31
virtual void GotoAngle(int Longitude)
Move the dish to the given angular position.
Definition: positioner.c:107
virtual void RecalcPositions(uint Number)
Take the difference between the current actual position of the dish and the position stored with the ...
Definition: positioner.h:135
virtual cString Error(void) const
Returns a short, single line string indicating an error condition (if the positioner is able to repor...
Definition: positioner.h:109
ePositionerDirection
Definition: positioner.h:83
virtual void DisableLimits(void)
Disables the soft limits for the dish movement.
Definition: positioner.h:127
virtual void Halt(void)
Stop any ongoing motion of the dish.
Definition: positioner.h:122
virtual bool IsMoving(void) const
Returns true if the dish is currently moving as a result of a call to GotoPosition() or GotoAngle()...
Definition: positioner.c:127
virtual void SetLimit(ePositionerDirection Direction)
Set the soft limit of the dish movement in the given Direction to the current position.
Definition: positioner.h:124
Definition: thread.h:63
virtual int CurrentLongitude(void) const
Returns the longitude the dish currently points to.
Definition: positioner.c:114
int Frontend(void) const
Returns the file descriptor of the DVB frontend the positioner is connected to.
Definition: positioner.h:49
int Capabilities(void) const
Returns a flag word defining all the things this positioner is capable of.
Definition: positioner.h:86
virtual ~cPositioner()
Definition: positioner.c:37
virtual void StorePosition(uint Number)
Store the current position as a satellite position with the given Number.
Definition: positioner.h:131
int frontend
Definition: positioner.h:36
int capabilities
Definition: positioner.h:35
cMutex mutex
Definition: positioner.h:33
ePositionerCapabilities
Definition: positioner.h:70
void SetCapabilities(int Capabilities)
A derived class shall call this function in its constructor to set the capability flags it supports...
Definition: positioner.h:46
static int CalcLongitude(int HourAngle)
Returns the longitude of the satellite position the dish points at when the positioner is moved to th...
Definition: positioner.c:59
void StartMovementTimer(int Longitude)
Starts a timer that estimates how long it will take to move the dish from the current position to the...
Definition: positioner.c:86
cTimeMs movementStart
Definition: positioner.h:42
Definition: tools.h:333
static int HorizonLongitude(ePositionerDirection Direction)
Returns the longitude of the satellite position that is just at the horizon when looking in the given...
Definition: positioner.c:69
int lastLongitude
Definition: positioner.h:37
virtual void Drive(ePositionerDirection Direction)
Continuously move the dish to the given Direction until Halt() is called or it hits the soft or hard ...
Definition: positioner.h:113
int HardLimitLongitude(ePositionerDirection Direction) const
Returns the longitude of the positioner's hard limit in the given Direction.
Definition: positioner.c:81
Definition: tools.h:168
static void DestroyPositioner(void)
Destroys a previously created positioner.
Definition: positioner.c:138
int lastHourAngle
Definition: positioner.h:39
cPositioner(void)
Definition: positioner.c:26