88 lines
2.2 KiB
C++
88 lines
2.2 KiB
C++
#pragma once
|
|
#ifndef OLIVIA_NSENS
|
|
#endif
|
|
#ifdef OLIVIA_COMPILA
|
|
#include "olv.h"
|
|
#include <string>
|
|
/**
|
|
* @file olv_sens_ws.h
|
|
* Archivo de definiciones y variables de la utilidad para conexión al Web Service para lectura de los sensores de la herramienta Olivia.
|
|
*/
|
|
|
|
#define OLV_MAX_CAMP_HTTP 16
|
|
#define OLV_MAX_CAMP_HTTP_LONG 32
|
|
#define OLV_MAX_URL 256
|
|
#define OLV_MAX_CUERPO 1024
|
|
|
|
enum ModosPet
|
|
{
|
|
OLV_SENS_PET_UNICO,
|
|
OLV_SENS_PET_MEDIA,
|
|
};
|
|
/**
|
|
* Estructura para campos de los parámetros del método HTTP POST
|
|
*/
|
|
typedef struct Camps_post
|
|
{
|
|
char fn[OLV_MAX_CAMP_HTTP];
|
|
char id[OLV_MAX_CAMP_HTTP];
|
|
char usr[OLV_MAX_CAMP_HTTP];
|
|
char pwd[OLV_MAX_CAMP_HTTP];
|
|
char startdate[OLV_MAX_CAMP_HTTP];
|
|
char enddate[OLV_MAX_CAMP_HTTP];
|
|
}Camps_post;
|
|
|
|
/**
|
|
* Estructura para campos de los parámetros de la respuesta del servicio en formato JSON
|
|
*/
|
|
typedef struct Camps_json
|
|
{
|
|
char id[OLV_MAX_CAMP_HTTP_LONG];
|
|
char histo[OLV_MAX_CAMP_HTTP_LONG];
|
|
char porc[OLV_MAX_CAMP_HTTP_LONG];
|
|
char resp_code[OLV_MAX_CAMP_HTTP_LONG];
|
|
char resp_code_err[OLV_MAX_CAMP_HTTP_LONG];
|
|
char resp_data[OLV_MAX_CAMP_HTTP_LONG];
|
|
}Camps_json;
|
|
|
|
/**
|
|
* Estructura para conexión al web service de los sensores
|
|
*/
|
|
typedef struct Info_sens
|
|
{
|
|
char url[OLV_MAX_URL];
|
|
char fn_cont_status[OLV_MAX_URL];
|
|
char usr[OLV_MAX_CAMP_HTTP];
|
|
char pwd[OLV_MAX_CAMP_HTTP];
|
|
char fecha_ini[OLV_MAX_CAMP_HTTP_LONG];
|
|
char fecha_fin[OLV_MAX_CAMP_HTTP_LONG];
|
|
int modo_pet;
|
|
double porc_lim;//en %
|
|
Camps_post camps;
|
|
Camps_json camps_json;
|
|
}Info_sens;
|
|
|
|
class Colv_sens_ws
|
|
{
|
|
public:
|
|
//*************************************************************************************
|
|
//Variables
|
|
Info_sens *info;
|
|
char cuerpo[OLV_MAX_CUERPO];
|
|
char err_str[OLV_MAX_ERR];
|
|
char url[OLV_MAX_URL];
|
|
std::string cURL_JSON_data;
|
|
//*************************************************************************************
|
|
//Funciones
|
|
Colv_sens_ws(void);
|
|
~Colv_sens_ws(void);
|
|
void inicia(Info_sens *info_);
|
|
double dame_porc_cont_i(char *id);
|
|
BOOL get_status_cont_i(char *id);
|
|
BOOL post_curl(char *body);
|
|
static size_t writeJSONURLCallback(char* buf, size_t size, size_t nmemb, void* up);
|
|
BOOL answer_json(char *id_, int *ndata_, int **data_vol_);
|
|
|
|
};
|
|
#endif
|