void TemperatureControl::on_get_public_data(void *argument)
{
    PublicDataRequest *pdr = static_cast<PublicDataRequest *>(argument);

    if(!pdr->starts_with(temperature_control_checksum)) return;

    if(pdr->second_element_is(pool_index_checksum)) {
        // asking for our instance pointer if we have this pool_index
        if(pdr->third_element_is(this->pool_index)) {
            static void *return_data;
            return_data = this;
            pdr->set_data_ptr(&return_data);
            pdr->set_taken();
        }
        return;

    } else if(!pdr->second_element_is(this->name_checksum)) return;

    // ok this is targeted at us, so send back the requested data
    if(pdr->third_element_is(current_temperature_checksum)) {
        this->public_data_return.current_temperature = this->get_temperature();
        this->public_data_return.target_temperature = (target_temperature == UNDEFINED) ? 0 : this->target_temperature;
        this->public_data_return.pwm = this->o;
        this->public_data_return.designator= this->designator;
        pdr->set_data_ptr(&this->public_data_return);
        pdr->set_taken();
    }

}
void ToolManager::on_get_public_data(void* argument)
{
    PublicDataRequest* pdr = static_cast<PublicDataRequest*>(argument);

    if(!pdr->starts_with(tool_manager_checksum)) return;

    if(pdr->second_element_is(is_active_tool_checksum)) {

        // check that we control the given tool
        bool managed = false;
        for(auto t : tools) {
            uint16_t n = t->get_name();
            if(pdr->third_element_is(n)) {
                managed = true;
                break;
            }
        }

        // we are not managing this tool so do not answer
        if(!managed) return;

        pdr->set_data_ptr(&this->current_tool_name);
        pdr->set_taken();

    }else if(pdr->second_element_is(get_active_tool_checksum)) {
        pdr->set_data_ptr(&this->active_tool);
        pdr->set_taken();
    }
}
void TemperatureControl::on_get_public_data(void *argument)
{
    PublicDataRequest *pdr = static_cast<PublicDataRequest *>(argument);

    if(!pdr->starts_with(temperature_control_checksum)) return;

    if(pdr->second_element_is(pool_index_checksum)) {
        // asking for our instance pointer if we have this pool_index
        if(pdr->third_element_is(this->pool_index)) {
            static void *return_data;
            return_data = this;
            pdr->set_data_ptr(&return_data);
            pdr->set_taken();
        }

    }else if(pdr->second_element_is(poll_controls_checksum)) {
        // polling for all temperature controls
        // add our data to the list which is passed in via the data_ptr

        std::vector<struct pad_temperature> *v= static_cast<std::vector<pad_temperature>*>(pdr->get_data_ptr());

        struct pad_temperature t;
        // setup data
        t.current_temperature = this->get_temperature();
        t.target_temperature = (target_temperature <= 0) ? 0 : this->target_temperature;
        t.pwm = this->o;
        t.designator= this->designator;
        t.id= this->name_checksum;
        v->push_back(t);
        pdr->set_taken();

    }else if(pdr->second_element_is(current_temperature_checksum)) {
        // if targeted at us
        if(pdr->third_element_is(this->name_checksum)) {
            // ok this is targeted at us, so set the requ3sted data in the pointer passed into us
            struct pad_temperature *t= static_cast<pad_temperature*>(pdr->get_data_ptr());
            t->current_temperature = this->get_temperature();
            t->target_temperature = (target_temperature <= 0) ? 0 : this->target_temperature;
            t->pwm = this->o;
            t->designator= this->designator;
            t->id= this->name_checksum;
            pdr->set_taken();
        }
    }

}
Exemple #4
0
void Switch::on_set_public_data(void *argument)
{
    PublicDataRequest *pdr = static_cast<PublicDataRequest *>(argument);

    if(!pdr->starts_with(switch_checksum)) return;

    if(!pdr->second_element_is(this->name_checksum)) return; // likely fan, but could be anything

    // ok this is targeted at us, so set the value
    if(pdr->third_element_is(state_checksum)) {
        bool t = *static_cast<bool *>(pdr->get_data_ptr());
        this->switch_state = t;
        pdr->set_taken();
        this->switch_changed= true;

    } else if(pdr->third_element_is(value_checksum)) {
        float t = *static_cast<float *>(pdr->get_data_ptr());
        this->switch_value = t;
        pdr->set_taken();
    }
}
void TemperatureControl::on_get_public_data(void* argument){
    PublicDataRequest* pdr = static_cast<PublicDataRequest*>(argument);

    if(!pdr->starts_with(temperature_control_checksum)) return;

    if(!pdr->second_element_is(this->name_checksum)) return; // will be bed or hotend

    // ok this is targeted at us, so send back the requested data
    if(pdr->third_element_is(current_temperature_checksum)) {
        // this must be static as it will be accessed long after we have returned
        static struct pad_temperature temp_return;
        temp_return.current_temperature= this->get_temperature();
        temp_return.target_temperature= (target_temperature == UNDEFINED) ? 0 : this->target_temperature;
        temp_return.pwm= this->o;

        pdr->set_data_ptr(&temp_return);
        pdr->set_taken();
    }
}