• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ IDSetSwitch函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中IDSetSwitch函数的典型用法代码示例。如果您正苦于以下问题:C++ IDSetSwitch函数的具体用法?C++ IDSetSwitch怎么用?C++ IDSetSwitch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了IDSetSwitch函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: IDSetNumber

/************************************************************************************
 *
* ***********************************************************************************/
bool BaaderDome::SetupParms()
{
    targetAz = 0;

    if (UpdatePosition())
        IDSetNumber(&DomeAbsPosNP, nullptr);

    if (UpdateShutterStatus())
        IDSetSwitch(&DomeShutterSP, nullptr);

    if (UpdateFlapStatus())
        IDSetSwitch(&DomeFlapSP, nullptr);

    if (InitPark())
    {
        // If loading parking data is successful, we just set the default parking values.
        SetAxis1ParkDefault(0);
    }
    else
    {
        // Otherwise, we set all parking data to default in case no parking data is found.
        SetAxis1Park(0);
        SetAxis1ParkDefault(0);
    }

    return true;
}
开发者ID:rrogge,项目名称:indi,代码行数:30,代码来源:baader_dome.cpp


示例2: INDI_UNUSED

bool FocuserInterface::processSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
{
    INDI_UNUSED(dev);
    //  This one is for us
    if (strcmp(name, "FOCUS_MOTION") == 0)
    {
        // Record last direction and state.
        FocusDirection prevDirection = FocusMotionS[FOCUS_INWARD].s == ISS_ON ? FOCUS_INWARD : FOCUS_OUTWARD;
        IPState prevState = FocusMotionSP.s;

        IUUpdateSwitch(&FocusMotionSP, states, names, n);

        FocusDirection targetDirection = FocusMotionS[FOCUS_INWARD].s == ISS_ON ? FOCUS_INWARD : FOCUS_OUTWARD;

        if (CanRelMove() || CanAbsMove() || HasVariableSpeed())
        {
            FocusMotionSP.s = IPS_OK;
        }
        // If we are dealing with a simple dumb DC focuser, we move in a specific direction in an open-loop fashion until stopped.
        else
        {
            // If we are reversing direction let's issue abort first.
            if (prevDirection != targetDirection && prevState == IPS_BUSY)
                AbortFocuser();

            FocusMotionSP.s = MoveFocuser(targetDirection, 0, 0);
        }

        IDSetSwitch(&FocusMotionSP, nullptr);

        return true;
    }

    if (strcmp(name, "FOCUS_ABORT_MOTION") == 0)
    {
        IUResetSwitch(&AbortSP);

        if (AbortFocuser())
        {
            AbortSP.s = IPS_OK;
            if (CanAbsMove() && FocusAbsPosNP.s != IPS_IDLE)
            {
                FocusAbsPosNP.s = IPS_IDLE;
                IDSetNumber(&FocusAbsPosNP, nullptr);
            }
            if (CanRelMove() && FocusRelPosNP.s != IPS_IDLE)
            {
                FocusRelPosNP.s = IPS_IDLE;
                IDSetNumber(&FocusRelPosNP, nullptr);
            }
        }
        else
            AbortSP.s = IPS_ALERT;

        IDSetSwitch(&AbortSP, nullptr);
        return true;
    }

    return false;
}
开发者ID:djibb,项目名称:indi,代码行数:60,代码来源:indifocuserinterface.cpp


示例3: IDSetSwitch

void QHYCCD::setCooler(bool enable)
{
    if (enable && coolerEnabled == false)
    {
        CoolerS[0].s = ISS_ON;
        CoolerS[1].s = ISS_OFF;
        CoolerSP.s   = IPS_OK;
        IDSetSwitch(&CoolerSP, NULL);

        CoolerNP.s = IPS_BUSY;
        IDSetNumber(&CoolerNP, NULL);
        DEBUG(INDI::Logger::DBG_SESSION, "Cooler on.");

        coolerEnabled = true;
    }
    else if (!enable && coolerEnabled == true)
    {
        coolerEnabled = false;

        if (sim == false)
            SetQHYCCDParam(camhandle, CONTROL_MANULPWM, 0);

        CoolerSP.s   = IPS_IDLE;
        CoolerS[0].s = ISS_OFF;
        CoolerS[1].s = ISS_ON;
        IDSetSwitch(&CoolerSP, NULL);

        CoolerNP.s = IPS_IDLE;
        IDSetNumber(&CoolerNP, NULL);

        TemperatureNP.s = IPS_IDLE;
        IDSetNumber(&TemperatureNP, NULL);
        DEBUG(INDI::Logger::DBG_SESSION, "Cooler off.");
    }
}
开发者ID:rrogge,项目名称:indi,代码行数:35,代码来源:qhy_ccd.cpp


示例4: IDSetSwitch

bool LX200Autostar::ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
{
    int index = 0;

    if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
    {
        // Focus Motion
        if (!strcmp(name, FocusMotionSP.name))
        {
            // If speed is "halt"
            if (FocusSpeedN[0].value == 0)
            {
                FocusMotionSP.s = IPS_IDLE;
                IDSetSwitch(&FocusMotionSP, nullptr);
                return false;
            }

            int last_motion = IUFindOnSwitchIndex(&FocusMotionSP);

            if (IUUpdateSwitch(&FocusMotionSP, states, names, n) < 0)
                return false;

            index = IUFindOnSwitchIndex(&FocusMotionSP);

            // If same direction and we're busy, stop
            if (last_motion == index && FocusMotionSP.s == IPS_BUSY)
            {
                IUResetSwitch(&FocusMotionSP);
                FocusMotionSP.s = IPS_IDLE;
                setFocuserSpeedMode(PortFD, 0);
                IDSetSwitch(&FocusMotionSP, nullptr);
                return true;
            }

            if (!isSimulation() && setFocuserMotion(PortFD, index) < 0)
            {
                FocusMotionSP.s = IPS_ALERT;
                IDSetSwitch(&FocusMotionSP, "Error setting focuser speed.");
                return false;
            }

            FocusMotionSP.s = IPS_BUSY;

            // with a timer
            if (FocusTimerNP.np[0].value > 0)
            {
                FocusTimerNP.s = IPS_BUSY;
                if (isDebug())
                    IDLog("Starting Focus Timer BUSY\n");

                IEAddTimer(50, LX200Generic::updateFocusHelper, this);
            }

            IDSetSwitch(&FocusMotionSP, nullptr);
            return true;
        }
    }

    return LX200Generic::ISNewSwitch(dev, name, states, names, n);
}
开发者ID:rrogge,项目名称:indi,代码行数:60,代码来源:lx200autostar.cpp


示例5: LOG_DEBUG

bool FocusMaster::AbortFocuser()
{
    uint8_t command[MAX_FM_BUF] = {0};

    command[0] = 0x30;
    command[1] = 0x30;

    LOG_DEBUG("Aborting Focuser...");

    bool rc = sendCommand(command);

    if (rc)
    {
        if (FullMotionSP.s == IPS_BUSY)
        {
            IUResetSwitch(&FullMotionSP);
            FullMotionSP.s = IPS_IDLE;
            IDSetSwitch(&FullMotionSP, nullptr);
        }

        if (FocusMotionSP.s == IPS_BUSY)
        {
            IUResetSwitch(&FocusMotionSP);
            FocusMotionSP.s = IPS_IDLE;
            IDSetSwitch(&FocusMotionSP, nullptr);
        }
    }

    return rc;
}
开发者ID:azwing,项目名称:indi,代码行数:30,代码来源:focusmaster.cpp


示例6: IDSetNumber

void ASIEAF::GetFocusParams()
{
    if (readPosition())
        IDSetNumber(&FocusAbsPosNP, nullptr);

    if (readReverse())
        IDSetSwitch(&FocusReverseSP, nullptr);

    if (readBeep())
        IDSetSwitch(&BeepSP, nullptr);
}
开发者ID:azwing,项目名称:indi,代码行数:11,代码来源:asi_focuser.cpp


示例7: readU32

/************************************************************************************
 *
* ***********************************************************************************/
bool ScopeDome::SetupParms()
{
    targetAz = 0;

    readU32(GetImpPerTurn, stepsPerTurn);
    LOGF_INFO("Steps per turn read as %d", stepsPerTurn);
    StepsPerRevolutionN[0].value = stepsPerTurn;
    StepsPerRevolutionNP.s       = IPS_OK;
    IDSetNumber(&StepsPerRevolutionNP, nullptr);

    readS32(GetHomeSensorPosition, homePosition);
    LOGF_INFO("Home position read as %d", homePosition);

    if (UpdatePosition())
        IDSetNumber(&DomeAbsPosNP, nullptr);

    if (UpdateShutterStatus())
        IDSetSwitch(&DomeShutterSP, nullptr);

    UpdateSensorStatus();
    UpdateRelayStatus();

    if (InitPark())
    {
        // If loading parking data is successful, we just set the default parking
        // values.
        SetAxis1ParkDefault(0);
    }
    else
    {
        // Otherwise, we set all parking data to default in case no parking data is
        // found.
        SetAxis1Park(0);
        SetAxis1ParkDefault(0);
    }

    uint8_t calibrationNeeded = false;
    readU8(IsFullSystemCalReq, calibrationNeeded);
    CalibrationNeededS[0].s = calibrationNeeded ? ISS_ON : ISS_OFF;
    CalibrationNeededSP.s   = IPS_OK;
    IDSetSwitch(&CalibrationNeededSP, nullptr);

    uint16_t fwVersion;
    readU16(GetVersionFirmware, fwVersion);
    FirmwareVersionsN[0].value = fwVersion / 100.0;

    uint8_t fwVersionRotary;
    readU8(GetVersionFirmwareRotary, fwVersionRotary);
    FirmwareVersionsN[1].value = (fwVersionRotary + 9) / 10.0;
    FirmwareVersionsNP.s       = IPS_OK;
    IDSetNumber(&FirmwareVersionsNP, nullptr);
    return true;
}
开发者ID:sterne-jaeger,项目名称:indi,代码行数:56,代码来源:scopedome_dome.cpp


示例8: IUUpdateSwitch

bool INDI::Focuser::ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n)
{
    if(strcmp(dev,getDeviceName())==0)
    {
        if (!strcmp(PresetGotoSP.name, name))
        {
            IUUpdateSwitch(&PresetGotoSP, states, names, n);
            int index = IUFindOnSwitchIndex(&PresetGotoSP);

            if (PresetN[index].value < FocusAbsPosN[0].min)
            {
                PresetGotoSP.s = IPS_ALERT;
                IDSetSwitch(&PresetGotoSP, NULL);
                DEBUGFDEVICE(dev, INDI::Logger::DBG_ERROR, "Requested position out of bound. Focus minimum position is %g", FocusAbsPosN[0].min);
                return false;
            }
            else if (PresetN[index].value > FocusAbsPosN[0].max)
            {
                PresetGotoSP.s = IPS_ALERT;
                IDSetSwitch(&PresetGotoSP, NULL);
                DEBUGFDEVICE(dev, INDI::Logger::DBG_ERROR, "Requested position out of bound. Focus maximum position is %g", FocusAbsPosN[0].max);
                return false;
            }

            int rc = MoveAbsFocuser(PresetN[index].value);
            if (rc >= 0)
            {
                PresetGotoSP.s = IPS_OK;
                DEBUGF(INDI::Logger::DBG_SESSION, "Moving to Preset %d with position %g.", index+1, PresetN[index].value);
                IDSetSwitch(&PresetGotoSP, NULL);
                return true;
            }

            PresetGotoSP.s = IPS_ALERT;
            IDSetSwitch(&PresetGotoSP, NULL);
            return false;
        }

        if (strstr(name, "FOCUS_"))
            return processFocuserSwitch(dev, name, states, names, n);

    }

    controller->ISNewSwitch(dev, name, states, names, n);

    //  Nobody has claimed this, so, ignore it
    return DefaultDevice::ISNewSwitch(dev,name,states,names,n);
}
开发者ID:A-j-K,项目名称:indi,代码行数:48,代码来源:indifocuser.cpp


示例9: EAFSetBeep

bool ASIEAF::ISNewSwitch(const char * dev, const char * name, ISState * states, char * names[], int n)
{
    if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
    {
        // Turn on/off beep
        if (!strcmp(name, BeepSP.name))
        {
            EAF_ERROR_CODE rc = EAF_SUCCESS;
            if (!strcmp(BeepS[BEEP_ON].name, IUFindOnSwitchName(states, names, n)))
                rc = EAFSetBeep(m_ID, true);
            else
                rc = EAFSetBeep(m_ID, false);

            if (rc == EAF_SUCCESS)
            {
                IUUpdateSwitch(&BeepSP, states, names, n);
                BeepSP.s = IPS_OK;
            }
            else
            {
                BeepSP.s = IPS_ALERT;
                LOGF_ERROR("Failed to set beep state. Error: %d", rc);
            }

            IDSetSwitch(&BeepSP, nullptr);
            return true;
        }
    }

    return INDI::Focuser::ISNewSwitch(dev, name, states, names, n);
}
开发者ID:azwing,项目名称:indi,代码行数:31,代码来源:asi_focuser.cpp


示例10: IUFindOnSwitchIndex

bool DSICCD::ISNewSwitch (const char *dev, const char *name,
                          ISState *states, char *names[], int n)
{
    int index=0;

    if(strcmp(dev,getDeviceName())==0)
    {
        /* Vdd on/off switch for DSI III exposure control (gs) */
        if (!strcmp(name,VddExpSP.name))
        {

            if (IUUpdateSwitch(&VddExpSP, states, names, n) < 0)
                return false;

            index = IUFindOnSwitchIndex(&VddExpSP);

            if (index == 0)
                dsi->setVddOn(true);
            else
                dsi->setVddOn(false);

            VddExpSP.s = IPS_OK;
            IDSetSwitch (&VddExpSP,
                         index == 0 ? "Vdd mode is ON" : "Vdd mode is OFF" );

            return true;
        }
    }

    return INDI::CCD::ISNewSwitch (dev, name, states, names,  n);
}
开发者ID:jochym,项目名称:indilib,代码行数:31,代码来源:dsi_ccd.cpp


示例11: IUUpdateNumber

bool ASICCD::ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n)
{
    ASI_ERROR_CODE errCode = ASI_SUCCESS;

     if(!strcmp(dev,getDeviceName()))
     {
         if (!strcmp(name, ControlNP.name))
         {
            double oldValues[ControlNP.nnp];
            for (int i=0; i < ControlNP.nnp; i++)
                oldValues[i] = ControlN[i].value;

            IUUpdateNumber(&ControlNP, values, names, n);

            for (int i=0; i < ControlNP.nnp; i++)
            {
                ASI_BOOL nAuto = *((ASI_BOOL *) ControlN[i].aux1);
                ASI_CONTROL_TYPE nType = *((ASI_CONTROL_TYPE *) ControlN[i].aux0);

                // If value didn't change or if USB bandwidth control is to change, then only continue if ExposureRequest < 250 ms
                if (ControlN[i].value == oldValues[i] || (nType == ASI_BANDWIDTHOVERLOAD && ExposureRequest > 0.25))
                    continue;

                if ( (errCode = ASISetControlValue(m_camInfo->CameraID, nType, ControlN[i].value, ASI_FALSE)) != ASI_SUCCESS)
                {
                    DEBUGF(INDI::Logger::DBG_ERROR, "ASISetControlValue (%s=%g) error (%d)", ControlN[i].name, ControlN[i].value, errCode);
                    ControlNP.s = IPS_ALERT;
                    for (int i=0; i < ControlNP.nnp; i++)
                        ControlN[i].value = oldValues[i];
                    IDSetNumber(&ControlNP, NULL);
                    return false;
                }

                // If it was set to nAuto value to turn it off
                if (nAuto)
                {
                    for (int j=0; j < ControlSP.nsp; j++)
                    {
                        ASI_CONTROL_TYPE swType = *((ASI_CONTROL_TYPE *) ControlS[j].aux);

                        if (swType == nType)
                        {
                            ControlS[j].s = ISS_OFF;
                            break;
                        }
                    }

                    IDSetSwitch(&ControlSP, NULL);
                 }
            }

            ControlNP.s = IPS_OK;
            IDSetNumber(&ControlNP, NULL);
            return true;
         }

     }

    return INDI::CCD::ISNewNumber(dev,name,values,names,n);
}
开发者ID:jochym,项目名称:indilib,代码行数:60,代码来源:asi_ccd.cpp


示例12: IUFindOnSwitchIndex

bool INDI::LightBoxInterface::processLightBoxSwitch(const char *dev, const char *name, ISState *states, char *names[],
                                                    int n)
{
    if (strcmp(dev, device->getDeviceName()) == 0)
    {
        // Light
        if (!strcmp(LightSP.name, name))
        {
            int prevIndex = IUFindOnSwitchIndex(&LightSP);
            IUUpdateSwitch(&LightSP, states, names, n);
            bool rc = EnableLightBox(LightS[FLAT_LIGHT_ON].s == ISS_ON ? true : false);

            LightSP.s = rc ? IPS_OK : IPS_ALERT;

            if (!rc)
            {
                IUResetSwitch(&LightSP);
                LightS[prevIndex].s = ISS_ON;
            }

            IDSetSwitch(&LightSP, nullptr);

            return true;
        }
    }

    return false;
}
开发者ID:rumengb,项目名称:indi,代码行数:28,代码来源:indilightboxinterface.cpp


示例13: getImageType

bool ASICCD::StartStreaming()
{
    ASI_IMG_TYPE type = getImageType();

    if (type != ASI_IMG_Y8 && type != ASI_IMG_RGB24)
    {
        IUResetSwitch(&VideoFormatSP);
        ISwitch *vf = IUFindSwitch(&VideoFormatSP,"ASI_IMG_Y8");
        if (vf == NULL)
            vf = IUFindSwitch(&VideoFormatSP,"ASI_IMG_RAW8");

        if (vf)
        {
            vf->s = ISS_ON;
            DEBUGF(INDI::Logger::DBG_DEBUG, "Switching to %s video format.", vf->label);
            PrimaryCCD.setBPP(8);
            UpdateCCDFrame(PrimaryCCD.getSubX(), PrimaryCCD.getSubY(), PrimaryCCD.getSubW(), PrimaryCCD.getSubH());
            IDSetSwitch(&VideoFormatSP, NULL);
        }
        else
        {
            DEBUG(INDI::Logger::DBG_ERROR, "No 8 bit video format found, cannot start stream.");
            return false;
        }
    }

    ASIStartVideoCapture(m_camInfo->CameraID);
    pthread_mutex_lock(&condMutex);
    streamPredicate = 1;
    pthread_mutex_unlock(&condMutex);
    pthread_cond_signal(&cv);


    return true;
}
开发者ID:seanhoughton,项目名称:indi,代码行数:35,代码来源:asi_ccd.cpp


示例14: while

bool MaxDomeII::Abort()
{
    int error=0;
    int nRetry = 3;

    while (nRetry)
    {
            error = Abort_Azimuth_MaxDomeII(PortFD);
            handle_driver_error(&error, &nRetry);
    }

    while (nRetry)
    {
            error = Abort_Shutter_MaxDomeII(PortFD);
            handle_driver_error(&error, &nRetry);
    }

    DomeAbsPosNP.s = IPS_IDLE;
    IDSetNumber(&DomeAbsPosNP, NULL);

    // If we abort while in the middle of opening/closing shutter, alert.
    if (DomeShutterSP.s == IPS_BUSY)
    {
        DomeShutterSP.s = IPS_ALERT;
        IDSetSwitch(&DomeShutterSP, "Shutter operation aborted.");
        return false;
    }

    return true;
}
开发者ID:mp77,项目名称:indi,代码行数:30,代码来源:maxdomeii.cpp


示例15: IUUpdateSwitch

/********************************************************************************************
** Client is asking us to update a switch
*********************************************************************************************/
bool RainDetector::ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
{
    if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
    {
        if (strcmp(name, RainSP.name) == 0)
        {
            IUUpdateSwitch(&RainSP, states, names, n);

            if (RainS[0].s == ISS_ON)
            {
                RainL[0].s = IPS_ALERT;
                RainLP.s   = IPS_ALERT;
                IDSetLight(&RainLP, "Alert! Alert! Rain detected!");
            }
            else
            {
                RainL[0].s = IPS_IDLE;
                RainLP.s   = IPS_OK;
                IDSetLight(&RainLP, "Rain threat passed. The skies are clear.");
            }

            RainSP.s = IPS_OK;
            IDSetSwitch(&RainSP, nullptr);
            return true;
        }
    }

    return INDI::DefaultDevice::ISNewSwitch(dev, name, states, names, n);
}
开发者ID:azwing,项目名称:indi,代码行数:32,代码来源:raindetector.cpp


示例16: DEBUG

bool QikFlat::Disconnect()
{
    sf->closePort();
    delete sf;	
    DEBUG(INDI::Logger::DBG_SESSION, "ARDUINO BOARD DISCONNECTED.");
    IDSetSwitch (getSwitch("CONNECTION"),"DISCONNECTED\n");
    return true;
}
开发者ID:dokeeffe,项目名称:qik-flat,代码行数:8,代码来源:qik_flat.cpp


示例17: IUResetSwitch

bool ATIKCCD::activateCooler(bool enable)
{
    IUResetSwitch(&CoolerSP);
    if (enable)
    {
        if (TemperatureRequest < TemperatureN[0].value)
        {
            if (CoolerSP.s != IPS_BUSY)
                LOG_INFO("Camera cooler is on.");

            CoolerS[COOLER_ON].s = ISS_ON;
            CoolerS[COOLER_OFF].s = ISS_OFF;
            CoolerSP.s = IPS_BUSY;
        }
        else
        {
            CoolerS[COOLER_ON].s = ISS_OFF;
            CoolerS[COOLER_OFF].s = ISS_ON;
            CoolerSP.s = IPS_IDLE;
            LOG_WARN("Cooler cannot be activated manually. Set a lower temperature to activate it.");
            IDSetSwitch(&CoolerSP, nullptr);
            return false;
        }
    }
    else if (enable == false)
    {
        int rc = ArtemisCoolerWarmUp(hCam);
        if (rc != ARTEMIS_OK)
        {
            CoolerS[COOLER_ON].s = ISS_ON;
            CoolerS[COOLER_OFF].s = ISS_OFF;
            CoolerSP.s = IPS_ALERT;
            LOGF_ERROR("Failed to warm camera (%d).", rc);
            IDSetSwitch(&CoolerSP, nullptr);
            return false;
        }

        CoolerS[COOLER_ON].s = ISS_OFF;
        CoolerS[COOLER_OFF].s = ISS_ON;
        CoolerSP.s = IPS_IDLE;
        LOG_INFO("Camera is warming up...");
    }

    IDSetSwitch(&CoolerSP, nullptr);
    return true;
}
开发者ID:azwing,项目名称:indi,代码行数:46,代码来源:atik_ccd.cpp


示例18: getInputState

/************************************************************************************
 *
* ***********************************************************************************/
bool ScopeDome::UpdateRelayStatus()
{
    PowerRelaysS[0].s = getInputState(OUT_CCD);
    PowerRelaysS[1].s = getInputState(OUT_SCOPE);
    PowerRelaysS[2].s = getInputState(OUT_LIGHT);
    PowerRelaysS[3].s = getInputState(OUT_FAN);
    PowerRelaysSP.s   = IPS_OK;
    IDSetSwitch(&PowerRelaysSP, nullptr);

    RelaysS[0].s = getInputState(OUT_RELAY1);
    RelaysS[0].s = getInputState(OUT_RELAY1);
    RelaysS[0].s = getInputState(OUT_RELAY1);
    RelaysS[0].s = getInputState(OUT_RELAY1);
    RelaysSP.s   = IPS_OK;
    IDSetSwitch(&RelaysSP, nullptr);
    return true;
}
开发者ID:azwing,项目名称:indi,代码行数:20,代码来源:scopedome_dome.cpp


示例19: switch

void GPhotoCCD::UpdateWidget(cam_opt *opt)
{
	struct tm *tm;

    switch(opt->widget->type)
    {
	case GP_WIDGET_RADIO:
	case GP_WIDGET_MENU:
		for (int i = 0; i < opt->widget->choice_cnt; i++)
			opt->item.sw[i].s = opt->widget->value.index == i ? ISS_ON : ISS_OFF;
		IDSetSwitch(&opt->prop.sw, NULL);
		break;
	case GP_WIDGET_TEXT:
		free(opt->item.text.text);
		opt->item.text.text = strdup(opt->widget->value.text);
		IDSetText(&opt->prop.text, NULL);
		break;
	case GP_WIDGET_TOGGLE:
		if(opt->widget->value.toggle) {
			opt->item.sw[0].s = ISS_ON;
			opt->item.sw[0].s = ISS_OFF;
        } else
        {
			opt->item.sw[0].s = ISS_OFF;
			opt->item.sw[0].s = ISS_ON;
		}
		IDSetSwitch(&opt->prop.sw, NULL);
		break;
	case GP_WIDGET_RANGE:
		opt->item.num.value = opt->widget->value.num;
		IDSetNumber(&opt->prop.num, NULL);
		break;
	case GP_WIDGET_DATE:
		free(opt->item.text.text);
		tm = gmtime((time_t *)&opt->widget->value.date);
		opt->item.text.text = strdup(asctime(tm));
		IDSetText(&opt->prop.text, NULL);
		break;
	default:
		delete opt;
		return;
	}
}
开发者ID:A-j-K,项目名称:indi,代码行数:43,代码来源:gphoto_ccd.cpp


示例20: IDSetSwitch

bool Weather::ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
{
    if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
    {
        // Refresh
        if (!strcmp(name, RefreshSP.name))
        {
            RefreshS[0].s = ISS_OFF;
            RefreshSP.s   = IPS_OK;
            IDSetSwitch(&RefreshSP, nullptr);

            TimerHit();
        }

        // Override
        if (!strcmp(name, OverrideSP.name))
        {
            IUUpdateSwitch(&OverrideSP, states, names, n);
            if (OverrideS[0].s == ISS_ON)
            {
                LOG_WARN("Weather override is enabled. Observatory is not safe. Turn off override as soon as possible.");
                OverrideSP.s = IPS_BUSY;

                critialParametersLP.s = IPS_OK;
                IDSetLight(&critialParametersLP, nullptr);
            }
            else
            {
                LOG_INFO("Weather override is disabled");
                OverrideSP.s = IPS_IDLE;

                syncCriticalParameters();
            }

            IDSetSwitch(&OverrideSP, nullptr);
            return true;
        }
    }

    return DefaultDevice::ISNewSwitch(dev, name, states, names, n);
}
开发者ID:azwing,项目名称:indi,代码行数:41,代码来源:indiweather.cpp



注:本文中的IDSetSwitch函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ IDX函数代码示例发布时间:2022-05-30
下一篇:
C++ IDSetNumber函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap