Skip to content

Commit

Permalink
Remove all 'IS' Functions. (#386)
Browse files Browse the repository at this point in the history
  • Loading branch information
pawel-soja committed Apr 30, 2021
1 parent 1a1fee2 commit daea3b6
Show file tree
Hide file tree
Showing 69 changed files with 441 additions and 4,211 deletions.
153 changes: 28 additions & 125 deletions examples/generic-ccd/generic_ccd.cpp
Expand Up @@ -25,6 +25,8 @@
#include <math.h>
#include <unistd.h>
#include <sys/time.h>
#include <memory>
#include <deque>

#include "config.h"
#include "indidevapi.h"
Expand All @@ -40,9 +42,6 @@
#define TEMP_THRESHOLD .25 /* Differential temperature threshold (C)*/
#define MAX_DEVICES 20 /* Max device cameraCount */

static int cameraCount;
static GenericCCD *cameras[MAX_DEVICES];

/**********************************************************
*
* IMPORRANT: List supported camera models in initializer of deviceTypes structure
Expand All @@ -56,133 +55,37 @@ static struct
const char *name;
} deviceTypes[] = { { 0x0001, 0x0001, "Model 1" }, { 0x0001, 0x0002, "Model 2" }, { 0, 0, nullptr } };

static void cleanup()
{
for (int i = 0; i < cameraCount; i++)
{
delete cameras[i];
}
}

void ISInit()
static class Loader
{
static bool isInit = false;
if (!isInit)
std::deque<std::unique_ptr<GenericCCD>> cameras;
public:
Loader()
{
/**********************************************************
*
* IMPORRANT: If available use CCD API function for enumeration available CCD's otherwise use code like this:
*
**********************************************************
cameraCount = 0;
for (struct usb_bus *bus = usb_get_busses(); bus && cameraCount < MAX_DEVICES; bus = bus->next) {
for (struct usb_device *dev = bus->devices; dev && cameraCount < MAX_DEVICES; dev = dev->next) {
int vid = dev->descriptor.idVendor;
int pid = dev->descriptor.idProduct;
for (int i = 0; deviceTypes[i].pid; i++) {
if (vid == deviceTypes[i].vid && pid == deviceTypes[i].pid) {
cameras[i] = new GenericCCD(dev, deviceTypes[i].name);
break;
}
}
}
}
*/

/**********************************************************
*
* IMPORRANT: If available use CCD API function for enumeration available CCD's otherwise use code like this:
*
**********************************************************
for (struct usb_bus *bus = usb_get_busses(); bus && cameraCount < MAX_DEVICES; bus = bus->next) {
for (struct usb_device *dev = bus->devices; dev && cameraCount < MAX_DEVICES; dev = dev->next) {
int vid = dev->descriptor.idVendor;
int pid = dev->descriptor.idProduct;
for (int i = 0; deviceTypes[i].pid; i++) {
if (vid == deviceTypes[i].vid && pid == deviceTypes[i].pid) {
cameras.push_back(new GenericCCD(dev, deviceTypes[i].name));
break;
}
}
}
}
*/
/* For demo purposes we are creating two test devices */
cameraCount = 2;
struct usb_device *dev = nullptr;
cameras[0] = new GenericCCD(dev, deviceTypes[0].name);
cameras[1] = new GenericCCD(dev, deviceTypes[1].name);

atexit(cleanup);
isInit = true;
cameras.push_back(std::unique_ptr<GenericCCD>(new GenericCCD(dev, deviceTypes[0].name)));
cameras.push_back(std::unique_ptr<GenericCCD>(new GenericCCD(dev, deviceTypes[1].name)));
}
}

void ISGetProperties(const char *dev)
{
ISInit();
for (int i = 0; i < cameraCount; i++)
{
GenericCCD *camera = cameras[i];
if (dev == nullptr || !strcmp(dev, camera->name))
{
camera->ISGetProperties(dev);
if (dev != nullptr)
break;
}
}
}

void ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int num)
{
ISInit();
for (int i = 0; i < cameraCount; i++)
{
GenericCCD *camera = cameras[i];
if (dev == nullptr || !strcmp(dev, camera->name))
{
camera->ISNewSwitch(dev, name, states, names, num);
if (dev != nullptr)
break;
}
}
}

void ISNewText(const char *dev, const char *name, char *texts[], char *names[], int num)
{
ISInit();
for (int i = 0; i < cameraCount; i++)
{
GenericCCD *camera = cameras[i];
if (dev == nullptr || !strcmp(dev, camera->name))
{
camera->ISNewText(dev, name, texts, names, num);
if (dev != nullptr)
break;
}
}
}

void ISNewNumber(const char *dev, const char *name, double values[], char *names[], int num)
{
ISInit();
for (int i = 0; i < cameraCount; i++)
{
GenericCCD *camera = cameras[i];
if (dev == nullptr || !strcmp(dev, camera->name))
{
camera->ISNewNumber(dev, name, values, names, num);
if (dev != nullptr)
break;
}
}
}

void ISNewBLOB(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[],
char *names[], int n)
{
INDI_UNUSED(dev);
INDI_UNUSED(name);
INDI_UNUSED(sizes);
INDI_UNUSED(blobsizes);
INDI_UNUSED(blobs);
INDI_UNUSED(formats);
INDI_UNUSED(names);
INDI_UNUSED(n);
}
void ISSnoopDevice(XMLEle *root)
{
ISInit();

for (int i = 0; i < cameraCount; i++)
{
GenericCCD *camera = cameras[i];
camera->ISSnoopDevice(root);
}
}
} loader;

GenericCCD::GenericCCD(DEVICE device, const char *name)
{
Expand Down
38 changes: 0 additions & 38 deletions indi-aagcloudwatcher-ng/indi_aagcloudwatcher_ng.cpp
Expand Up @@ -1101,41 +1101,3 @@ const char *AAGCloudWatcher::getDefaultName()
{
return "AAG Cloud Watcher NG";
}

void ISGetProperties(const char *dev)
{
cloudWatcher->ISGetProperties(dev);
}

void ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
{
cloudWatcher->ISNewSwitch(dev, name, states, names, n);
}

void ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n)
{
cloudWatcher->ISNewText(dev, name, texts, names, n);
}

void ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
{
cloudWatcher->ISNewNumber(dev, name, values, names, n);
}

void ISNewBLOB(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[],
char *names[], int n)
{
INDI_UNUSED(dev);
INDI_UNUSED(name);
INDI_UNUSED(sizes);
INDI_UNUSED(blobsizes);
INDI_UNUSED(blobs);
INDI_UNUSED(formats);
INDI_UNUSED(names);
INDI_UNUSED(n);
}

void ISSnoopDevice(XMLEle *root)
{
INDI_UNUSED(root);
}
50 changes: 0 additions & 50 deletions indi-aagcloudwatcher-ng/main.cpp
Expand Up @@ -118,53 +118,3 @@ int main(int /*argc*/, char ** /*argv*/)

return 0;
}

void ISGetProperties(const char *dev)
{
INDI_UNUSED(dev);
}

void ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
{
INDI_UNUSED(dev);
INDI_UNUSED(name);
INDI_UNUSED(states);
INDI_UNUSED(names);
INDI_UNUSED(n);
}

void ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n)
{
INDI_UNUSED(dev);
INDI_UNUSED(name);
INDI_UNUSED(texts);
INDI_UNUSED(names);
INDI_UNUSED(n);
}

void ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
{
INDI_UNUSED(dev);
INDI_UNUSED(name);
INDI_UNUSED(values);
INDI_UNUSED(names);
INDI_UNUSED(n);
}

void ISNewBLOB(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[],
char *names[], int n)
{
INDI_UNUSED(dev);
INDI_UNUSED(name);
INDI_UNUSED(sizes);
INDI_UNUSED(blobsizes);
INDI_UNUSED(blobs);
INDI_UNUSED(formats);
INDI_UNUSED(names);
INDI_UNUSED(n);
}

void ISSnoopDevice(XMLEle *root)
{
INDI_UNUSED(root);
}
38 changes: 0 additions & 38 deletions indi-aagcloudwatcher/indi_aagcloudwatcher.cpp
Expand Up @@ -1398,41 +1398,3 @@ const char *AAGCloudWatcher::getDefaultName()
{
return "AAG Cloud Watcher";
}

void ISGetProperties(const char *dev)
{
cloudWatcher->ISGetProperties(dev);
}

void ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
{
cloudWatcher->ISNewSwitch(dev, name, states, names, n);
}

void ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n)
{
cloudWatcher->ISNewText(dev, name, texts, names, n);
}

void ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
{
cloudWatcher->ISNewNumber(dev, name, values, names, n);
}

void ISNewBLOB(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[],
char *names[], int n)
{
INDI_UNUSED(dev);
INDI_UNUSED(name);
INDI_UNUSED(sizes);
INDI_UNUSED(blobsizes);
INDI_UNUSED(blobs);
INDI_UNUSED(formats);
INDI_UNUSED(names);
INDI_UNUSED(n);
}

void ISSnoopDevice(XMLEle *root)
{
INDI_UNUSED(root);
}
30 changes: 0 additions & 30 deletions indi-ahp-correlator/indi_ahp_correlator.cpp
Expand Up @@ -38,36 +38,6 @@
static int nplots = 1;
static std::unique_ptr<AHP_XC> array(new AHP_XC());

void ISGetProperties(const char *dev)
{
array->ISGetProperties(dev);
}

void ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int num)
{
array->ISNewSwitch(dev, name, states, names, num);
}

void ISNewText( const char *dev, const char *name, char *texts[], char *names[], int num)
{
array->ISNewText(dev, name, texts, names, num);
}

void ISNewNumber(const char *dev, const char *name, double values[], char *names[], int num)
{
array->ISNewNumber(dev, name, values, names, num);
}

void ISNewBLOB (const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n)
{
array->ISNewBLOB(dev, name, sizes, blobsizes, blobs, formats, names, n);
}

void ISSnoopDevice (XMLEle *root)
{
array->ISSnoopDevice(root);
}

std::string regex_replace_compat(const std::string &input, const std::string &pattern, const std::string &replace)
{
std::stringstream s;
Expand Down

0 comments on commit daea3b6

Please sign in to comment.