File: LoaderClient.cpp

package info (click to toggle)
indi 2.1.9%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 15,888 kB
  • sloc: cpp: 217,447; ansic: 31,363; xml: 1,195; sh: 311; makefile: 13
file content (88 lines) | stat: -rw-r--r-- 1,880 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include "LoaderClient.h"

#include <cstring>
#include <sstream>

using namespace INDI::AlignmentSubsystem;

LoaderClient::LoaderClient() : DeviceName("skywatcherAPIMount")
{
    //ctor
}

LoaderClient::~LoaderClient()
{
    //dtor
}

// Public methods

void LoaderClient::Initialise(int argc, char *argv[])
{
    std::string HostName("localhost");
    int Port = 7624;

    if (argc > 1)
        DeviceName = argv[1];
    if (argc > 2)
        HostName = argv[2];
    if (argc > 3)
    {
        std::istringstream Parameter(argv[3]);
        Parameter >> Port;
    }

    AlignmentSubsystemForClients::Initialise(DeviceName.c_str(), this);

    setServer(HostName.c_str(), Port);

    watchDevice(DeviceName.c_str());

    connectServer();

    setBLOBMode(B_ALSO, DeviceName.c_str(), nullptr);
}

void LoaderClient::Load()
{
    AlignmentDatabaseEntry CurrentValues;
    AppendSyncPoint(CurrentValues);
    AppendSyncPoint(CurrentValues);
    AppendSyncPoint(CurrentValues);
    CurrentValues.ObservationJulianDate = 128;
    EditSyncPoint(2, CurrentValues);
    CurrentValues.ObservationJulianDate = 256;
    InsertSyncPoint(2, CurrentValues);
    DeleteSyncPoint(0);
    CurrentValues.PrivateData.reset(new unsigned char[50]);
    strcpy((char *)CurrentValues.PrivateData.get(), "This is a test BLOB");
    CurrentValues.PrivateDataSize = strlen((char *)CurrentValues.PrivateData.get()) + 1;
    AppendSyncPoint(CurrentValues);
}

// Protected methods

void LoaderClient::newBLOB(IBLOB *bp)
{
    ProcessNewBLOB(bp);
}

void LoaderClient::newDevice(INDI::BaseDevice *dp)
{
    ProcessNewDevice(dp);
}

void LoaderClient::newNumber(INumberVectorProperty *nvp)
{
    ProcessNewNumber(nvp);
}

void LoaderClient::newProperty(INDI::Property *property)
{
    ProcessNewProperty(property);
}

void LoaderClient::newSwitch(ISwitchVectorProperty *svp)
{
    ProcessNewSwitch(svp);
}