Bi-monthly release with minor bug fixes and improvements
void IndiClient::newDevice(INDI::BaseDevice baseDevice)
{
auto interface = baseDevice->getDriverInterface();
if (interface == INDI::BaseDevice::TELESCOPE_INTERFACE)
{
IDLog("New Device: %s\n", baseDevice->getDeviceName());
}
}
void IndiClient::serverConnected()
{
IDLog("Server Connected\n\n");
IDLog("Listing mounts:\n");
std::vector<INDI::BaseDevice> mounts;
getDevices(mounts, INDI::BaseDevice::TELESCOPE_INTERFACE);
for (INDI::BaseDevice *device : mounts)
printf("Mount Name: %s\n", device->getDeviceName());
IDLog("Listing cameras:\n");
std::vector<INDI::BaseDevice> cameras;
getDevices(cameras, INDI::BaseDevice::CCD_INTERFACE);
for (INDI::BaseDevice *device : cameras)
printf("Camera Name: %s\n", device->getDeviceName());
}
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
auto interface = baseDevice->getDriverInterface();
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
// ************************************************************************
// The following methods are called by the server as various states change.
// ************************************************************************
void IndiClient::newDevice(INDI::BaseDevice baseDevice)
{
//IDLog("New Device: %s\n", baseDevice.getDeviceName());
}
void IndiClient::removeDevice(INDI::BaseDevice baseDevice)
{
IDLog("Remove Device: %s\n", baseDevice.getDeviceName());
string removedDeviceName = baseDevice.getDeviceName();
if (baseDevice.getDriverInterface() & BaseDevice::TELESCOPE_INTERFACE)
{
auto &mountNames = pNanoverse->_indiMountNames;
for (int i = 0; i < mountNames.size(); i++)
{
if (removedDeviceName == mountNames[i])
{
mountNames.erase(mountNames.begin() + i);
}
}
IDLog("\n");
}
else if (baseDevice.getDriverInterface() & BaseDevice::CCD_INTERFACE)
{
auto &cameraNames = pNanoverse->_indiCameraNames;
for (int i = 0; i < cameraNames.size(); i++)
{
if (removedDeviceName == cameraNames[i])
{
cameraNames.erase(cameraNames.begin() + i);
}
}
}
}
void IndiClient::newProperty(INDI::Property property)
{
IDLog("New Property: %s\n", property.getName());
auto baseDevice = property.getBaseDevice();
auto deviceName = baseDevice.getDeviceName();
if (property.isNameMatch("DRIVER_INFO"))
{
auto interface = baseDevice.getDriverInterface();
if (interface & BaseDevice::TELESCOPE_INTERFACE)
{
IDLog("Found telescope: %s\n", deviceName);
pNanoverse->_indiMountNames.push_back(deviceName);
}
else if (interface & BaseDevice::CCD_INTERFACE)
{
IDLog("Found camera: %s\n", deviceName);
pNanoverse->_indiCameraNames.push_back(deviceName);
setBLOBMode(B_ALSO, deviceName, nullptr);
enableDirectBlobAccess(deviceName, nullptr);
}
}
// Handle Telescope properties
if (baseDevice.getDriverInterface() & BaseDevice::TELESCOPE_INTERFACE)
{
if (property.isNameMatch("SYSTEM_PORTS"))
{
IDLog("Found system ports for %s\n", deviceName);
INDI::PropertyView<ISwitch> systemPorts = *(baseDevice.getSwitch("SYSTEM_PORTS"));
vector<string> ports;
for (auto &port : systemPorts)
{
ports.push_back(port.name);
}
pNanoverse->_indiSerialPortsMap.insert({deviceName, ports});
}
else if (property.isNameMatch("DEVICE_PORT"))
{
string portName = baseDevice.getText("DEVICE_PORT").at(0)->getText();
pNanoverse->_indiCurrentSerialPortsMap.insert({deviceName, portName});
}
}
}
void IndiClient::updateProperty(INDI::Property property)
{
if (property.isNameMatch("MOUNT_AXES"))
{
return;
}
//IDLog("Update Property: %s\n", property.getName());
auto device = property.getBaseDevice();
if (device.isDeviceNameMatch(pNanoverse->_indiCurrentMountName.c_str()) && property.isNameMatch("EQUATORIAL_EOD_COORD"))
{
double raInHours = IUFindNumber(property, "RA")->value;
double decInDegrees = IUFindNumber(property, "DEC")->value;
IDLog("Updated Coords. ra = %f; dec = %f\n", raInHours, decInDegrees);
setScopeRA(SSAngle::fromHours(raInHours));
setScopeDec(SSAngle::fromDegrees(decInDegrees));
}
}
void IndiClient::removeProperty(INDI::Property property)
{
//IDLog("Remove Property: %s\n", property.getName());
}
void IndiClient::newMessage(INDI::BaseDevice baseDevice, int messageID)
{
//IDLog("Receiving message from Server:\n %s\n\n", baseDevice.messageQueue(messageID).c_str());
}
void IndiClient::serverConnected()
{
IDLog("Server Connected\n\n");
}
void IndiClient::serverDisconnected(int exit_code)
{
IDLog("Server Disconnected with code: %d", exit_code);
resetMountNames();
}
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
import PyIndi
import time
class IndiClient(PyIndi.BaseClient):
def __init__(self):
super(IndiClient, self).__init__()
def newDevice(self, d):
pass
def newBLOB(self, bp):
pass
def newSwitch(self, svp):
pass
def newNumber(self, nvp):
pass
def newMessage(self, d, m):
pass
def serverConnected(self):
pass
def serverDisconnected(self, code):
pass
def newProperty(self,property):
baseDevice = property.getBaseDevice()
deviceName = baseDevice.getDeviceName()
if(property.getName()=="DRIVER_INFO"):
interface = baseDevice.getDriverInterface()
if(interface & PyIndi.BaseDevice.CCD_INTERFACE):
print("Found camera:" + deviceName)
# connect the server
indiclient=IndiClient()
indiclient.setServer("localhost",7624)
indiclient.connectServer()
# Let's take some pictures
ccd="Nikon DSLR DSC D5100 (PTP mode)"
device_ccd=indiclient.getDevice(ccd)
while not(device_ccd):
time.sleep(0.5)
device_ccd=indiclient.getDevice(ccd)
ccd_connect=device_ccd.getSwitch("CONNECTION")
while not(ccd_connect):
time.sleep(0.5)
ccd_connect=device_ccd.getSwitch("CONNECTION")
if not(device_ccd.isConnected()):
ccd_connect[0].s=PyIndi.ISS_ON # the "CONNECT" switch
ccd_connect[1].s=PyIndi.ISS_OFF # the "DISCONNECT" switch
indiclient.sendNewSwitch(ccd_connect)
ccd_exposure=device_ccd.getNumber("CCD_EXPOSURE")
# while not(ccd_exposure):
# time.sleep(0.5)
# ccd_exposure=device_ccd.getNumber("CCD_EXPOSURE")
# we should inform the indi server that we want to receive the
# "CCD1" blob from this device
indiclient.setBLOBMode(PyIndi.B_ALSO, ccd, "CCD1")
ccd_ccd1=device_ccd.getBLOB("CCD1")
# while not(ccd_ccd1):
# time.sleep(0.5)
# ccd_ccd1=device_ccd.getBLOB("CCD1")
ccd_exposure[0].value=1.0
indiclient.sendNewNumber(ccd_exposure)
ccd_dis_connect=device_ccd.getSwitch("DISCONNECTION")
while not(ccd_dis_connect):
time.sleep(0.5)
ccd_dis_connect=device_ccd.getSwitch("DISCONNECTION")
print("try disconnect")
print("disconnect!")
#include "nikon_client.h"
#include <basedevice.h>
#include <unistd.h> // sleep lib
#include <string>
#include <fstream>
#include <iostream>
#include <memory>
int main(int, char *[])
{
IndiClient indiclient;
indiclient.setServer("localhost", 7624);
indiclient.connectServer();
char ccd[]="Nikon DSLR DSC D5100 (PTP mode)";
INDI::BaseDevice device_ccd = indiclient.getDevice(ccd);
while(!device_ccd){
sleep(0.5);
device_ccd=indiclient.getDevice(ccd);
}
INDI::PropertySwitch ccd_connect=device_ccd.getSwitch("CONNECTION");
while(!ccd_connect){
sleep(0.5);
ccd_connect=device_ccd.getSwitch("CONNECTION");
}
if(!device_ccd.isConnected()){
ccd_connect[0].s=ISS_ON;
ccd_connect[1].s=ISS_OFF;
indiclient.sendNewSwitch(ccd_connect);
}
INDI::PropertyNumber ccd_exposure=device_ccd.getNumber("CCD_EXPOSURE");
indiclient.setBLOBMode(B_ALSO,ccd,"CCD1");
INDI::PropertyBlob ccd_ccd1=device_ccd.getBLOB("CCD1");
while(!ccd_ccd1){
sleep(0.5);
ccd_ccd1=device_ccd.getBLOB("CCD1");
}
ccd_exposure[0].value=1.0;
std::cout << "777.\n";
indiclient.sendNewNumber(ccd_exposure);
std::cout << "888.\n";
INDI::PropertySwitch ccd_dis_connect=device_ccd.getSwitch("DISCONNECTION");
while(!ccd_dis_connect){
sleep(0.5);
ccd_dis_connect=device_ccd.getSwitch("DISCONNECTION");
std::cout << "Try disconnect.\n";
}
std::cout << "Press Enter key to terminate the client.\n";
std::cin.ignore();
}
IndiClient::IndiClient():BaseClient()
{
}
void IndiClient::newDevice(INDI::BaseDevice baseDevice)
{
return;
}
void IndiClient::newBLOB(IBLOB *bp)
{
return;
}
void IndiClient::newSwitch(ISwitchVectorProperty *svp)
{
return;
}
void IndiClient::newNumber(INumberVectorProperty *nvp)
{
return;
}
void IndiClient::newMessage(INDI::BaseDevice *dp, int messageID)
{
return;
}
void IndiClient::serverConnected()
{
return;
}
void IndiClient::serverDisconnected(int exit_code)
{
return;
}
void IndiClient::newProperty(INDI::Property property)
{
auto baseDevice = property.getBaseDevice();
auto deviceName = baseDevice.getDeviceName();
// With DRIVER_INFO defined, we have access to getDriverInterface()
if (property.isNameMatch("DRIVER_INFO"))
{
auto interface = baseDevice.getDriverInterface();
if(interface & INDI::BaseDevice::CCD_INTERFACE)
{
IDLog("Found camera: %s\n", deviceName);
}
}
}
#include "baseclient.h"
#include <basedevice.h>
class IndiClient : public INDI::BaseClient
{
public:
IndiClient();
~IndiClient() = default;
public:
void newDevice(INDI::BaseDevice baseDevice);
void newBLOB(IBLOB *bp);
void newSwitch(ISwitchVectorProperty *svp);
void newNumber(INumberVectorProperty *nvp);
void newMessage(INDI::BaseDevice *dp, int messageID);
void serverConnected();
void serverDisconnected(int exit_code);
void newProperty(INDI::Property property);
};
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.