using DbAPI.Connections;
using DTS.Common.Interface.Database;
using DTS.Common.Interface.Sensors;
using DTS.Common.Interface.Sensors.AnalogDiagnostics;
using System;
namespace DbAPI.Sensors
{
///
/// Sensor related functions (GetAnalogSensors, InsertUpdateSensor, DeleteSensor)
///
public interface ISensors
{
///
/// returns all matching analog diagnostic records
///
/// user making query
/// connection being queried over
/// id of record, or null for all records
/// id of diagnostic run, or null for all records
/// sensor id to query for, or null for all
/// serial number to query for, or null for all
///
ulong SensorsAnalogDiagnosticsGet(IUserDbRecord user, IConnectionDetails connection,
long? Id, long? diagnosticRunId, int? sensorId, string sensorSerialNumber, out IDiagnosticEntry [] records);
///
/// retrieves any matching
///
/// user making query
/// diagnostic run id to query for or null for any id
/// test setup id to query for or null for any id
/// test setup name to query for or null for any name
/// connection to query on
/// out records
/// 0 (ERROR_SUCCESS) on success, all other values are error codes
ulong SensorsAnalogDiagnosticRunGet(IUserDbRecord user, IConnectionDetails connection,
long? Id, int? testId, string testName, out IDiagnosticRun [] records);
///
/// update or inserts all entries passed in
///
/// user committing entries
/// connection to commit over
/// entries to insert or update
/// 0 (ERROR_SUCCESS) on success, all other values are error codes
ulong SensorsAnalogDiagnosticUpdateInsert(IUserDbRecord user,
IConnectionDetails connection,
ref IDiagnosticEntry entry);
///
/// updates or inserts a Diagnostic run into the database
///
/// user committing record
/// connection diagnostic run is being committed over
/// the record to insert or update
/// 0 (ERROR_SUCCESS) on success, all other values are error codes
ulong SensorsAnalogDiagnosticRunUpdateInsert(IUserDbRecord user,
IConnectionDetails connection,
ref IDiagnosticRun run);
///
/// updates or inserts an input stream record into the database
/// Database id is modified on record on an insert operation
///
/// user committing record
/// connection record is being committed over
/// record to be inserted or updated
/// 0 (ERROR_SUCCESS) on success, all other values are error codes
ulong SensorsInputStreamUpdateInsert(IUserDbRecord user,
IConnectionDetails connection,
ref IStreamInputRecord record);
///
/// retrieves matching input streams from database
///
/// user making request
/// connection over which to look for records
/// database id of record (use null for all)
/// serial number of record (use null for all)
/// all matching records
/// 0 (ERROR_SUCCESS) on success, all other values are error codes
ulong SensorsInputStreamGet(IUserDbRecord user,
IConnectionDetails connection,
int? Id,
string SerialNumber,
out IStreamInputRecord[] records);
///
/// retrieves matching thermocouplers from database
///
/// user making request
/// connection over which to look for records
/// database id of record (use null for all)
/// serial number of record (use null for all)
/// all matching records
/// 0 (ERROR_SUCCESS) on success, all other values are error codes
ulong SensorsThermocouplerGet(IUserDbRecord user,
IConnectionDetails connection,
int clientDbVersion,
int? Id,
string SerialNumber,
out IThermocouplerRecord[] records);
///
/// updates or inserts an output stream record into the database
/// Database id is modified on record on an insert operation
///
/// user committing record
/// connection record is being committed over
/// record to be inserted or updated
/// 0 (ERROR_SUCCESS) on success, all other values are error codes
ulong SensorsOutputStreamUpdateInsert(IUserDbRecord user,
IConnectionDetails connection,
ref IStreamOutputRecord record);
///
/// retrieves matching output streams from database
///
/// user making request
/// connection over which to look for records
/// database id of record (use null for all)
/// serial number of record (use null for all)
/// all matching records
/// 0 (ERROR_SUCCESS) on success, all other values are error codes
ulong SensorsOutputStreamGet(IUserDbRecord user,
IConnectionDetails connection,
int? Id,
string SerialNumber,
out IStreamOutputRecord[] records);
///
/// updates or inserts a new UART record into the database
/// Id is updated if a new record is inserted
///
/// user committing UART
/// connection UART should be committed on
/// record being inserted or updated
/// 0 (ERROR_SUCCESS) on success, all other values are error codes
ulong SensorsUARTUpdateInsert(IUserDbRecord user,
IConnectionDetails connection,
ref IUARTRecord record);
///
/// retrieves UART settings
///
/// user making requests
/// connection request sh
/// Id to search for (use null for all)
/// serial number to search for (use null or empty for all)
/// matching records found
/// 0 (ERROR_SUCCESS) on success, all other values are error codes
ulong SensorsUARTGet(IUserDbRecord user,
IConnectionDetails connection,
int? Id,
string SerialNumber,
out IUARTRecord[] records);
ulong SensorsCanGet(IUserDbRecord user,
IConnectionDetails connection,
int? Id,
string SerialNumber,
out ICANRecord[] records);
ulong SensorsCanUpdateInsert(IUserDbRecord user,
IConnectionDetails connection,
ref ICANRecord record);
///
/// commits a digital output setting to the db
/// The record will be modified with a new database id if
/// a new record is inserted
///
/// user making commit
/// connection over which to commit
/// the record to commit
/// 0 (ERROR_SUCCESS) on success, all other values are error codes
ulong SensorsDigitalOutUpdateInsert(IUserDbRecord user,
IConnectionDetails connection,
IDigitalOutDbRecord record);
///
/// retrieves all matching digital output settings in the db
///
/// user requesting records
/// connection to query records on
/// Database id of records (can be null)
/// serial number/name of setting (can be null)
/// all matching records
/// 0 (ERROR_SUCCESS) on success, all other values are error codes
ulong SensorsDigitalOutGet(
IUserDbRecord user,
IConnectionDetails connection,
int? Id,
string serialNumber,
out IDigitalOutDbRecord[] records);
///
/// inserts or updates a digital input record into the db. If a record is inserted
/// then the original record is updated with the database id of the entry
///
/// user committing record
///
///
///
ulong SensorsDigitalInUpdateInsert(IUserDbRecord user,
IConnectionDetails connection,
IDigitalInDbRecord record);
///
/// retrieves any digital input settings matching input criteria
/// in the database
///
/// user making request
/// connection to query over
/// Database Id of digital input setting (can be null)
/// serial number of setting (can be null)
/// Electronic id of setting (can be null)
/// all matching records
/// 0 (ERROR_SUCCESS) on success, all other values are errors
ulong SensorsDigitalInGet(IUserDbRecord user,
IConnectionDetails connection,
int? id,
string serialNumber,
string eId,
out IDigitalInDbRecord[] records);
///
/// Inserts or updates a squib setting in the db
/// setting is modified with new db id after execution
///
/// user inserting setting
/// connection for inserting
/// record to be inserted
/// 0 (ERROR_SUCCESS) on success, all other values are error codes
ulong SensorsSquibUpdateInsert(IUserDbRecord user,
IConnectionDetails connection,
ISquibDbRecord record);
///
/// retrieves all squib settings matching input criteria
///
/// user requesting squib settings
/// connection for retrieving squib settings
/// Electronic Id
/// Database Id for squib setting
/// serial number/name of squib setting
/// output records discovered
/// 0 (ERROR_SUCCESS) on success, all other values are errors
ulong SensorsSquibGet(IUserDbRecord user,
IConnectionDetails connection,
int? Id,
string serialNumber,
string eId,
out ISquibDbRecord[] records);
///
/// Deletes ALL sensors in the db
///
/// user deleting sensors
/// connection sensors to be deleted on
/// 0 (ERROR_SUCCESS) on success, all other values are errors
ulong SensorsDeleteAll(IUserDbRecord user,
IConnectionDetails connection);
///
/// retrieves the bridge resistance for a sensor
///
/// user making query
/// connection query is being made on
/// serial number of sensor
/// output bridge resistance of sensor
/// 0 (ERROR_SUCCESS) on success, all other values are error codes
ulong SensorsAnalogBridgeResistanceGet(IUserDbRecord user,
IConnectionDetails connection,
string serialNumber,
out double bridgeResistance);
///
/// deletes all sensor calibrations matching criteria
/// nulls are wild cards, so passing in all nulls will
/// delete all calibrations
///
/// user deleting calibrations
/// connection to use for deletes
/// allows null
/// allows null
/// allows null
/// 0 (ERROR_SUCCESS) on success, all other values are errors
ulong SensorCalibrationsDelete(IUserDbRecord user,
IConnectionDetails connection,
string sensorSerialNumber,
DateTime? calibrationDate,
DateTime? modifyDate
);
///
/// inserts a new calibration record
///
/// user submitting record
/// connection record is being submitted on
/// calibration record
/// type of sensor
///
/// 0 (ERROR_SUCCESS) on success, all other values are error codes
ulong SensorCalibrationsInsert(IUserDbRecord user,
IConnectionDetails connection,
ISensorCalDbRecord cal,
int sensorType,
bool setCalibrationId);
///
/// deletes all sensors matching criteria
/// sensor types are defined in table SensorsType
/// 0 - analog
/// 1 - digital in
/// 2 - digital out
/// 3 - squib
/// 4 - UART
///
/// user deleting sensors
/// connection sensors are being deleted on
/// id in database
/// type of sensor
/// 0 (ERROR_SUCCESS) on success, all other values are errors
ulong SensorsDelete(IUserDbRecord user,
IConnectionDetails connection,
int sensorId,
int sensorType);
///
/// commits an analog sensor to the db
///
/// DataPRO user making commit
/// connection commit is being made on
/// the record being committed
/// 0 (ERROR_SUCCESS) on success, all other values are error codes
ulong SensorsAnalogUpdateInsert(IUserDbRecord user,
IConnectionDetails connection,
IAnalogDbRecord record);
///
/// retrieves all calibrations matching search criteria
///
/// user querying calibrations
/// connection user is using
/// sensor id (allows null)
/// serial number (allows null and empty)
/// any calibrations matching criteria
/// 0 (ERROR_SUCCESS) on success, all other values are error codes
ulong SensorCalibrationsGet(IUserDbRecord user,
IConnectionDetails connection,
int? sensorId,
string serialNumber,
out ISensorCalDbRecord[] calibrations
);
///
/// retrieves all analog sensors matching search criteria
///
/// user querying sensors
/// connection is using
/// sensor database id (allows null)
/// sensor serial number (allows null)
/// electronic Id (DALLAS or TEDS id value)
/// any sensors matching criteria
/// 0 (ERROR_SUCCES) on success, all other values are error codes
ulong SensorsAnalogGet(IUserDbRecord user,
IConnectionDetails connection,
int? sensorId,
string serialNumber,
string eId,
out IAnalogDbRecord[] sensors);
///
/// retrieves all analog sensors matching search criteria
///
/// user querying sensors
/// connection is using
/// sensor serial number (allows null)
/// any sensors matching criteria
/// 0 (ERROR_SUCCES) on success, all other values are error codes
ulong SensorsGet(IUserDbRecord user,
IConnectionDetails connection,
string serialNumber,
out ISensorDbRecord[] sensors);
ulong UpdateAssemblySensorUsageCount(IUserDbRecord user,
IConnectionDetails connection,
string assemblyName,
int newUsageCount);
///
/// Updates a sensor's (total) usage count
///
/// user querying sensors
/// connection is using
/// The sensor to be updated
///
ulong UpdateSensorUsageCount(IUserDbRecord user,
IConnectionDetails connection,
ISensorData sd);
///
/// Updates a sensor calibration's usage count
///
/// user querying sensors
/// connection is using
/// The sensor to be updated
///
ulong UpdateSensorCalibrationUsageCount(IUserDbRecord user,
IConnectionDetails connection,
int sensorId,
int sensorCalibrationId,
int newUsageCount);
}
}