private void sendHearbeat() {
   List<Node> nodes = DaoUtils.getNodeDao().getAll();
   for (Node node : nodes) {
     switch (node.getGateway().getNetworkType()) {
       case MY_SENSORS:
         ObjectFactory.getIActionEngine(NETWORK_TYPE.MY_SENSORS).sendAliveStatusRequest(node);
         break;
       default:
         // TODO: not supported
         return;
     }
   }
 }
 private void checkHearbeat() {
   List<Node> nodes = DaoUtils.getNodeDao().getAll();
   long aliveCheckInterval =
       ObjectFactory.getAppProperties().getControllerSettings().getAliveCheckInterval();
   if (aliveCheckInterval < MycUtils.MINUTE) {
     aliveCheckInterval = MycUtils.MINUTE;
   }
   for (Node node : nodes) {
     if (node.getLastSeen() == null
         || node.getLastSeen() <= (System.currentTimeMillis() - aliveCheckInterval)) {
       node.setState(STATE.DOWN);
       DaoUtils.getNodeDao().update(node);
       _logger.debug("Node is in not reachable state, Node:[{}]", node);
     }
   }
 }
  private MetricsChartDataGroupNVD3 getMetricsBatteryJsonNVD3(
      Integer nodeId, Long timestampFrom, Long timestampTo, Boolean withMinMax) {
    ArrayList<MetricsChartDataNVD3> preDoubleData = new ArrayList<MetricsChartDataNVD3>();

    MetricsBatteryUsage metricQueryBattery =
        MetricsBatteryUsage.builder()
            .timestampFrom(timestampFrom)
            .timestampTo(timestampTo)
            .node(Node.builder().id(nodeId).build())
            .build();
    List<MetricsBatteryUsage> batteryMetrics =
        DaoUtils.getMetricsBatteryUsageDao().getAll(metricQueryBattery);
    ArrayList<Object> avgMetricValues = new ArrayList<Object>();
    ArrayList<Object> minMetricValues = new ArrayList<Object>();
    ArrayList<Object> maxMetricValues = new ArrayList<Object>();
    for (MetricsBatteryUsage metric : batteryMetrics) {
      avgMetricValues.add(new Object[] {metric.getTimestamp(), metric.getAvg()});
      if (withMinMax) {
        minMetricValues.add(new Object[] {metric.getTimestamp(), metric.getMin()});
        maxMetricValues.add(new Object[] {metric.getTimestamp(), metric.getMax()});
      }
    }
    MetricsGraph metricBattery =
        ObjectFactory.getAppProperties().getMetricsGraphSettings().getBattery();
    preDoubleData.add(
        MetricsChartDataNVD3.builder()
            .key(ObjectFactory.getMcLocale().getString(MC_LOCALE.AVERAGE))
            .values(avgMetricValues)
            .color(metricBattery.getColor())
            .type(metricBattery.getSubType())
            .build()
            .updateSubType(metricBattery.getType()));
    if (withMinMax) {
      preDoubleData.add(
          MetricsChartDataNVD3.builder()
              .key(ObjectFactory.getMcLocale().getString(MC_LOCALE.MINUMUM))
              .values(minMetricValues)
              .color(COLOR_MINIMUM)
              .type(metricBattery.getSubType())
              .build()
              .updateSubType(metricBattery.getType()));
      preDoubleData.add(
          MetricsChartDataNVD3.builder()
              .key(ObjectFactory.getMcLocale().getString(MC_LOCALE.MAXIMUM))
              .values(maxMetricValues)
              .color(COLOR_MAXIMUM)
              .type(metricBattery.getSubType())
              .build()
              .updateSubType(metricBattery.getType()));
    }

    return MetricsChartDataGroupNVD3.builder()
        .metricsChartDataNVD3(preDoubleData)
        .unit("%")
        .timeFormat(getTimeFormat(timestampFrom))
        .id(nodeId)
        .resourceName(new ResourceModel(RESOURCE_TYPE.NODE, nodeId).getResourceLessDetails())
        .chartType(metricBattery.getType())
        .chartInterpolate(metricBattery.getInterpolate())
        .build();
  }