Exemple #1
0
int is_ver_sensor_katcp(struct katcp_dispatch *d, struct katcp_vrbl *vx)
{
  struct katcp_vrbl_payload *py;

  if(vx == NULL){
    return -1;
  }

  if((vx->v_flags & KATCP_VRF_VER) == 0){
    return 0;
  }

  py = find_payload_katcp(d, vx, KATCP_VRC_VERSION_VERSION);
  if(py == NULL){
    return 0;
  }

  return 1;
}
Exemple #2
0
int is_vrbl_sensor_katcp(struct katcp_dispatch *d, struct katcp_vrbl *vx)
{
  struct katcp_vrbl_payload *py;

  if(vx == NULL){
    return -1;
  }

  if((vx->v_flags & KATCP_VRF_SEN) == 0){
    return 0;
  }

  py = find_payload_katcp(d, vx, KATCP_VRC_SENSOR_VALUE);
  if(py == NULL){
    return 0;
  }

  if(py->p_type >= KATCP_MAX_VRT){
    return -1;
  }

  return 1;
}
Exemple #3
0
int add_partial_sensor_katcp(struct katcp_dispatch *d, struct katcl_parse *px, char *name, int flags, struct katcp_vrbl *vx)
{
  int results[5];
  struct katcp_vrbl_payload *py;
  unsigned int r;
  int i, sum;
  char *ptr;

  if((px == NULL) || (vx == NULL)){
    return -1;
  }

  if(name){
    ptr = name;
  } else if(vx->v_name){
    ptr = vx->v_name;
  } else {
    ptr = "unnamed";
  }

  r = 0;

  py = find_payload_katcp(d, vx, KATCP_VRC_SENSOR_TIME);
  if(py){
    results[r++] = add_payload_vrbl_katcp(d, px, 0, vx, py);
  } else {
    results[r++] = add_timestamp_parse_katcl(px, flags & KATCP_FLAG_FIRST, NULL);
  }

  results[r++] = add_string_parse_katcl(px, KATCP_FLAG_STRING, "1");

  results[r++] = add_string_parse_katcl(px, KATCP_FLAG_STRING, ptr);

  py = find_payload_katcp(d, vx, KATCP_VRC_SENSOR_STATUS);
  if(py){
    results[r++] = add_payload_vrbl_katcp(d, px, 0, vx, py);
  } else {
    results[r++] = add_string_parse_katcl(px, KATCP_FLAG_STRING, "unknown");
  }

  py = find_payload_katcp(d, vx, KATCP_VRC_SENSOR_VALUE);
  if(py){
    results[r++] = add_payload_vrbl_katcp(d, px, flags & KATCP_FLAG_LAST, vx, py);
  } else {
    results[r++] = add_string_parse_katcl(px, KATCP_FLAG_STRING | (flags & KATCP_FLAG_LAST), "unset");
  }

  sum = 0;
  for(i = 0; i < r; i++){
    if(results[i] < 0){
      sum = (-1);
      i = r;
    } else {
      sum += results[i];
    }
  }

  if(sum <= 0){
    return (-1);
  }

  return sum;
}