Browse Source

Merge pull request #59 from perryh/add_api_khs

Add API_KHS endpoint.
nfactor-troky
Noel Maersk 11 years ago
parent
commit
37f60c3d2a
  1. 21
      api.c
  2. 1
      miner.h

21
api.c

@ -756,6 +756,7 @@ static struct api_data *api_add_data_full(struct api_data *root, char *name, enu @@ -756,6 +756,7 @@ static struct api_data *api_add_data_full(struct api_data *root, char *name, enu
case API_DOUBLE:
case API_ELAPSED:
case API_MHS:
case API_KHS:
case API_MHTOTAL:
case API_UTILITY:
case API_FREQ:
@ -868,6 +869,11 @@ struct api_data *api_add_mhs(struct api_data *root, char *name, double *data, bo @@ -868,6 +869,11 @@ struct api_data *api_add_mhs(struct api_data *root, char *name, double *data, bo
return api_add_data_full(root, name, API_MHS, (void *)data, copy_data);
}
struct api_data *api_add_khs(struct api_data *root, char *name, double *data, bool copy_data)
{
return api_add_data_full(root, name, API_KHS, (void *)data, copy_data);
}
struct api_data *api_add_mhtotal(struct api_data *root, char *name, double *data, bool copy_data)
{
return api_add_data_full(root, name, API_MHTOTAL, (void *)data, copy_data);
@ -983,6 +989,9 @@ static struct api_data *print_data(struct api_data *root, char *buf, bool isjson @@ -983,6 +989,9 @@ static struct api_data *print_data(struct api_data *root, char *buf, bool isjson
case API_MHS:
sprintf(buf, "%.4f", *((double *)(root->data)));
break;
case API_KHS:
sprintf(buf, "%.0f", *((double *)(root->data)));
break;
case API_VOLTS:
sprintf(buf, "%.3f", *((float *)(root->data)));
break;
@ -1672,6 +1681,12 @@ static void gpustatus(struct io_data *io_data, int gpu, bool isjson, bool precom @@ -1672,6 +1681,12 @@ static void gpustatus(struct io_data *io_data, int gpu, bool isjson, bool precom
char mhsname[27];
sprintf(mhsname, "MHS %ds", opt_log_interval);
root = api_add_mhs(root, mhsname, &(cgpu->rolling), false);
double khs_avg = mhs * 1000.0;
double khs_rolling = cgpu->rolling * 1000.0;
root = api_add_khs(root, "KHS av", &khs_avg, false);
char khsname[27];
sprintf(khsname, "KHS %ds", opt_log_interval);
root = api_add_khs(root, khsname, &khs_rolling, false);
root = api_add_int(root, "Accepted", &(cgpu->accepted), false);
root = api_add_int(root, "Rejected", &(cgpu->rejected), false);
root = api_add_int(root, "Hardware Errors", &(cgpu->hw_errors), false);
@ -1879,6 +1894,12 @@ static void summary(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __mayb @@ -1879,6 +1894,12 @@ static void summary(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __mayb
char mhsname[27];
sprintf(mhsname, "MHS %ds", opt_log_interval);
root = api_add_mhs(root, mhsname, &(total_rolling), false);
double khs_avg = mhs * 1000.0;
double khs_rolling = total_rolling * 1000.0;
root = api_add_khs(root, "KHS av", &khs_avg, false);
char khsname[27];
sprintf(khsname, "KHS %ds", opt_log_interval);
root = api_add_khs(root, khsname, &khs_rolling, false);
root = api_add_uint(root, "Found Blocks", &(found_blocks), true);
root = api_add_int(root, "Getworks", &(total_getworks), true);
root = api_add_int(root, "Accepted", &(total_accepted), true);

1
miner.h

@ -1437,6 +1437,7 @@ enum api_data_type { @@ -1437,6 +1437,7 @@ enum api_data_type {
API_TIMEVAL,
API_TIME,
API_MHS,
API_KHS,
API_MHTOTAL,
API_TEMP,
API_UTILITY,

Loading…
Cancel
Save