Instrument Neutral Distributed Interface INDI 2.2.5
LoaderClient.cpp
Go to the documentation of this file.
1#include "LoaderClient.h"
2
3#include <cstring>
4#include <sstream>
5
6using namespace INDI::AlignmentSubsystem;
7
8LoaderClient::LoaderClient() : DeviceName("skywatcherAPIMount")
9{
10 //ctor
11}
12
14{
15 //dtor
16}
17
18// Public methods
19
20void 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
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);
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{
68}
69
74
79
81{
82 ProcessNewProperty(property);
83}
84
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 Initialise(const char *DeviceName, INDI::BaseClient *BaseClient)
This routine should be called before any connections to devices are made.
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.
Class to provide basic INDI device functionality.
Definition basedevice.h:52
Provides generic container for INDI properties.
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:269
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:317
Switch vector property descriptor.
Definition indiapi.h:365