コード例 #1
0
ファイル: cgi_hvac.c プロジェクト: dheerajkvs/MQX_3.8.1
_mqx_int cgi_hvac_data(HTTPD_SESSION_STRUCT *session) {
	uint_32 Td = HVAC_GetDesiredTemperature();
    uint_32 Ta = HVAC_GetActualTemperature();
    char str[50];

    session->response.contenttype = CONTENT_TYPE_PLAIN;
    httpd_sendhdr(session, 0, 0);

    CGI_SEND_STR(HVAC_HVACModeName(HVAC_GetHVACMode()));

    sprintf(str, "%d.%d °%c\n%d.%d °%c\n", Td/10, Td%10, HVAC_GetTemperatureSymbol(), Ta/10, Ta%10, HVAC_GetTemperatureSymbol());
    httpd_sendstr(session->sock, str);
    
    CGI_SEND_STR(HVAC_GetFanMode() == Fan_Automatic ? "auto" : "on");

//  CGI_SEND_STR(HVAC_GetOutputName(0));
//  CGI_SEND_STR(HVAC_GetOutputName(1));
//  CGI_SEND_STR(HVAC_GetOutputName(2));
            
    CGI_SEND_STR(HVAC_GetOutput(HVAC_FAN_OUTPUT) ? "on" : "off");
    CGI_SEND_STR(HVAC_GetOutput(HVAC_HEAT_OUTPUT) ? "on" : "off");
    CGI_SEND_STR(HVAC_GetOutput(HVAC_COOL_OUTPUT) ? "on" : "off");      

    return session->request.content_len;
}
コード例 #2
0
int_32  Shell_hvac(int_32 argc, char_ptr argv[] )
{
   boolean           print_usage, shorthelp = FALSE;
   int_32            return_code = SHELL_EXIT_SUCCESS;

   print_usage = Shell_check_help_request(argc, argv, &shorthelp );

   if (!print_usage)  {
      if (argc > 2) {
         printf("Error, invalid number of parameters\n");
         return_code = SHELL_EXIT_ERROR;
         print_usage=TRUE;
      } else {
         if (argc == 2) {
            if (strcmp(argv[1],"off")==0) {
               HVAC_SetHVACMode(HVAC_Off);
            } else if (strcmp(argv[1],"cool")==0) {
               HVAC_SetHVACMode(HVAC_Cool);
            } else if (strcmp(argv[1],"heat")==0) {
               HVAC_SetHVACMode(HVAC_Heat);
            } else if (strcmp(argv[1],"auto")==0) {
               HVAC_SetHVACMode(HVAC_Auto);
            } else {
               printf("Invalid hvac mode specified\n");
            } 
         }

         printf("HVAC mode is %s\n", HVAC_HVACModeName(HVAC_GetHVACMode()));
      }
   }
   
   if (print_usage)  {
      if (shorthelp)  {
         printf("%s [<mode>]\n", argv[0]);
      } else  {
         printf("Usage: %s [<mode>]\n", argv[0]);
         printf("   <mode> = off, cool, heat or auto\n");
      }
   }
   return return_code;
} 
コード例 #3
0
int_32  Shell_info(int_32 argc, char_ptr argv[] )
{
   boolean           print_usage, shorthelp = FALSE;
   int_32            return_code = SHELL_EXIT_SUCCESS;
   uint_32           temp;
   FAN_Mode_t        fan;
   HVAC_Output_t     output;

   print_usage = Shell_check_help_request(argc, argv, &shorthelp );

   if (!print_usage)  {
      if (argc > 1) {
         printf("Error, invalid number of parameters\n");
         return_code = SHELL_EXIT_ERROR;
         print_usage=TRUE;
      } else {
         printf("HVAC mode:    %s\n",  HVAC_HVACModeName(HVAC_GetHVACMode()));
         temp  = HVAC_GetDesiredTemperature();
         printf("Desired Temp: %d.%1d %c\n", temp/10, temp%10, HVAC_GetTemperatureSymbol());
         temp  = HVAC_GetActualTemperature();
         printf("Actual Temp:  %d.%1d %c\n", temp/10, temp%10, HVAC_GetTemperatureSymbol());
         fan  = HVAC_GetFanMode();
         printf("Fan mode:     %s\n", fan == Fan_Automatic ? "Automatic" : "On");

         for(output=(HVAC_Output_t)0;output<HVAC_MAX_OUTPUTS;output++) {
            printf("%12s: %s\n", HVAC_GetOutputName(output), HVAC_GetOutput(output) ? "On" : "Off");
         }
       }
   }
   
   if (print_usage)  {
      if (shorthelp)  {
         printf("%s \n", argv[0]);
      } else  {
         printf("Usage: %s \n", argv[0]);
      }
   }
   return return_code;
} 
コード例 #4
0
ファイル: HVAC_Util.c プロジェクト: dheerajkvs/MQX_3.8.1
void HVAC_LogCurrentState(void) 
{
   char     Message[LOG_MESSAGE_SIZE];
   uint_32  temp_d,temp_a,output,i;

   temp_d = HVAC_GetDesiredTemperature();
   temp_a = HVAC_GetActualTemperature();
   
   i=sprintf(Message,"mode: %s, set:%2d.%1d %c temp:%2d.%1d %c Fan: %s ",
      HVAC_HVACModeName(HVAC_GetHVACMode()), 
      temp_d/10, temp_d%10, HVAC_GetTemperatureSymbol(), 
      temp_a/10, temp_a%10, HVAC_GetTemperatureSymbol(),
      HVAC_GetFanMode()==Fan_Automatic?"Auto":"On  ");

   for(output=0;output<HVAC_MAX_OUTPUTS;output++) {
      i+=sprintf(&Message[i],"%s %s, ", HVAC_GetOutputName((HVAC_Output_t)output), HVAC_GetOutput((HVAC_Output_t)output)?"On":"Off");
   }
   sprintf(&Message[i],"\n");

   Log(Message);

}
コード例 #5
0
ファイル: cgi_hvac.c プロジェクト: zhouglu/K60F120M
_mqx_int cgi_hvac_data(HTTPSRV_CGI_REQ_STRUCT* param)
{
    HTTPSRV_CGI_RES_STRUCT response;
    uint_32 Td = HVAC_GetDesiredTemperature();
    uint_32 Ta = HVAC_GetActualTemperature();
    uint_32 length = 0;
    uint_32 size = 0;
    char* str = NULL;
    
    if (param->request_method != HTTPSRV_REQ_GET)
    {
        return(0);
    }
    
    response.ses_handle = param->ses_handle;
    response.content_type = HTTPSRV_CONTENT_TYPE_PLAIN;
    response.status_code = 200;
    
    size = snprintf(NULL, 0, "%d.%d &deg;%c\n%d.%d &deg;%c\n%s\n%s\n%s\n%s\n%s\n",
                     Ta/10,
                     Ta%10,
                     HVAC_GetTemperatureSymbol(),
                     Td/10,
                     Td%10,
                     HVAC_GetTemperatureSymbol(), 
                     HVAC_GetFanMode() == Fan_Automatic ? "auto" : "on", 
                     HVAC_GetOutput(HVAC_FAN_OUTPUT) ? "on" : "off",
                     HVAC_GetOutput(HVAC_COOL_OUTPUT) ? "on" : "off",
                     HVAC_GetOutput(HVAC_HEAT_OUTPUT) ? "on" : "off",
                     HVAC_HVACModeName(HVAC_GetHVACMode()));
    size += 1;

    str = _mem_alloc(sizeof(char)*size);
    if (str != NULL)
    {
        length = snprintf(str, size, "%d.%d &deg;%c\n%d.%d &deg;%c\n%s\n%s\n%s\n%s\n%s\n",
                     Ta/10,
                     Ta%10,
                     HVAC_GetTemperatureSymbol(),
                     Td/10,
                     Td%10,
                     HVAC_GetTemperatureSymbol(), 
                     HVAC_GetFanMode() == Fan_Automatic ? "auto" : "on", 
                     HVAC_GetOutput(HVAC_FAN_OUTPUT) ? "on" : "off",
                     HVAC_GetOutput(HVAC_COOL_OUTPUT) ? "on" : "off",
                     HVAC_GetOutput(HVAC_HEAT_OUTPUT) ? "on" : "off",
                     HVAC_HVACModeName(HVAC_GetHVACMode()));

        response.data = str;
        response.data_length = length;
        response.content_length = response.data_length;
        
    }
    else
    {
        response.data_length = strlen("n/a\n")*11;
        response.data = "n/a\nn/a\nn/a\nn/a\nn/a\nn/a\nn/a\nn/a\nn/a\nn/a\nn/a\n";
        response.content_length = response.data_length;
    }
    HTTPSRV_cgi_write(&response);
    if (str)
    {
        _mem_free(str);
    }
    return (response.content_length);
}