Esempio n. 1
0
/* add new device */
INDI::BaseDevice * INDI::BaseClientQt::addDevice (XMLEle * dep, char * errmsg)
{
    //devicePtr dp(new INDI::BaseDriver());
    INDI::BaseDevice * dp = new INDI::BaseDevice();
    XMLAtt * ap;
    char * device_name;

    /* allocate new INDI::BaseDriver */
    ap = findXMLAtt (dep, "device");
    if (!ap)
    {
        strncpy(errmsg, "Unable to find device attribute in XML element. Cannot add device.", MAXRBUF);
        return NULL;
    }

    device_name = valuXMLAtt(ap);

    dp->setMediator(this);
    dp->setDeviceName(device_name);

    cDevices.push_back(dp);

    newDevice(dp);

    /* ok */
    return dp;
}
Esempio n. 2
0
/* delete the property in the given device, including widgets and data structs.
 * when last property is deleted, delete the device too.
 * if no property name attribute at all, delete the whole device regardless.
 * return 0 if ok, else -1 with reason in errmsg[].
 */
int INDI::BaseClientQt::delPropertyCmd (XMLEle * root, char * errmsg)
{
    XMLAtt * ap;
    INDI::BaseDevice * dp;

    /* dig out device and optional property name */
    dp = findDev (root, 0, errmsg);
    if (!dp)
        return INDI_DEVICE_NOT_FOUND;

    dp->checkMessage(root);

    ap = findXMLAtt (root, "name");

    /* Delete property if it exists, otherwise, delete the whole device */
    if (ap)
    {
        INDI::Property * rProp = dp->getProperty(valuXMLAtt(ap));
        removeProperty(rProp);
        int errCode = dp->removeProperty(valuXMLAtt(ap), errmsg);

        return errCode;
    }
    // delete the whole device
    else
        return deleteDevice(dp->getDeviceName(), errmsg);
}
Esempio n. 3
0
/* a general message command received from the device.
 * return 0 if ok, else -1 with reason in errmsg[].
 */
int INDI::BaseClientQt::messageCmd (XMLEle * root, char * errmsg)
{
    INDI::BaseDevice * dp =findDev (root, 0, errmsg);

    if (dp)
        dp->checkMessage(root);

    return (0);
}
Esempio n. 4
0
void Mount::updateLog(int messageID)
{
    INDI::BaseDevice *dv = currentTelescope->getBaseDevice();

    QString message = QString::fromStdString(dv->messageQueue(messageID));

    logText.insert(0, i18nc("Message shown in Ekos Mount module", "%1", message));

    emit newLog();
}
Esempio n. 5
0
void INDI::BaseClientQt::setDriverConnection(bool status, const char * deviceName)
{
    INDI::BaseDevice * drv = getDevice(deviceName);
    ISwitchVectorProperty * drv_connection = NULL;

    if (drv == NULL)
    {
        IDLog("INDI::BaseClientQt: Error. Unable to find driver %s\n", deviceName);
        return;
    }

    drv_connection = drv->getSwitch("CONNECTION");

    if (drv_connection == NULL)
        return;

    // If we need to connect
    if (status)
    {
        // If there is no need to do anything, i.e. already connected.
        if (drv_connection->sp[0].s == ISS_ON)
            return;

        IUResetSwitch(drv_connection);
        drv_connection->s = IPS_BUSY;
        drv_connection->sp[0].s = ISS_ON;
        drv_connection->sp[1].s = ISS_OFF;

        sendNewSwitch(drv_connection);
    }
    else
    {
        // If there is no need to do anything, i.e. already disconnected.
        if (drv_connection->sp[1].s == ISS_ON)
            return;

        IUResetSwitch(drv_connection);
        drv_connection->s = IPS_BUSY;
        drv_connection->sp[0].s = ISS_OFF;
        drv_connection->sp[1].s = ISS_ON;

        sendNewSwitch(drv_connection);

    }
}
Esempio n. 6
0
void IndiGui::OnNewDeviceFromThread(wxThreadEvent& event)
{
    INDI::BaseDevice *dp = (INDI::BaseDevice *) event.GetExtraLong();
    //printf("newdevice from thread %s \n",dp->getDeviceName());
    wxString devname =  wxString::FromAscii(dp->getDeviceName());
    IndiDev *indiDev = new IndiDev();
    wxPanel *panel = new wxPanel(parent_notebook);
    indiDev->page = new wxNotebook(panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP);
    wxBoxSizer *nb_sizer = new wxBoxSizer(wxVERTICAL);
    panel->SetSizer(nb_sizer);
    nb_sizer->Add(indiDev->page, 1,  wxEXPAND | wxALL);
    parent_notebook->AddPage(panel, devname);
    indiDev->dp = dp;
    devlist[devname] = indiDev;
    panel->Fit();
    sizer->Layout();
    Fit();
}
Esempio n. 7
0
void INDI::BaseClientQt::sendNewText (const char * deviceName, const char * propertyName, const char * elementName, const char * text)
{
    INDI::BaseDevice * drv = getDevice(deviceName);

    if (drv == NULL)
        return;

    ITextVectorProperty * tvp = drv->getText(propertyName);

    if (tvp == NULL)
        return;

    IText * tp = IUFindText(tvp, elementName);

    if (tp == NULL)
        return;

    IUSaveText(tp, text);

    sendNewText(tvp);
}
Esempio n. 8
0
void INDI::BaseClientQt::sendNewSwitch (const char * deviceName, const char * propertyName, const char * elementName)
{
    INDI::BaseDevice * drv = getDevice(deviceName);

    if (drv == NULL)
        return;

    ISwitchVectorProperty * svp = drv->getSwitch(propertyName);

    if (svp == NULL)
        return;

    ISwitch * sp = IUFindSwitch(svp, elementName);

    if (sp == NULL)
        return;

    sp->s = ISS_ON;

    sendNewSwitch(svp);

}
Esempio n. 9
0
void INDI::BaseClientQt::sendNewNumber (const char * deviceName, const char * propertyName, const char * elementName, double value)
{
    INDI::BaseDevice * drv = getDevice(deviceName);

    if (drv == NULL)
        return;

    INumberVectorProperty * nvp = drv->getNumber(propertyName);

    if (nvp == NULL)
        return;

    INumber * np = IUFindNumber(nvp, elementName);

    if (np == NULL)
        return;

    np->value = value;

    sendNewNumber(nvp);

}
Esempio n. 10
0
int INDI::BaseClientQt::dispatchCommand(XMLEle * root, char * errmsg)
{
    if  (!strcmp (tagXMLEle(root), "message"))
        return messageCmd(root, errmsg);
    else if  (!strcmp (tagXMLEle(root), "delProperty"))
        return delPropertyCmd(root, errmsg);
    // Just ignore any getProperties we might get
    else if  (!strcmp (tagXMLEle(root), "getProperties"))
        return INDI_PROPERTY_DUPLICATED;

    /* Get the device, if not available, create it */
    INDI::BaseDevice * dp = findDev (root, 1, errmsg);
    if (dp == NULL)
    {
        strcpy(errmsg,"No device available and none was created");
        return INDI_DEVICE_NOT_FOUND;
    }

    // FIXME REMOVE THIS

    // Ignore echoed newXXX and getProperties
    if (strstr(tagXMLEle(root), "new") ||strstr(tagXMLEle(root), "getProperties"))
        return 0;

    if ((!strcmp (tagXMLEle(root), "defTextVector"))  ||
            (!strcmp (tagXMLEle(root), "defNumberVector")) ||
            (!strcmp (tagXMLEle(root), "defSwitchVector")) ||
            (!strcmp (tagXMLEle(root), "defLightVector"))  ||
            (!strcmp (tagXMLEle(root), "defBLOBVector")))
        return dp->buildProp(root, errmsg);
    else if (!strcmp (tagXMLEle(root), "setTextVector") ||
             !strcmp (tagXMLEle(root), "setNumberVector") ||
             !strcmp (tagXMLEle(root), "setSwitchVector") ||
             !strcmp (tagXMLEle(root), "setLightVector") ||
             !strcmp (tagXMLEle(root), "setBLOBVector"))
        return dp->setValue(root, errmsg);

    return INDI_DISPATCH_ERROR;
}