本文整理汇总了C++中PublicDataRequest::starts_with方法的典型用法代码示例。如果您正苦于以下问题:C++ PublicDataRequest::starts_with方法的具体用法?C++ PublicDataRequest::starts_with怎么用?C++ PublicDataRequest::starts_with使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PublicDataRequest
的用法示例。
在下文中一共展示了PublicDataRequest::starts_with方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_set_public_data
void Extruder::on_set_public_data(void *argument)
{
PublicDataRequest *pdr = static_cast<PublicDataRequest *>(argument);
if(!pdr->starts_with(extruder_checksum)) return;
// handle extrude rates request from robot
if(pdr->second_element_is(target_checksum)) {
// disabled extruders do not reply NOTE only one enabled extruder supported
if(!this->enabled) return;
float *d = static_cast<float *>(pdr->get_data_ptr());
float target = d[0]; // the E passed in on Gcode is in mm³ (maybe absolute or relative)
float isecs = d[1]; // inverted secs
// check against maximum speeds and return rate modifier
d[1] = check_max_speeds(target, isecs);
pdr->set_taken();
return;
}
// save or restore state
if(pdr->second_element_is(save_state_checksum)) {
this->saved_current_position = this->current_position;
this->saved_absolute_mode = this->absolute_mode;
pdr->set_taken();
} else if(pdr->second_element_is(restore_state_checksum)) {
// NOTE this only gets called when the queue is empty so the milestones will be the same
this->milestone_last_position= this->current_position = this->saved_current_position;
this->milestone_absolute_mode= this->absolute_mode = this->saved_absolute_mode;
pdr->set_taken();
}
}
示例2: on_get_public_data
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();
}
}
示例3: on_get_public_data
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();
}
}
示例4: on_set_public_data
void Robot::on_set_public_data(void *argument)
{
PublicDataRequest *pdr = static_cast<PublicDataRequest *>(argument);
if(!pdr->starts_with(robot_checksum)) return;
if(pdr->second_element_is(speed_override_percent_checksum)) {
// NOTE do not use this while printing!
float t = *static_cast<float *>(pdr->get_data_ptr());
// enforce minimum 10% speed
if (t < 10.0F) t = 10.0F;
this->seconds_per_minute = t / 0.6F; // t * 60 / 100
pdr->set_taken();
} else if(pdr->second_element_is(current_position_checksum)) {
float *t = static_cast<float *>(pdr->get_data_ptr());
for (int i = 0; i < 3; i++) {
this->last_milestone[i] = this->to_millimeters(t[i]);
}
float actuator_pos[3];
arm_solution->cartesian_to_actuator(last_milestone, actuator_pos);
for (int i = 0; i < 3; i++)
actuators[i]->change_last_milestone(actuator_pos[i]);
pdr->set_taken();
}
}
示例5: on_set_public_data
void Player::on_set_public_data(void* argument) {
PublicDataRequest* pdr = static_cast<PublicDataRequest*>(argument);
if(!pdr->starts_with(player_checksum)) return;
if(pdr->second_element_is(abort_play_checksum)) {
abort_command("", &(StreamOutput::NullStream));
pdr->set_taken();
}
}
示例6: on_get_public_data
void Extruder::on_get_public_data(void* argument) {
PublicDataRequest* pdr = static_cast<PublicDataRequest*>(argument);
if(!pdr->starts_with(extruder_checksum)) return;
if(this->enabled) {
// Note this is allowing both step/mm and filament diameter to be exposed via public data
pdr->set_data_ptr(&this->steps_per_millimeter);
pdr->set_taken();
}
}
示例7: on_set_public_data
void ToolManager::on_set_public_data(void* argument)
{
PublicDataRequest* pdr = static_cast<PublicDataRequest*>(argument);
if(!pdr->starts_with(tool_manager_checksum)) return;
// ok this is targeted at us, so change tools
//uint16_t tool_name= *static_cast<float*>(pdr->get_data_ptr());
// TODO: fire a tool change gcode
//pdr->set_taken();
}
示例8: on_set_public_data
void TemperatureControl::on_set_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 set the temp
float t= *static_cast<float*>(pdr->get_data_ptr());
this->set_desired_temperature(t);
pdr->set_taken();
}
示例9: on_set_public_data
void TemperatureControl::on_set_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;
// ok this is targeted at us, so set the temp
// NOTE unlike the M code this will set the temp now not when the queue is empty
float t = *static_cast<float *>(pdr->get_data_ptr());
this->set_desired_temperature(t);
pdr->set_taken();
}
示例10: on_set_public_data
void Panel::on_set_public_data(void *argument)
{
PublicDataRequest *pdr = static_cast<PublicDataRequest *>(argument);
if(!pdr->starts_with(panel_checksum)) return;
if(!pdr->second_element_is(panel_display_message_checksum)) return;
string *s = static_cast<string *>(pdr->get_data_ptr());
if (s->size() > 20) {
this->message = s->substr(0, 20);
} else {
this->message= *s;
}
}
示例11: on_set_public_data
void Robot::on_set_public_data(void* argument){
PublicDataRequest* pdr = static_cast<PublicDataRequest*>(argument);
if(!pdr->starts_with(robot_checksum)) return;
if(pdr->second_element_is(speed_override_percent_checksum)) {
// NOTE do not use this while printing!
double t= *static_cast<double*>(pdr->get_data_ptr());
// enforce minimum 10% speed
if (t < 10.0) t= 10.0;
this->seconds_per_minute= t * 0.6;
pdr->set_taken();
}
}
示例12: on_get_public_data
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();
}
}
}
示例13: on_get_public_data
void Switch::on_get_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 send back the requested data
// this must be static as it will be accessed long after we have returned
static struct pad_switch pad;
pad.name = this->name_checksum;
pad.state = this->switch_state;
pad.value = this->switch_value;
pdr->set_data_ptr(&pad);
pdr->set_taken();
}
示例14: on_get_public_data
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();
}
}
示例15: on_get_public_data
void Robot::on_get_public_data(void* argument){
PublicDataRequest* pdr = static_cast<PublicDataRequest*>(argument);
if(!pdr->starts_with(robot_checksum)) return;
if(pdr->second_element_is(speed_override_percent_checksum)) {
static double return_data;
return_data= 100*this->seconds_per_minute/60;
pdr->set_data_ptr(&return_data);
pdr->set_taken();
}else if(pdr->second_element_is(current_position_checksum)) {
static double return_data[3];
return_data[0]= from_millimeters(this->current_position[0]);
return_data[1]= from_millimeters(this->current_position[1]);
return_data[2]= from_millimeters(this->current_position[2]);
pdr->set_data_ptr(&return_data);
pdr->set_taken();
}
}