您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ IDSetSwitch函数代码示例

51自学网 2021-06-01 21:28:01
  C++
这篇教程C++ IDSetSwitch函数代码示例写得很实用,希望能帮到您。

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

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


示例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,


示例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,


示例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,


示例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,


示例6: IDSetNumber

void ASIEAF::GetFocusParams(){    if (readPosition())        IDSetNumber(&FocusAbsPosNP, nullptr);    if (readReverse())        IDSetSwitch(&FocusReverseSP, nullptr);    if (readBeep())        IDSetSwitch(&BeepSP, nullptr);}
开发者ID:azwing,项目名称:indi,代码行数:11,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例21: ok

/* Handle a request to change a switch. */bool ShelyakEshel::ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n){    if (!strcmp(dev, getDeviceName())) // check if the message is for our device    {        if (!strcmp(LampSP.name, name)) // check if its lamp request        {            LampSP.s = IPS_OK; // set state to ok (change later if something goes wrong)            for (int i = 0; i < n; i++)            {                ISwitch *s = IUFindSwitch(&LampSP, names[i]);                if (states[i] != s->s)                { // check if state has changed                    bool rc = calibrationUnitCommand(COMMANDS[states[i]], PARAMETERS[names[i]]);                    if (!rc)                        LampSP.s = IPS_ALERT;                }            }            IUUpdateSwitch(&LampSP, states, names, n); // update lamps            IDSetSwitch(&LampSP, nullptr);                // tell clients to update            return true;        }        else            if (!strcmp(MirrorSP.name, name)) // check if its a mirror request        {            ISState s = MirrorS[0].s;                    // save current mirror state            IUUpdateSwitch(&MirrorSP, states, names, n); // update mirror            MirrorSP.s = IPS_OK;                         // set state to ok (change later if something goes wrong)            if (s != MirrorS[0].s)            { // if mirror state has changed send command                bool rc = calibrationUnitCommand(COMMANDS[MirrorS[0].s], PARAMETERS["MIRROR"]);                if (!rc)                    MirrorSP.s = IPS_ALERT;            }            IDSetSwitch(&MirrorSP, nullptr); // tell clients to update            return true;        }    }    return INDI::DefaultDevice::ISNewSwitch(dev, name, states, names, n); // send it to the parent classes}
开发者ID:azwing,项目名称:indi,代码行数:42,


示例22: IDSetSwitch

bool DomeSim::Abort(){        // 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. Status: unknown.");        return false;    }    return true;}
开发者ID:mp77,项目名称:indi,代码行数:12,


示例23: DEBUGF

void JoyStick::buttonEvent(int button_n, int value){    if (!isConnected())        return;    DEBUGF(INDI::Logger::DBG_DEBUG, "buttonEvent[%d]: %s", button_n, value > 0 ? "On" : "Off");    ButtonSP.s          = IPS_OK;    ButtonS[button_n].s = (value == 0) ? ISS_OFF : ISS_ON;    IDSetSwitch(&ButtonSP, nullptr);}
开发者ID:rrogge,项目名称:indi,代码行数:12,


示例24: IDLog

void JoyStick::buttonEvent(int button_n, int value){    if (isConnected() == false)        return;    if (isDebug())        IDLog("buttonEvent[%d]: %s/n", button_n, value > 0 ? "On" : "Off");    ButtonSP.s = IPS_OK;    ButtonS[button_n].s = (value == 0 )? ISS_OFF : ISS_ON;    IDSetSwitch(&ButtonSP, NULL);}
开发者ID:LabAixBidouille,项目名称:Indi,代码行数:13,


示例25: IUResetSwitch

bool StarbookDriver::performStart() {    IUResetSwitch(&StartSP);    if (last_known_state == starbook::INIT) {        if (cmd_interface->Start()) {            StartSP.s = IPS_OK;        }    } else {        LOGF_WARN("Can't initialize in %s state, must be INIT", starbook::STATE_TO_STR.at(last_known_state).c_str());        StartSP.s = IPS_ALERT;    }    IDSetSwitch(&StartSP, nullptr);    return true;}
开发者ID:azwing,项目名称:indi,代码行数:13,


示例26: IUResetSwitch

bool RollOff::Abort(){    MotionRequest=-1;    // If both limit switches are off, then we're neither parked nor unparked.    if (fullOpenLimitSwitch == false && fullClosedLimitSwitch == false)    {        IUResetSwitch(&ParkSP);        ParkSP.s = IPS_IDLE;        IDSetSwitch(&ParkSP, NULL);    }    return true;}
开发者ID:jochym,项目名称:indilib,代码行数:14,


示例27: IUUpdateSwitch

bool Vantage::ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n){    if(strcmp(dev,getDeviceName())==0)    {        if (!strcmp(BaudRateSP.name, name))        {            IUUpdateSwitch(&BaudRateSP, states, names, n);            BaudRateSP.s = IPS_OK;            IDSetSwitch(&BaudRateSP, NULL);            return true;        }    }    return INDI::Weather::ISNewSwitch(dev, name, states, names, n);}
开发者ID:A-j-K,项目名称:indi,代码行数:15,


示例28: IUUpdateSwitch

bool MICCD::ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n){    if (strcmp(dev, getDeviceName()) == 0)    {        if (!strcmp(name, ReadModeSP.name))        {            IUUpdateSwitch(&ReadModeSP, states, names, n);            ReadModeSP.s = IPS_OK;            IDSetSwitch(&ReadModeSP, nullptr);            return true;        }    }    return INDI::CCD::ISNewSwitch(dev, name, states, names, n);}
开发者ID:azwing,项目名称:indi,代码行数:15,


示例29: IDSetSwitch

bool ASICCD::activateCooler(bool enable){    bool rc = (ASISetControlValue(m_camInfo->CameraID, ASI_COOLER_ON, enable ? ASI_TRUE : ASI_FALSE, ASI_FALSE) == ASI_SUCCESS);    if (rc == false)        CoolerSP.s = IPS_ALERT;    else    {        CoolerS[0].s = enable ? ISS_ON : ISS_OFF;        CoolerS[1].s = enable ? ISS_OFF: ISS_ON;        CoolerSP.s = IPS_BUSY;    }    IDSetSwitch(&CoolerSP, NULL);    return rc;}
开发者ID:seanhoughton,项目名称:indi,代码行数:15,


示例30: IUUpdateSwitch

bool XAGYLWheel::ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n){    if(strcmp(dev,getDeviceName())==0)    {        if (!strcmp(ResetSP.name, name))        {            IUUpdateSwitch(&ResetSP, states, names, n);            int value = IUFindOnSwitchIndex(&ResetSP);            IUResetSwitch(&ResetSP);            if (value == 3)                value = 6;            bool rc = reset(value);            if (rc)            {                switch (value)                {                case 0:                    DEBUG(INDI::Logger::DBG_SESSION, "Executing hard reboot...");                    break;                case 1:                    DEBUG(INDI::Logger::DBG_SESSION, "Restarting and moving to filter position #1...");                    break;                case 2:                    DEBUG(INDI::Logger::DBG_SESSION, "Calibration removed.");                    break;                case 6:                    DEBUG(INDI::Logger::DBG_SESSION, "Calibrating...");                    break;                }            }            ResetSP.s = rc ? IPS_OK : IPS_ALERT;            IDSetSwitch(&ResetSP, NULL);            return true;        }    }    return INDI::FilterWheel::ISNewSwitch(dev, name, states, names, n);}
开发者ID:phomer60,项目名称:indi,代码行数:48,



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


C++ IDX函数代码示例
C++ IDSetNumber函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。