Instrument Neutral Distributed Interface INDI  2.0.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 }
void setServer(const char *hostname, unsigned int port)
Set the server host name and port.
void setBLOBMode(BLOBHandling blobH, const char *dev, const char *prop=nullptr)
Set Binary Large Object policy mode.
void watchDevice(const char *deviceName)
Add a device to the watch list.
void ProcessNewProperty(INDI::Property *PropertyPointer)
Process new property message from driver. This routine should be called from within the newProperty h...
void ProcessNewNumber(INumberVectorProperty *NumberVectorPropertyPointer)
Process new number message from driver. This routine should be called from within the newNumber handl...
void ProcessNewSwitch(ISwitchVectorProperty *SwitchVectorPropertyPointer)
Process new switch message from driver. This routine should be called from within the newSwitch handl...
void ProcessNewDevice(INDI::BaseDevice *DevicePointer)
Process new device message from driver. This routine should be called from within the newDevice handl...
void ProcessNewBLOB(IBLOB *BLOBPointer)
Process new BLOB message from driver. This routine should be called from within the newBLOB handler i...
bool AppendSyncPoint(const AlignmentDatabaseEntry &CurrentValues)
Append a sync point to the database.
bool InsertSyncPoint(unsigned int Offset, const AlignmentDatabaseEntry &CurrentValues)
Insert a sync point in the database.
bool EditSyncPoint(unsigned int Offset, const AlignmentDatabaseEntry &CurrentValues)
Edit a sync point in the database.
bool DeleteSyncPoint(unsigned int Offset)
Delete a sync point from the database.
bool connectServer() override
Connect to INDI server.
Definition: baseclient.cpp:308
Class to provide basic INDI device functionality.
Definition: basedevice.h:52
Provides generic container for INDI properties.
Definition: indiproperty.h:48
virtual void newNumber(INumberVectorProperty *nvp)
Emmited when a new number value arrives from INDI server.
virtual void newSwitch(ISwitchVectorProperty *svp)
Emmited when a new switch value arrives from INDI server.
virtual ~LoaderClient()
virtual void newBLOB(IBLOB *bp)
Emmited when a new property value arrives from INDI server.
void Initialise(int argc, char *argv[])
virtual void newDevice(INDI::BaseDevice *dp)
Emmited when a new device is created from INDI server.
virtual void newProperty(INDI::Property *property)
Emmited when a new property is created for an INDI driver.
@ B_ALSO
Definition: indidevapi.h:268
Namespace to encapsulate the INDI Alignment Subsystem classes. For more information see "INDI Alignme...
One Blob (Binary Large Object) descriptor.
Entry in the in memory alignment database.
Definition: Common.h:152
int PrivateDataSize
This size in bytes of any private data.
Definition: Common.h:203
std::unique_ptr< unsigned char > PrivateData
Private data associated with this sync point.
Definition: Common.h:200
Number vector property descriptor.
Definition: indiapi.h:319
Switch vector property descriptor.
Definition: indiapi.h:367