Instrument Neutral Distributed Interface INDI  1.9.2
LoaderClient.cpp
Go to the documentation of this file.
1 #include "LoaderClient.h"
2 
3 #include <cstring>
4 #include <sstream>
5 
6 using namespace INDI::AlignmentSubsystem;
7 
8 LoaderClient::LoaderClient() : DeviceName("skywatcherAPIMount")
9 {
10  //ctor
11 }
12 
14 {
15  //dtor
16 }
17 
18 // Public methods
19 
20 void LoaderClient::Initialise(int argc, char *argv[])
21 {
22  std::string HostName("localhost");
23  int Port = 7624;
24 
25  if (argc > 1)
26  DeviceName = argv[1];
27  if (argc > 2)
28  HostName = argv[2];
29  if (argc > 3)
30  {
31  std::istringstream Parameter(argv[3]);
32  Parameter >> Port;
33  }
34 
35  AlignmentSubsystemForClients::Initialise(DeviceName.c_str(), this);
36 
37  setServer(HostName.c_str(), Port);
38 
39  watchDevice(DeviceName.c_str());
40 
41  connectServer();
42 
43  setBLOBMode(B_ALSO, DeviceName.c_str(), nullptr);
44 }
45 
47 {
48  AlignmentDatabaseEntry CurrentValues;
49  AppendSyncPoint(CurrentValues);
50  AppendSyncPoint(CurrentValues);
51  AppendSyncPoint(CurrentValues);
52  CurrentValues.ObservationJulianDate = 128;
53  EditSyncPoint(2, CurrentValues);
54  CurrentValues.ObservationJulianDate = 256;
55  InsertSyncPoint(2, CurrentValues);
56  DeleteSyncPoint(0);
57  CurrentValues.PrivateData.reset(new unsigned char[50]);
58  strcpy((char *)CurrentValues.PrivateData.get(), "This is a test BLOB");
59  CurrentValues.PrivateDataSize = strlen((char *)CurrentValues.PrivateData.get()) + 1;
60  AppendSyncPoint(CurrentValues);
61 }
62 
63 // Protected methods
64 
66 {
67  ProcessNewBLOB(bp);
68 }
69 
71 {
72  ProcessNewDevice(dp);
73 }
74 
76 {
77  ProcessNewNumber(nvp);
78 }
79 
81 {
82  ProcessNewProperty(property);
83 }
84 
86 {
87  ProcessNewSwitch(svp);
88 }
LoaderClient::newDevice
virtual void newDevice(INDI::BaseDevice *dp)
Emmited when a new device is created from INDI server.
Definition: LoaderClient.cpp:70
INDI::AlignmentSubsystem::AlignmentDatabaseEntry
Entry in the in memory alignment database.
Definition: Common.h:145
LoaderClient::newProperty
virtual void newProperty(INDI::Property *property)
Emmited when a new property is created for an INDI driver.
Definition: LoaderClient.cpp:80
INDI::AlignmentSubsystem::AlignmentSubsystemForClients::ProcessNewSwitch
void ProcessNewSwitch(ISwitchVectorProperty *SwitchVectorPropertyPointer)
Process new switch message from driver. This routine should be called from within the newSwitch handl...
Definition: AlignmentSubsystemForClients.cpp:60
LoaderClient::Load
void Load()
Definition: LoaderClient.cpp:46
INDI::AlignmentSubsystem::AlignmentDatabaseEntry::PrivateDataSize
int PrivateDataSize
This size in bytes of any private data.
Definition: Common.h:197
INDI::AlignmentSubsystem
Namespace to encapsulate the INDI Alignment Subsystem classes. For more information see "INDI Alignme...
Definition: AlignmentSubsystemForClients.cpp:13
INDI::Property
Provides generic container for INDI properties.
Definition: indiproperty.h:43
INDI::BaseClient::watchDevice
void watchDevice(const char *deviceName)
Add a device to the watch list.
Definition: baseclient.cpp:863
INDI::AlignmentSubsystem::ClientAPIForAlignmentDatabase::DeleteSyncPoint
bool DeleteSyncPoint(unsigned int Offset)
Delete a sync point from the database.
Definition: ClientAPIForAlignmentDatabase.cpp:108
_INumberVectorProperty
Number vector property descriptor.
Definition: indiapi.h:317
B_ALSO
@ B_ALSO
Definition: indidevapi.h:271
LoaderClient::newSwitch
virtual void newSwitch(ISwitchVectorProperty *svp)
Emmited when a new switch value arrives from INDI server.
Definition: LoaderClient.cpp:85
LoaderClient.h
INDI::AlignmentSubsystem::AlignmentDatabaseEntry::PrivateData
std::unique_ptr< unsigned char > PrivateData
Private data associated with this sync point.
Definition: Common.h:194
INDI::BaseClient::setBLOBMode
void setBLOBMode(BLOBHandling blobH, const char *dev, const char *prop=nullptr)
Set Binary Large Object policy mode.
Definition: baseclient.cpp:1066
LoaderClient::newNumber
virtual void newNumber(INumberVectorProperty *nvp)
Emmited when a new number value arrives from INDI server.
Definition: LoaderClient.cpp:75
INDI::AlignmentSubsystem::AlignmentSubsystemForClients::ProcessNewBLOB
void ProcessNewBLOB(IBLOB *BLOBPointer)
Process new BLOB message from driver. This routine should be called from within the newBLOB handler i...
Definition: AlignmentSubsystemForClients.cpp:22
LoaderClient::newBLOB
virtual void newBLOB(IBLOB *bp)
Emmited when a new BLOB value arrives from INDI server.
Definition: LoaderClient.cpp:65
INDI::AlignmentSubsystem::ClientAPIForAlignmentDatabase::InsertSyncPoint
bool InsertSyncPoint(unsigned int Offset, const AlignmentDatabaseEntry &CurrentValues)
Insert a sync point in the database.
Definition: ClientAPIForAlignmentDatabase.cpp:223
LoaderClient::~LoaderClient
virtual ~LoaderClient()
Definition: LoaderClient.cpp:13
INDI::AlignmentSubsystem::ClientAPIForAlignmentDatabase::EditSyncPoint
bool EditSyncPoint(unsigned int Offset, const AlignmentDatabaseEntry &CurrentValues)
Edit a sync point in the database.
Definition: ClientAPIForAlignmentDatabase.cpp:159
INDI::AlignmentSubsystem::AlignmentSubsystemForClients::ProcessNewProperty
void ProcessNewProperty(INDI::Property *PropertyPointer)
Process new property message from driver. This routine should be called from within the newProperty h...
Definition: AlignmentSubsystemForClients.cpp:50
INDI::AlignmentSubsystem::AlignmentSubsystemForClients::ProcessNewNumber
void ProcessNewNumber(INumberVectorProperty *NumberVectorPropertyPointer)
Process new number message from driver. This routine should be called from within the newNumber handl...
Definition: AlignmentSubsystemForClients.cpp:41
LoaderClient::LoaderClient
LoaderClient()
Definition: LoaderClient.cpp:8
LoaderClient::Initialise
void Initialise(int argc, char *argv[])
Definition: LoaderClient.cpp:20
INDI::BaseClient::setServer
void setServer(const char *hostname, unsigned int port)
Set the server host name and port.
Definition: baseclient.cpp:856
INDI::AlignmentSubsystem::AlignmentDatabaseEntry::ObservationJulianDate
double ObservationJulianDate
Definition: Common.h:180
INDI::AlignmentSubsystem::ClientAPIForAlignmentDatabase::AppendSyncPoint
bool AppendSyncPoint(const AlignmentDatabaseEntry &CurrentValues)
Append a sync point to the database.
Definition: ClientAPIForAlignmentDatabase.cpp:29
INDI::BaseDevice
Class to provide basic INDI device functionality.
Definition: basedevice.h:45
INDI::AlignmentSubsystem::AlignmentSubsystemForClients::ProcessNewDevice
void ProcessNewDevice(INDI::BaseDevice *DevicePointer)
Process new device message from driver. This routine should be called from within the newDevice handl...
Definition: AlignmentSubsystemForClients.cpp:31
IBLOB
One Blob (Binary Large Object) descriptor.
_ISwitchVectorProperty
Switch vector property descriptor.
Definition: indiapi.h:365
INDI::BaseClient::connectServer
bool connectServer()
Connect to INDI server.
Definition: baseclient.cpp:876