File: MathPluginManagerClient.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 (94 lines) | stat: -rw-r--r-- 2,016 bytes parent folder | download | duplicates (4)
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
89
90
91
92
93
94
#include "MathPluginManagerClient.h"

#include <iostream>

#include <cstring>
#include <sstream>

using namespace INDI::AlignmentSubsystem;

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

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

// Public methods

void MathPluginManagerClient::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 MathPluginManagerClient::Test()
{
    MathPluginsList AvailableMathPlugins;

    cout << "Testing Enumerate available plugins\n";

    if (EnumerateMathPlugins(AvailableMathPlugins))
    {
        cout << "Success - List of plugins follows\n";
        for (MathPluginsList::const_iterator iTr = AvailableMathPlugins.begin(); iTr != AvailableMathPlugins.end();
                iTr++)
            cout << *iTr << '\n';
    }
    else
        cout << "Failure\n";

    cout << "Testing select plugin\n";

    if (SelectMathPlugin(AvailableMathPlugins[AvailableMathPlugins.size() - 1]))
        cout << "Success\n";
    else
        cout << "Failure\n";

    cout << "Testing reinitilialise plugin\n";

    if (ReInitialiseMathPlugin())
        cout << "Success\n";
    else
        cout << "Failure\n";
}

// Protected methods

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

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

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