//Подготовка провайдера, чтение значений IDCHANNEL public void Prepare() { _signalsIndication.Clear(); _signalsUnit.Clear(); using (var rec = new ReaderAdo(SqlProps, "SELECT OBJECTS.NAME_OBJECT, DEVICES.NAME_DEVICE, LIB_CHANNELS.NAME_TYPE, LIB_CHANNELS.UNIT, CHANNELS.IDCHANNEL, LIB_CHANNELS.TABLE_NAME " + "FROM CHANNELS INNER JOIN DEVICES ON CHANNELS.IDDEVICE = DEVICES.IDDEVICE INNER JOIN " + "LIB_CHANNELS ON dbo.CHANNELS.IDTYPE_CHANNEL = dbo.LIB_CHANNELS.IDTYPE_CHANNEL INNER JOIN " + "POINT_DEVICES ON dbo.DEVICES.IDDEVICE = dbo.POINT_DEVICES.IDDEVICE INNER JOIN " + "POINT_CONNECTIONS ON dbo.POINT_DEVICES.IDPOINT_CONNECTION = dbo.POINT_CONNECTIONS.IDPOINT_CONNECTION INNER JOIN " + "POINT_OBJ ON dbo.POINT_CONNECTIONS.IDPOINT_CONNECTION = dbo.POINT_OBJ.IDPOINT_CONNECTION INNER JOIN " + "OBJECTS ON dbo.POINT_OBJ.IDOBJECT = dbo.OBJECTS.IDOBJECT")) while (rec.Read()) { string code = rec.GetString("NAME_OBJECT") + "." + rec.GetString("NAME_DEVICE") + "." + rec.GetString("NAME_TYPE"); if (ProviderSignals.ContainsKey(code + ".Indication")) { var sig = (SignalMir)ProviderSignals[code + ".Indication"]; sig.IdChannel = rec.GetInt("IDCHANNEL"); _signalsIndication.Add(sig.IdChannel, sig); } if (ProviderSignals.ContainsKey(code + ".Unit")) { var sig = (SignalMir)ProviderSignals[code + ".Unit"]; sig.IdChannel = rec.GetInt("IDCHANNEL"); _signalsUnit.Add(sig.IdChannel, sig); } } }
//Подготовка сигналов public void Prepare() { try { if (CloneFile.IsEmpty()) { return; } Logger.AddEvent("Установка отметок для считываемых сигналов"); _signalsId.Clear(); _signalsStrId.Clear(); using (var rec = new RecDao(CloneFile, "SELECT SignalId, FullCode, Otm FROM Signals")) while (rec.Read()) { string code = rec.GetString("FullCode"); if (!ProviderSignals.ContainsKey(code)) { rec.Put("Otm", false); } else { rec.Put("Otm", true); (ProviderSignals[code].DataType.LessOrEquals(DataType.Real) ? _signalsId : _signalsStrId) .Add(rec.GetInt("SignalId"), ProviderSignals[code]); } } } catch (Exception ex) { Logger.AddError("Ошибка при подготовке сигналов", ex); } }
//Добавление сигнала public ProviderSignal AddSignal(string signalInf, string code, DataType dataType, int idInClone = 0) { if (!ProviderSignals.ContainsKey(code)) { var sig = new ProviderSignal(signalInf, code, dataType, this, idInClone) { Value = new SingleValue(SingleType.List) }; ProviderSignals.Add(code, sig); return(sig); } return(ProviderSignals[code]); }
//Подготовка сигналов public void Prepare() { try { Logger.AddEvent("Подготовка сигналов"); _signalsId.Clear(); _signalsStrId.Clear(); using (var rec = new DataSetSql(SqlProps, "SELECT SignalId, FullCode, Otm FROM Signals")) while (rec.Read()) { string code = rec.GetString("FullCode"); if (ProviderSignals.ContainsKey(code)) { (ProviderSignals[code].DataType.LessOrEquals(DataType.Real) ? _signalsId : _signalsStrId) .Add(rec.GetInt("SignalId"), ProviderSignals[code]); } } } catch (Exception ex) { Logger.AddError("Ошибка при подготовке сигналов", ex); } }