Instrument Neutral Distributed Interface INDI 2.2.5
alpaca_client.cpp
Go to the documentation of this file.
1/*******************************************************************************
2 Copyright(c) 2025 Jasem Mutlaq. All rights reserved.
3
4 INDI Alpaca Client
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2 of the License, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20
21 The full GNU General Public License is included in this distribution in the
22 file called LICENSE.
23*******************************************************************************/
24
25#include "alpaca_client.h"
26#include "device_manager.h"
27#include "indilogger.h"
28
30 : m_DeviceManager(deviceManager)
31{
32 DEBUGDEVICE("INDI Alpaca Server", INDI::Logger::DBG_SESSION, "Alpaca client initialized");
33}
34
36{
37 DEBUGDEVICE("INDI Alpaca Server", INDI::Logger::DBG_SESSION, "Alpaca client destroyed");
38}
39
41{
42 DEBUGDEVICE("INDI Alpaca Server", INDI::Logger::DBG_SESSION, "Connecting to INDI server");
44}
45
47{
48 DEBUGDEVICE("INDI Alpaca Server", INDI::Logger::DBG_SESSION, "Disconnecting from INDI server");
49 return INDI::BaseClient::disconnectServer(exit_code);
50}
51
53{
54 // Do not process our own driver at all
55 if (!strcmp(dp.getDeviceName(), "INDI Alpaca Server"))
56 return;
57
58 setBLOBMode(B_ALSO, dp.getDeviceName(), nullptr);
60
61 DEBUGFDEVICE("INDI Alpaca Server", INDI::Logger::DBG_SESSION, "New device: %s", dp.getDeviceName());
62 m_DeviceManager->addDevice(dp);
63}
64
66{
67 DEBUGFDEVICE("INDI Alpaca Server", INDI::Logger::DBG_SESSION, "Remove device: %s", dp.getDeviceName());
68 m_DeviceManager->removeDevice(dp);
69}
70
72{
73 DEBUGFDEVICE("INDI Alpaca Server", INDI::Logger::DBG_DEBUG, "New property: %s.%s", property.getDeviceName(),
74 property.getName());
75 m_DeviceManager->updateDeviceProperty(property);
76}
77
79{
80 DEBUGFDEVICE("INDI Alpaca Server", INDI::Logger::DBG_DEBUG, "Remove property: %s.%s", property.getDeviceName(),
81 property.getName());
82}
83
85{
86 DEBUGFDEVICE("INDI Alpaca Server", INDI::Logger::DBG_DEBUG, "Update property: %s.%s", property.getDeviceName(),
87 property.getName());
88 m_DeviceManager->updateDeviceProperty(property);
89}
90
92{
93 DEBUGDEVICE("INDI Alpaca Server", INDI::Logger::DBG_SESSION, "Connected to INDI server");
94}
95
97{
98 DEBUGFDEVICE("INDI Alpaca Server", INDI::Logger::DBG_SESSION, "Disconnected from INDI server (exit code: %d)", exitCode);
99}
void serverConnected() override
Emmited when the server is connected.
void updateProperty(INDI::Property property) override
Emmited when a new property value arrives from INDI server.
AlpacaClient(DeviceManager *deviceManager)
void serverDisconnected(int exitCode) override
Emmited when the server gets disconnected.
bool connectServer() override
Connect to INDI server.
void removeDevice(INDI::BaseDevice dp) override
Emmited when a device is deleted from INDI server.
void newProperty(INDI::Property property) override
Emmited when a new property is created for an INDI driver.
void removeProperty(INDI::Property property) override
Emmited when a property is deleted for an INDI driver.
void newDevice(INDI::BaseDevice dp) override
Emmited when a new device is created from INDI server.
bool disconnectServer(int exist_code=0) override
Disconnect from INDI server. Any devices previously created will be deleted and memory cleared.
void addDevice(INDI::BaseDevice device)
void removeDevice(INDI::BaseDevice device)
void updateDeviceProperty(INDI::Property property)
void setBLOBMode(BLOBHandling blobH, const char *dev, const char *prop=nullptr)
Set Binary Large Object policy mode.
void enableDirectBlobAccess(const char *dev=nullptr, const char *prop=nullptr)
activate zero-copy delivering of the blob content. When enabled, all blob copy will be avoided when p...
bool disconnectServer(int exit_code=0) override
Disconnect from INDI server. Any devices previously created will be deleted and memory cleared.
bool connectServer() override
Connect to INDI server.
Class to provide basic INDI device functionality.
Definition basedevice.h:52
const char * getDeviceName() const
Provides generic container for INDI properties.
const char * getDeviceName() const
const char * getName() const
@ B_ALSO
Definition indidevapi.h:269
#define DEBUGDEVICE(device, priority, msg)
Definition indilogger.h:60
#define DEBUGFDEVICE(device, priority, msg,...)
Definition indilogger.h:61