Пример #1
0
        public static async Task WriteTemperatureLogAsync(decimal eventNumber, ModbusPortCommunication portCommunication)
        {
            (int relayOut, double lastScanTemp) = await Task.Run(() =>
                                                                 portCommunication?.ReadLastInputData() ?? (0, 0.0)).ConfigureAwait(false);

            ScanResult scanResult =
                await ADOSqlClient.ReadFullUserDataAsync(eventNumber).ConfigureAwait(false);

            scanResult.RelayOut     = relayOut;
            scanResult.LastScanTemp = lastScanTemp;

            await ADOSqlClient.SaveTemperatureDataAsync(scanResult).ConfigureAwait(false);

#if DEBUG
            Console.WriteLine(scanResult);
#endif
        }
Пример #2
0
 /// <summary>
 /// Represents KeyValue pairs where key is id of control point and value is a particular serial device.
 /// 
 /// Control points ID in the build A:
 ///     9 - ВХІД01,
 ///     23 - ВХІД02,
 ///     25 - ВХІД03,
 ///     27 - ВХІД04.
 /// Control points ID in build B:
 ///     95 - MQB02 — IN01,
 ///     97 - MQB02 — IN02 (Currently used),
 ///     99 - MQB02 — IN03,
 ///     101 - MQB02 — IN04
 /// 
 /// Serial device port name in the build A: COM11.
 /// Serial device port name in the build B: COM13.
 /// </summary>
        private Dictionary<int, ModbusPortCommunication> Turnstiles { get; set; }

        public MonitorChange()
        {
            Turnstiles = new Dictionary<int, ModbusPortCommunication>()
     {
         { 9, new ModbusPortCommunication("COM11") },
         { 97, new ModbusPortCommunication("COM13") }
     };

            tblEvents_55Dependency = new SqlTableDependency<tblEvents_55>(
                connectionString: ADOSqlClient.GetConnectionString("StopNet4_3DB"),
                schemaName: "dbo",
                notifyOn: DmlTriggerType.Insert);

            tblEvents_55Dependency.OnChanged += TableDependency_Changed;
            tblEvents_55Dependency.OnError += TableDependency_OnError;
        }