mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-09 14:28:12 +00:00
api add data type AVG float 3 decimal
This commit is contained in:
parent
83ea44af5d
commit
b6c6ec5c83
7
api.c
7
api.c
@ -760,6 +760,7 @@ static struct api_data *api_add_data_full(struct api_data *root, char *name, enu
|
|||||||
break;
|
break;
|
||||||
case API_VOLTS:
|
case API_VOLTS:
|
||||||
case API_TEMP:
|
case API_TEMP:
|
||||||
|
case API_AVG:
|
||||||
api_data->data = (void *)malloc(sizeof(float));
|
api_data->data = (void *)malloc(sizeof(float));
|
||||||
*((float *)(api_data->data)) = *((float *)data);
|
*((float *)(api_data->data)) = *((float *)data);
|
||||||
break;
|
break;
|
||||||
@ -894,6 +895,11 @@ struct api_data *api_add_percent(struct api_data *root, char *name, double *data
|
|||||||
return api_add_data_full(root, name, API_PERCENT, (void *)data, copy_data);
|
return api_add_data_full(root, name, API_PERCENT, (void *)data, copy_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct api_data *api_add_avg(struct api_data *root, char *name, float *data, bool copy_data)
|
||||||
|
{
|
||||||
|
return api_add_data_full(root, name, API_AVG, (void *)data, copy_data);
|
||||||
|
}
|
||||||
|
|
||||||
static struct api_data *print_data(struct api_data *root, char *buf, bool isjson, bool precom)
|
static struct api_data *print_data(struct api_data *root, char *buf, bool isjson, bool precom)
|
||||||
{
|
{
|
||||||
struct api_data *tmp;
|
struct api_data *tmp;
|
||||||
@ -973,6 +979,7 @@ static struct api_data *print_data(struct api_data *root, char *buf, bool isjson
|
|||||||
sprintf(buf, "%.0f", *((double *)(root->data)));
|
sprintf(buf, "%.0f", *((double *)(root->data)));
|
||||||
break;
|
break;
|
||||||
case API_VOLTS:
|
case API_VOLTS:
|
||||||
|
case API_AVG:
|
||||||
sprintf(buf, "%.3f", *((float *)(root->data)));
|
sprintf(buf, "%.3f", *((float *)(root->data)));
|
||||||
break;
|
break;
|
||||||
case API_MHTOTAL:
|
case API_MHTOTAL:
|
||||||
|
4
miner.h
4
miner.h
@ -1446,7 +1446,8 @@ enum api_data_type {
|
|||||||
API_VOLTS,
|
API_VOLTS,
|
||||||
API_HS,
|
API_HS,
|
||||||
API_DIFF,
|
API_DIFF,
|
||||||
API_PERCENT
|
API_PERCENT,
|
||||||
|
API_AVG
|
||||||
};
|
};
|
||||||
|
|
||||||
struct api_data {
|
struct api_data {
|
||||||
@ -1482,5 +1483,6 @@ extern struct api_data *api_add_volts(struct api_data *root, char *name, float *
|
|||||||
extern struct api_data *api_add_hs(struct api_data *root, char *name, double *data, bool copy_data);
|
extern struct api_data *api_add_hs(struct api_data *root, char *name, double *data, bool copy_data);
|
||||||
extern struct api_data *api_add_diff(struct api_data *root, char *name, double *data, bool copy_data);
|
extern struct api_data *api_add_diff(struct api_data *root, char *name, double *data, bool copy_data);
|
||||||
extern struct api_data *api_add_percent(struct api_data *root, char *name, double *data, bool copy_data);
|
extern struct api_data *api_add_percent(struct api_data *root, char *name, double *data, bool copy_data);
|
||||||
|
extern struct api_data *api_add_avg(struct api_data *root, char *name, float *data, bool copy_data);
|
||||||
|
|
||||||
#endif /* __MINER_H__ */
|
#endif /* __MINER_H__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user