コード例 #1
0
double tempcont::wait_setpoint_reached(double delta, size_t timeout) const {
  // poll temperature every second
  time_t end_polling=time(NULL)+timeout;
  double setpoint=get_setpoint();
  double temperature=get_temperature();
  while (fabs(temperature-setpoint)>delta && (timeout==0 || end_polling>=time(NULL))) {
    sleep(1);
    temperature=get_temperature();
  }
  return temperature;
}
コード例 #2
0
double Eurotherm2000Series::set_setpoint(double ct) {
  char buffer[8];
  snprintf(buffer,8,fp_format.c_str(),ct);
  set_value("SL",buffer);
  // extra wait, until the get_setpoint function returns the same value
  timespec write_latency;
  write_latency.tv_sec=0; write_latency.tv_nsec=50000000;
  nanosleep(&write_latency,NULL);  
  write_latency.tv_nsec=100000000;
  int i=100;
  while(fabs(get_setpoint()-ct)>1e-4) {
    if (i<0) throw Eurotherm2000Series_error("could not confirm setpoint value settings, timeout");
    nanosleep(&write_latency,NULL);
    --i;
  }
  return ct;
}
コード例 #3
0
ファイル: main.c プロジェクト: kgutwin/MavBBQ
static void select_long_handler(ClickRecognizerRef recognizer, void *context) {
	get_setpoint(get_current_setpoint(2, true), get_current_setpoint(2, false), master_temp2, "Temp 2", (SetpointCallback) alarm_2_update);
}
コード例 #4
0
ファイル: main.c プロジェクト: kgutwin/MavBBQ
static void up_long_handler(ClickRecognizerRef recognizer, void *context) {
	//APP_LOG(APP_LOG_LEVEL_DEBUG, "get setpoint %d %d", alarm_1_upper_setpoint, alarm_1_lower_setpoint);
	get_setpoint(get_current_setpoint(1, true), get_current_setpoint(1, false), master_temp1, "Temp 1", (SetpointCallback) alarm_1_update);
}
コード例 #5
0
ファイル: temp_control.c プロジェクト: fishbaoz/wiced-emw3165
/*
 * Updates temperature information in the web page
 */
static int32_t process_temperature_update( const char* url_parameters, wiced_http_response_stream_t* stream, void* arg, wiced_http_message_body_t* http_data )
{
    wiced_iso8601_time_t* curr_time;
    float temp_celcius;
    float temp_fahrenheit;
    float setpoint_celcius = get_setpoint();
    float setpoint_fahrenheit;
    char  temp_char_buffer[6];
    int   temp_char_buffer_length;

    UNUSED_PARAMETER(http_data);

    wiced_rtos_lock_mutex( &xively_data.mutex );

    if ( xively_data.temperature_reading_index == 0 )
    {
        curr_time = &xively_data.temperature_readings[MAX_TEMPERATURE_READINGS - 1].timestamp;
    }
    else
    {
        curr_time = &xively_data.temperature_readings[xively_data.temperature_reading_index - 1].timestamp;
    }

    /* Update temperature report with the most recent temperature reading */
    temp_celcius        = (float) xively_data.last_sample / 10.0f;
    temp_fahrenheit     = temp_celcius / 5.0f * 9.0f + 32.0f;
    setpoint_fahrenheit = setpoint_celcius / 5.0f * 9.0f + 32.0f;

    wiced_rtos_unlock_mutex( &xively_data.mutex );

    /* Write the time */
    wiced_http_response_stream_write_resource( stream, &resources_apps_DIR_temp_control_DIR_data_html_time_start );
    wiced_http_response_stream_write( stream, curr_time->hour, sizeof(curr_time->hour)   +
                                                     sizeof(curr_time->colon1) +
                                                     sizeof(curr_time->minute) +
                                                     sizeof(curr_time->colon2) +
                                                     sizeof(curr_time->second) );
    wiced_http_response_stream_write_resource( stream, &resources_apps_DIR_temp_control_DIR_data_html_time_end );

    /* Write the date */
    wiced_http_response_stream_write_resource( stream, &resources_apps_DIR_temp_control_DIR_data_html_date_start );
    wiced_http_response_stream_write(stream, curr_time->year, sizeof(curr_time->year)  +
                                                    sizeof(curr_time->dash1) +
                                                    sizeof(curr_time->month) +
                                                    sizeof(curr_time->dash2) +
                                                    sizeof(curr_time->day) );

    wiced_http_response_stream_write_resource( stream, &resources_apps_DIR_temp_control_DIR_data_html_date_end );

    wiced_http_response_stream_write_resource( stream, &resources_apps_DIR_temp_control_DIR_data_html_temp_start );
    temp_char_buffer_length = sprintf(temp_char_buffer, "%.1f", temp_celcius);
    wiced_http_response_stream_write(stream, temp_char_buffer, temp_char_buffer_length );
    wiced_http_response_stream_write_resource( stream, &resources_apps_DIR_temp_control_DIR_data_html_temp_mid );
    temp_char_buffer_length = sprintf(temp_char_buffer, "%.1f", temp_fahrenheit);
    wiced_http_response_stream_write(stream, temp_char_buffer, temp_char_buffer_length );
    wiced_http_response_stream_write_resource( stream, &resources_apps_DIR_temp_control_DIR_data_html_temp_end );

    wiced_http_response_stream_write_resource( stream, &resources_apps_DIR_temp_control_DIR_data_html_set_start );
    temp_char_buffer_length = sprintf(temp_char_buffer, "%.1f", setpoint_celcius);
    wiced_http_response_stream_write(stream, temp_char_buffer, temp_char_buffer_length );
    wiced_http_response_stream_write_resource( stream, &resources_apps_DIR_temp_control_DIR_data_html_set_mid );
    temp_char_buffer_length = sprintf(temp_char_buffer, "%.1f", setpoint_fahrenheit);
    wiced_http_response_stream_write(stream, temp_char_buffer, temp_char_buffer_length );
    wiced_http_response_stream_write_resource( stream, &resources_apps_DIR_temp_control_DIR_data_html_set_end );

    wiced_http_response_stream_write_resource( stream, &resources_apps_DIR_temp_control_DIR_data_html_page_end );

    return 0;
}