vdr  2.2.0
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Private Attributes | Static Private Attributes | List of all members
cPositioner Class Reference

#include <positioner.h>

Public Types

enum  ePositionerCapabilities {
  pcCanNothing = 0x0000, pcCanDrive = 0x0001, pcCanStep = 0x0002, pcCanHalt = 0x0004,
  pcCanSetLimits = 0x0008, pcCanDisableLimits = 0x0010, pcCanEnableLimits = 0x0020, pcCanStorePosition = 0x0040,
  pcCanRecalcPositions = 0x0080, pcCanGotoPosition = 0x0100, pcCanGotoAngle = 0x0200
}
 
enum  ePositionerDirection { pdLeft, pdRight }
 

Public Member Functions

int Capabilities (void) const
 
void SetFrontend (int Frontend)
 
int HardLimitLongitude (ePositionerDirection Direction) const
 
int LastLongitude (void) const
 
int TargetLongitude (void) const
 
virtual cString Error (void) const
 
virtual void Drive (ePositionerDirection Direction)
 
virtual void Step (ePositionerDirection Direction, uint Steps=1)
 
virtual void Halt (void)
 
virtual void SetLimit (ePositionerDirection Direction)
 
virtual void DisableLimits (void)
 
virtual void EnableLimits (void)
 
virtual void StorePosition (uint Number)
 
virtual void RecalcPositions (uint Number)
 
virtual void GotoPosition (uint Number, int Longitude)
 
virtual void GotoAngle (int Longitude)
 
virtual int CurrentLongitude (void) const
 
virtual bool IsMoving (void) const
 

Static Public Member Functions

static int NormalizeAngle (int Angle)
 
static int HorizonLongitude (ePositionerDirection Direction)
 
static cPositionerGetPositioner (void)
 
static void DestroyPositioner (void)
 

Protected Member Functions

 cPositioner (void)
 
virtual ~cPositioner ()
 
void SetCapabilities (int Capabilities)
 
int Frontend (void) const
 
void StartMovementTimer (int Longitude)
 

Static Protected Member Functions

static int CalcHourAngle (int Longitude)
 
static int CalcLongitude (int HourAngle)
 

Private Attributes

cMutex mutex
 
int capabilities
 
int frontend
 
int lastLongitude
 
int targetLongitude
 
int lastHourAngle
 
int targetHourAngle
 
int swingTime
 
cTimeMs movementStart
 

Static Private Attributes

static cPositionerpositioner = NULL
 

Detailed Description

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").

Therefore, moving the dish "east" or "west" means something different on either hemisphere. From the local dish motor's point of view, it makes more sense to speak of turning the dish "left" or "right", which is independent of the actual hemisphere the dish is located in. In the cPositioner class context, when a dish on the northern hemisphere moves "east", it is considered to be moving "left". Imagine standing behind the dish and looking towards the satellites, and clearly "east" is "left". On the southern hemisphere the same move to the "left" would go to the "west". So on the hardware level it is clear what "left" and "right" means. The user interface may present different labels to the viewer, depending on the hemisphere the dish is on. All angles in this context are given in "degrees * 10", which allows for an angular resolution of 0.1 degrees.

Definition at line 31 of file positioner.h.

Member Enumeration Documentation

Enumerator
pcCanNothing 
pcCanDrive 
pcCanStep 
pcCanHalt 
pcCanSetLimits 
pcCanDisableLimits 
pcCanEnableLimits 
pcCanStorePosition 
pcCanRecalcPositions 
pcCanGotoPosition 
pcCanGotoAngle 

Definition at line 70 of file positioner.h.

Enumerator
pdLeft 
pdRight 

Definition at line 83 of file positioner.h.

Constructor & Destructor Documentation

cPositioner::cPositioner ( void  )
protected
cPositioner::~cPositioner ( )
protectedvirtual

Definition at line 37 of file positioner.c.

References positioner.

Member Function Documentation

int cPositioner::CalcHourAngle ( int  Longitude)
staticprotected

Takes the longitude and latitude of the dish location from the system setup and the given Longitude to calculate the "hour angle" to which to move the dish to in order to point to the satellite at orbital position Longitude.

An hour angle of zero means the dish shall point directly towards the celestial equator (which is south on the northern hemisphere, and north on the southern hemisphere). Negative values mean that the dish needs to be moved to the left (as seen from behind the dish), while positive values require a movement to the right.

Definition at line 51 of file positioner.c.

References DEG, RAD, SAT_EARTH_RATIO, Setup, cSetup::SiteLat, and cSetup::SiteLon.

Referenced by cPositioner(), Frontend(), cDiseqcPositioner::GotoAngle(), and StartMovementTimer().

int cPositioner::CalcLongitude ( int  HourAngle)
staticprotected

Returns the longitude of the satellite position the dish points at when the positioner is moved to the given HourAngle.

Definition at line 59 of file positioner.c.

References DEG, NormalizeAngle(), RAD, SAT_EARTH_RATIO, Setup, cSetup::SiteLat, and cSetup::SiteLon.

Referenced by CurrentLongitude(), Frontend(), and HardLimitLongitude().

int cPositioner::Capabilities ( void  ) const
inline

Returns a flag word defining all the things this positioner is capable of.

Definition at line 86 of file positioner.h.

References capabilities.

Referenced by SetCapabilities().

int cPositioner::CurrentLongitude ( void  ) const
virtual

Returns the longitude the dish currently points to.

If the dish is in motion, this may be an estimate based on the angular speed of the positioner. The default implementation takes the last and target longitude as well as the rotation speed of the positioner to calculate the estimated current longitude the dish points to.

Definition at line 114 of file positioner.c.

References CalcLongitude(), cTimeMs::Elapsed(), lastHourAngle, lastLongitude, movementStart, mutex, swingTime, targetHourAngle, and targetLongitude.

Referenced by DrawDevicePosition(), IsMoving(), RecalcPositions(), and StartMovementTimer().

void cPositioner::DestroyPositioner ( void  )
static

Destroys a previously created positioner.

Definition at line 138 of file positioner.c.

References positioner.

Referenced by main(), and RecalcPositions().

virtual void cPositioner::DisableLimits ( void  )
inlinevirtual

Disables the soft limits for the dish movement.

Reimplemented in cDiseqcPositioner.

Definition at line 127 of file positioner.h.

virtual void cPositioner::Drive ( ePositionerDirection  Direction)
inlinevirtual

Continuously move the dish to the given Direction until Halt() is called or it hits the soft or hard limit.

Reimplemented in cDiseqcPositioner.

Definition at line 113 of file positioner.h.

virtual void cPositioner::EnableLimits ( void  )
inlinevirtual

Enables the soft limits for the dish movement.

Reimplemented in cDiseqcPositioner.

Definition at line 129 of file positioner.h.

virtual cString cPositioner::Error ( void  ) const
inlinevirtual

Returns a short, single line string indicating an error condition (if the positioner is able to report any errors).

NULL means there is no error.

Definition at line 109 of file positioner.h.

int cPositioner::Frontend ( void  ) const
inlineprotected

Returns the file descriptor of the DVB frontend the positioner is connected to.

If the positioner is not connected to any DVB device, -1 will be returned.

Definition at line 49 of file positioner.h.

References CalcHourAngle(), CalcLongitude(), frontend, and StartMovementTimer().

Referenced by cDiseqcPositioner::SendDiseqc(), and SetFrontend().

cPositioner * cPositioner::GetPositioner ( void  )
static

Returns a previously created positioner.

If no plugin has created a positioner, there will always be the default DiSEqC positioner.

Definition at line 133 of file positioner.c.

References positioner.

Referenced by cDvbTuner::GetPositioner(), main(), and RecalcPositions().

void cPositioner::GotoAngle ( int  Longitude)
virtual

Move the dish to the given angular position.

Longitude can be in the range -1800...+1800. A positive sign indicates a position east of Greenwich, while western positions have a negative sign. The absolute value is in "degrees * 10", which allows for a resolution of 1/10 of a degree. A derived class must call the base class function to have the target longitude stored.

Reimplemented in cDiseqcPositioner.

Definition at line 107 of file positioner.c.

References dsyslog, StartMovementTimer(), and targetLongitude.

Referenced by cDvbTuner::ExecuteDiseqc(), cDiseqcPositioner::GotoAngle(), and RecalcPositions().

void cPositioner::GotoPosition ( uint  Number,
int  Longitude 
)
virtual

Move the dish to the satellite position stored under the given Number.

Number must be one of the values previously used with StorePosition(). The special value 0 shall move the dish to a "reference position", which usually is due south (or north, if you're on the southern hemisphere). Longitude will be used to calculate how long it takes to move the dish from its current position to the given Longitude. A derived class must call the base class function to have the target longitude stored.

Reimplemented in cDiseqcPositioner.

Definition at line 100 of file positioner.c.

References dsyslog, StartMovementTimer(), and targetLongitude.

Referenced by cDvbTuner::ExecuteDiseqc(), cDiseqcPositioner::GotoPosition(), and RecalcPositions().

virtual void cPositioner::Halt ( void  )
inlinevirtual

Stop any ongoing motion of the dish.

Reimplemented in cDiseqcPositioner.

Definition at line 122 of file positioner.h.

int cPositioner::HardLimitLongitude ( ePositionerDirection  Direction) const

Returns the longitude of the positioner's hard limit in the given Direction.

Note that the value returned here may be larger (or smaller, depending on the Direction) than that returned by HorizonLongitude(), which would mean that it lies below that horizon.

Definition at line 81 of file positioner.c.

References CalcLongitude(), pdLeft, cSetup::PositionerSwing, and Setup.

Referenced by DrawDevicePosition(), and SetFrontend().

int cPositioner::HorizonLongitude ( ePositionerDirection  Direction)
static

Returns the longitude of the satellite position that is just at the horizon when looking in the given Direction.

Note that this function only delivers reasonable values for site latitudes between +/-81 degrees. Beyond these limits (i.e. near the north or south pole) a constant value of 0 will be returned.

Definition at line 69 of file positioner.c.

References DEG, NormalizeAngle(), pdLeft, RAD, SAT_EARTH_RATIO, SAT_VISIBILITY_LAT, Setup, cSetup::SiteLat, and cSetup::SiteLon.

Referenced by DrawDevicePosition(), and SetFrontend().

bool cPositioner::IsMoving ( void  ) const
virtual

Returns true if the dish is currently moving as a result of a call to GotoPosition() or GotoAngle().

Definition at line 127 of file positioner.c.

References CurrentLongitude(), mutex, and targetLongitude.

Referenced by cDvbTuner::ExecuteDiseqc(), cDisplayChannel::ProcessKey(), and RecalcPositions().

int cPositioner::LastLongitude ( void  ) const
inline

Returns the longitude the dish has last been moved to.

Definition at line 103 of file positioner.h.

References lastLongitude.

int cPositioner::NormalizeAngle ( int  Angle)
static

Normalizes the given Angle into the range -1800...1800.

Definition at line 42 of file positioner.c.

Referenced by CalcLongitude(), DrawDevicePosition(), and HorizonLongitude().

virtual void cPositioner::RecalcPositions ( uint  Number)
inlinevirtual

Take the difference between the current actual position of the dish and the position stored with the given Number, and apply the difference to all stored positions.

Reimplemented in cDiseqcPositioner.

Definition at line 135 of file positioner.h.

References CurrentLongitude(), DestroyPositioner(), GetPositioner(), GotoAngle(), GotoPosition(), and IsMoving().

void cPositioner::SetCapabilities ( int  Capabilities)
inlineprotected

A derived class shall call this function in its constructor to set the capability flags it supports.

Definition at line 46 of file positioner.h.

References Capabilities().

Referenced by cDiseqcPositioner::cDiseqcPositioner().

void cPositioner::SetFrontend ( int  Frontend)
inline

This function is called whenever the positioner is connected to a DVB frontend.

Definition at line 89 of file positioner.h.

References Frontend(), HardLimitLongitude(), and HorizonLongitude().

virtual void cPositioner::SetLimit ( ePositionerDirection  Direction)
inlinevirtual

Set the soft limit of the dish movement in the given Direction to the current position.

Reimplemented in cDiseqcPositioner.

Definition at line 124 of file positioner.h.

void cPositioner::StartMovementTimer ( int  Longitude)
protected

Starts a timer that estimates how long it will take to move the dish from the current position to the one given by Longitude.

The default implementation of CurrentLongitude() uses this timer.

Definition at line 86 of file positioner.c.

References CalcHourAngle(), CurrentLongitude(), lastHourAngle, lastLongitude, movementStart, mutex, cSetup::PositionerLastLon, cSetup::PositionerSpeed, cTimeMs::Set(), Setup, swingTime, targetHourAngle, and targetLongitude.

Referenced by Frontend(), GotoAngle(), and GotoPosition().

virtual void cPositioner::Step ( ePositionerDirection  Direction,
uint  Steps = 1 
)
inlinevirtual

Move the dish the given number of Steps in the given Direction.

The maximum number of steps a particular positioner can do in a single call may be limited. A "step" is the smallest possible movement the positioner can make, which is typically 0.1 degrees.

Reimplemented in cDiseqcPositioner.

Definition at line 116 of file positioner.h.

virtual void cPositioner::StorePosition ( uint  Number)
inlinevirtual

Store the current position as a satellite position with the given Number.

Number can be in the range 1...255. However, a particular positioner may only have a limited number of satellite positions it can store.

Reimplemented in cDiseqcPositioner.

Definition at line 131 of file positioner.h.

int cPositioner::TargetLongitude ( void  ) const
inline

Returns the longitude the dish is supposed to be moved to.

Once the target longitude has been reached, this is the same as the value returned by CurrentLongitude().

Definition at line 105 of file positioner.h.

References targetLongitude.

Referenced by DrawDevicePosition().

Member Data Documentation

int cPositioner::capabilities
private

Definition at line 35 of file positioner.h.

Referenced by Capabilities(), and cPositioner().

int cPositioner::frontend
private

Definition at line 36 of file positioner.h.

Referenced by cPositioner(), and Frontend().

int cPositioner::lastHourAngle
mutableprivate

Definition at line 39 of file positioner.h.

Referenced by cPositioner(), CurrentLongitude(), and StartMovementTimer().

int cPositioner::lastLongitude
mutableprivate

Definition at line 37 of file positioner.h.

Referenced by cPositioner(), CurrentLongitude(), LastLongitude(), and StartMovementTimer().

cTimeMs cPositioner::movementStart
private

Definition at line 42 of file positioner.h.

Referenced by CurrentLongitude(), and StartMovementTimer().

cMutex cPositioner::mutex
mutableprivate

Definition at line 33 of file positioner.h.

Referenced by CurrentLongitude(), cScrs::GetUnused(), IsMoving(), and StartMovementTimer().

cPositioner * cPositioner::positioner = NULL
staticprivate

Definition at line 34 of file positioner.h.

Referenced by cPositioner(), DestroyPositioner(), GetPositioner(), and ~cPositioner().

int cPositioner::swingTime
private

Definition at line 41 of file positioner.h.

Referenced by cPositioner(), CurrentLongitude(), and StartMovementTimer().

int cPositioner::targetHourAngle
private

Definition at line 40 of file positioner.h.

Referenced by cPositioner(), CurrentLongitude(), and StartMovementTimer().

int cPositioner::targetLongitude
private

The documentation for this class was generated from the following files: