> For the complete documentation index, see [llms.txt](https://help.qtech.co.nz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.qtech.co.nz/qtech/datscan-and-data-loggers/datahost/reference.md).

# Sites, nodes and the DatScan database

The site nodes in the DATAHost TBD, and how each logger input becomes a site in the DatScan database.

This page lists the nodes on each logger site in the DATAHost TBD, and shows how each logger input becomes its own site in the DATScan database.

## How inputs become sites

Each Q48 logger is one site in DATAHost, with an address (its device number) and a short name. The Comms Object Site Short Name is used for creating new sites in the database, and the I/O point number gets appended before the data is logged, so each of the logger's 8 inputs becomes a separate site in the database. For example, a logger with the short name QT1RTU gives sites QT1RTU1 to QT1RTU8.

![Two loggers, device IDs 1 and 2, each with 8 inputs. In DATAHost, logger 1 (short name QT1RTU) maps its inputs to sites QT1RTU1 to QT1RTU8, and logger 2 to QT2RTU1 to QT2RTU8. All 16 sites are listed in the tblSiteInfo table of the DatScan database in SQL Server.](https://3621580088-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5hMAUl7E1cWeN5Rghg0%2Fuploads%2FhIhGqbT9uVICEQyWoJIg%2Fdatahost-logger-inputs-to-sites.png?alt=media)

The Site Code is a unique identifier for the site. This field is automatically created by the DATAHost base station when data is retrieved by the Cellular Data Logger. If multiple sensors are connected to a single Cellular Data Logger then they will be numbered alongside the site name. E.g. QD01, QD02 etc. See [Set up your sites](https://help.qtech.co.nz/qtech/datscan-and-data-loggers/datscan-analyser/set-up.md).

## Site nodes

Under each site's comms object:

| Node                      | Meaning                                                                                                                                                                                                                                                                                                      |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Address**               | The RTU address                                                                                                                                                                                                                                                                                              |
| **Channel**               | The name of the channel used for communications                                                                                                                                                                                                                                                              |
| **Log Record Count**      | The number of records on the RTU to be downloaded as returned by the initialisation command                                                                                                                                                                                                                  |
| **Log Records Remaining** | The number of records that are yet to be retrieved; this value is decremented by the amount of returned records every time Datran receives a reply to a "Get Records" command. Note that this could potentially go negative if more records were received due to logging since the call to get record count. |
| **RTU Clock**             | The RTU Clock value, set upon status reply reception                                                                                                                                                                                                                                                         |
| **RTU Connection**        | The connection status, either "Connected" or "Disconnected"                                                                                                                                                                                                                                                  |
| **RTU Firmware Ver**      | The RTU firmware version, set upon status reply reception                                                                                                                                                                                                                                                    |
| **RxTime**                | This node is updated using the server time every time a complete packet is received, before the checksum is calculated or the payload is processed.                                                                                                                                                          |
| **Site Short Name**       | The name used to identify the site when records are written into the database                                                                                                                                                                                                                                |
| **Type**                  | The used channel type                                                                                                                                                                                                                                                                                        |

**RX Time**: There are no occurrences of this parameter in the source code; this means it is a stray parameter that was probably hand written in the TBD. Irrelevant parameters are not automatically removed.

## What happens in a connection

When a logger connects, DATAHost:

1. asks for its status
2. asks how many records it has
3. collects the records, a batch at a time, until none are left
4. tells the logger to clear its log
5. sets the logger's clock
6. ends the connection.

If the logger has no records, DATAHost goes straight to setting its clock.

## The DATScan database

| Table              | Contents                                                                  |
| ------------------ | ------------------------------------------------------------------------- |
| **tblTransaction** | The records: opening is 0 (switch open) and closing is 1 (switch closed). |
| **tblSiteInfo**    | One row for each site: each logger input                                  |
| **tblEventIds**    | The eventIds table contents, created by `DATScanDB.sql`                   |

`DATScanDB.sql` creates the appropriate tables, the eventIds table contents and logging stored procedure.
