sync-at-time

command module
v0.0.0-...-6dbae82 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 16, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

README

sync-at-time modular resource

This module allows you to configure Cloud Sync to occur only at a specific time frame by implementing a sensor, naomi:sync-at-time:timesyncsensor, that enables sync when within a specified timeframe and disables sync when outside that timeframe.

Requirements

Before configuring your sensor, you must create a machine.

To use the sync-at-time module you also need to:

  1. Enable data capture.
  2. Enable cloud sync.

Build and run

To use this module, follow these instructions to add a module from the Viam Registry and select the naomi:sync-at-time:timesyncsensor model from the sync-at-time module.

Configure your sync-at-time sensor

Navigate to the Config tab of your machine's page in the Viam app. Click on the Components subtab and click Create component. Select the sensor type, then select the sync-at-time:timesyncsensor model. Click Add module, then enter a name for your sensor and click Create.

On the new component panel, copy and paste the following attribute template into your sensor’s Attributes box:

{
  "start": "HH:MM:SS",
  "end": "HH:MM:SS",
  "zone": "<TIMEZONE>"
}

[!NOTE] For more information, see Configure a Machine.

Attributes

The following attributes are available for the naomi:sync-at-time:timesyncsensor sensor:

Name Type Inclusion Description
start string Required The start time for the time frame during which you want to sync, example: "14:10:00".
end string Required The start time for the time frame during which you want to sync, example: "15:35:00".
zone string Required The time zone for the start and end time, for example: "CET".
Example configuration
{
  "start": "14:10:00",
  "end": "15:35:00",
  "zone": "CET"
}

To ensure the data manager starts up before the sensor, add this service_config to the component configuration on the JSON tab.

"service_configs": [
    {
        "attributes": {
        "capture_methods": []
        },
        "type": "data_manager"
    }
]

The entire component configuration should resemble this:

{
    "attributes": {
    "start": "14:10:00",
    "end": "15:35:00",
    "zone": "CET"
    },
    "depends_on": [],
    "name": "timesensor",
    "model": "naomi:sync-at-time:timesyncsensor",
    "type": "sensor",
    "namespace": "rdk",
    "service_configs": [
    {
        "attributes": {
        "capture_methods": []
        },
        "type": "data_manager"
    }
    ]
}
Configure data manager

On your machine's Config tab, switch to JSON mode and add a selective_syncer_name with the name for the sensor you configured:

{
  "attributes": {
    "additional_sync_paths": [],
    "capture_dir": "",
    "capture_disabled": false,
    "selective_syncer_name": "<SENSOR-NAME>",
    "sync_disabled": false,
    "sync_interval_mins": 0.1,
    "tags": []
  },
  "name": "Data-Management-Service",
  "type": "data_manager"
}

For an example configuration see example.json.

Next steps

You have now configured sync to happen during a specific time slot. To test your setup, configure a webcam or another component and enable data capture on one of the component methods, for example ReadImage. The data manager will now capture data. Go to the Control tab. You should see the sensor. Click on GetReadings. If you are in the time frame for sync, the sensor will return true. You can confirm that no data is currently syncing by going to the Data tab. If you are not in the time frame for sync, adjust the configuration of your sensor. Then check again on the Control and Data tab to confirm data is syncing.

Local Development

This module is written in Go.

go mod tidy
go build

License

Copyright 2021-2023 Viam Inc.
Apache 2.0

Documentation

Overview

Package main is a module which serves the timesync sensor model.

Directories

Path Synopsis
Package timesyncsensor implements a datasync manager.
Package timesyncsensor implements a datasync manager.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL