public override void Execute(ModbusClient modbusClient) { ModbusWriteCommandParameters mdb_write_comm_pars = this.CommandParameters as ModbusWriteCommandParameters; ushort outputAddress = mdb_write_comm_pars.OutputAddress; int value = mdb_write_comm_pars.Value; if (outputAddress >= ushort.MaxValue || outputAddress == ushort.MinValue) { string message = $"Address is out of bound. Output address: {outputAddress}."; Logger.LogError(message); throw new Exception(message); } bool commandingValue; if (value == 0) { commandingValue = false; } else if (value == 1) { commandingValue = true; } else { throw new ArgumentException("Non-boolean value in write single coil command parameter."); } //TODO: Check does current scada model has the requested address, maybe let anyway modbusClient.WriteSingleCoil(outputAddress - 1, commandingValue); Logger.LogInfo($"WriteSingleCoilFunction executed SUCCESSFULLY. OutputAddress: {outputAddress}, Value: {commandingValue}"); }
/// <summary> /// Executes a digital write command. /// </summary> /// <param name="configItem">The configuration item.</param> /// <param name="transactionId">The transaction identifier.</param> /// <param name="remoteUnitAddress">The remote unit address.</param> /// <param name="pointAddress">The point address.</param> /// <param name="value">The value.</param> private void ExecuteDigitalCommand(IConfigItem configItem, ushort transactionId, byte remoteUnitAddress, ushort pointAddress, int value) { ModbusWriteCommandParameters p = new ModbusWriteCommandParameters(6, (byte)ModbusFunctionCode.WRITE_SINGLE_COIL, pointAddress, (ushort)value, transactionId, remoteUnitAddress); IModbusFunction fn = FunctionFactory.CreateModbusFunction(p); this.functionExecutor.EnqueueCommand(fn); }
private void WriteCommand_Execute(object obj) { try { ModbusWriteCommandParameters p = null; switch (type) { case PointType.DO_REG: p = new ModbusWriteCommandParameters(6, (byte)ModbusFunctionCode.WRITE_SINGLE_COIL, address, RawValue); break; case PointType.HR_INT: p = new ModbusWriteCommandParameters(6, (byte)ModbusFunctionCode.WRITE_SINGLE_REGISTER, address, RawValue); break; default: break; } // TODO implement ModbusFunction fn = FunctionFactory.CreateModbusFunction(p); this.commandExecutor.ExecuteCommand(fn); } catch (Exception ex) { string message = $"{ex.TargetSite.ReflectedType.Name}.{ex.TargetSite.Name}: {ex.Message}"; this.stateUpdater.LogMessage(message); } }
/// <summary> /// Method that is executed when write button is clicked on control window; /// Method should create write command parameters and provide it to FunctionFactory /// </summary> /// <param name="obj">Not used</param> private void WriteCommand_Execute(object obj) { try { ModbusWriteCommandParameters para = null; switch (type) { case PointType.DIGITAL_OUTPUT: para = new ModbusWriteCommandParameters(6, (byte)ModbusFunctionCode.WRITE_SINGLE_COIL, address, commandedValue); break; case PointType.ANALOG_OUTPUT: para = new ModbusWriteCommandParameters(6, (byte)ModbusFunctionCode.WRITE_SINGLE_REGISTER, address, commandedValue); break; default: break; } ModbusFunction fn = FunctionFactory.CreateModbusFunction(para); this.commandExecutor.EnqueueCommand(fn); } catch (Exception ex) { string message = $"{ex.TargetSite.ReflectedType.Name}.{ex.TargetSite.Name}: {ex.Message}"; this.stateUpdater.LogMessage(message); } }
public static IWriteModbusFunction CreateWriteModbusFunction(ModbusWriteCommandParameters commandParameters, CommandOriginType commandOrigin) { IWriteModbusFunction modbusFunction; if (FunctionFactory.scadaModel == null) { string message = $"CreateWriteModbusFunction => SCADA model is null."; LoggerWrapper.Instance.LogError(message); //TODO: InternalSCADAServiceException throw new Exception(message); } switch ((ModbusFunctionCode)commandParameters.FunctionCode) { case ModbusFunctionCode.WRITE_SINGLE_COIL: modbusFunction = new WriteSingleCoilFunction(commandParameters, commandOrigin); break; case ModbusFunctionCode.WRITE_SINGLE_REGISTER: modbusFunction = new WriteSingleRegisterFunction(commandParameters, commandOrigin); break; default: modbusFunction = null; string message = $"CreateWriteModbusFunction => Wrong function code {(ModbusFunctionCode)commandParameters.FunctionCode}."; LoggerWrapper.Instance.LogError(message); break; } return(modbusFunction); }
/// <summary> /// Executes an analog write command. /// </summary> /// <param name="configItem">The configuration item.</param> /// <param name="transactionId">The transaction identifier.</param> /// <param name="remoteUnitAddress">The remote unit address.</param> /// <param name="pointAddress">The point address.</param> /// <param name="value">The value.</param> private void ExecuteAnalogCommand(IConfigItem configItem, ushort transactionId, byte remoteUnitAddress, ushort pointAddress, int value) { ushort raw = eguConverter.ConvertToRaw(configItem.ScaleFactor, configItem.Deviation, value); ModbusWriteCommandParameters p = new ModbusWriteCommandParameters(6, (byte)ModbusFunctionCode.WRITE_SINGLE_REGISTER, pointAddress, (ushort)raw, transactionId, remoteUnitAddress); IModbusFunction fn = FunctionFactory.CreateModbusFunction(p); this.functionExecutor.EnqueueCommand(fn); }
public override void Execute(ModbusClient modbusClient) { ModbusWriteCommandParameters mdb_write_comm_pars = this.CommandParameters as ModbusWriteCommandParameters; //TODO: Check does current scada model has the requested address, maybe let anyway modbusClient.WriteSingleRegister(mdb_write_comm_pars.OutputAddress - 1, mdb_write_comm_pars.Value); Logger.LogInfo($"WriteSingleRegisterFunction executed SUCCESSFULLY. OutputAddress: {mdb_write_comm_pars.OutputAddress}, Value: {mdb_write_comm_pars.Value}"); }
/// <inheritdoc /> public override Dictionary <Tuple <PointType, ushort>, ushort> ParseResponse(byte[] response) { ModbusWriteCommandParameters para = this.CommandParameters as ModbusWriteCommandParameters; Dictionary <Tuple <PointType, ushort>, ushort> dic = new Dictionary <Tuple <PointType, ushort>, ushort>(); return(dic); }
public override Dictionary <Tuple <PointType, ushort>, ushort> ParseResponse(byte[] response) { ModbusWriteCommandParameters mdmWriteCommParams = this.CommandParameters as ModbusWriteCommandParameters; Dictionary <Tuple <PointType, ushort>, ushort> dic = new Dictionary <Tuple <PointType, ushort>, ushort>(); ushort value = (ushort)(response[11] & (byte)0x1); dic.Add(new Tuple <PointType, ushort>(PointType.DO_REG, mdmWriteCommParams.OutputAddress), value); return(dic); }
/// <inheritdoc /> public override Dictionary <Tuple <PointType, ushort>, ushort> ParseResponse(byte[] response) { var retval = new Dictionary <Tuple <PointType, ushort>, ushort>(); ModbusWriteCommandParameters mbParams = (ModbusWriteCommandParameters)CommandParameters; retval.Add(new Tuple <PointType, ushort>(PointType.DIGITAL_OUTPUT, mbParams.OutputAddress), mbParams.Value); return(retval); }
/// <inheritdoc /> public override Dictionary <Tuple <PointType, ushort>, ushort> ParseResponse(byte[] response) { ModbusWriteCommandParameters para = this.CommandParameters as ModbusWriteCommandParameters; Dictionary <Tuple <PointType, ushort>, ushort> dic = new Dictionary <Tuple <PointType, ushort>, ushort>(); ushort value = (ushort)(response[11] + (response[10] << 8)); dic.Add(new Tuple <PointType, ushort>(PointType.ANALOG_OUTPUT, para.OutputAddress), value); return(dic); }
/// <inheritdoc /> public override Dictionary <Tuple <PointType, ushort>, ushort> ParseResponse(byte[] response) { //Extract all the data bytes from the entire response short dataShort = BitConverter.ToInt16(response, 10); dataShort = IPAddress.NetworkToHostOrder(dataShort); Dictionary <Tuple <PointType, ushort>, ushort> odgovor = new Dictionary <Tuple <PointType, ushort>, ushort>(); ModbusWriteCommandParameters parameters = (ModbusWriteCommandParameters)CommandParameters; odgovor.Add(new Tuple <PointType, ushort>(PointType.ANALOG_OUTPUT, parameters.OutputAddress), (ushort)dataShort); return(odgovor); }
public override byte[] PackRequest() { ModbusWriteCommandParameters mdmWriteCommParams = this.CommandParameters as ModbusWriteCommandParameters; byte[] mdbRequest = new byte[12]; Buffer.BlockCopy(BitConverter.GetBytes(IPAddress.HostToNetworkOrder((short)mdmWriteCommParams.TransactionId)), 0, mdbRequest, 0, 2); Buffer.BlockCopy(BitConverter.GetBytes(IPAddress.HostToNetworkOrder((short)mdmWriteCommParams.ProtocolId)), 0, mdbRequest, 2, 2); Buffer.BlockCopy(BitConverter.GetBytes(IPAddress.HostToNetworkOrder((short)mdmWriteCommParams.Length)), 0, mdbRequest, 4, 2); mdbRequest[6] = mdmWriteCommParams.UnitId; mdbRequest[7] = mdmWriteCommParams.FunctionCode; Buffer.BlockCopy(BitConverter.GetBytes(IPAddress.HostToNetworkOrder((short)mdmWriteCommParams.OutputAddress)), 0, mdbRequest, 8, 2); Buffer.BlockCopy(BitConverter.GetBytes(IPAddress.HostToNetworkOrder((short)mdmWriteCommParams.Value)), 0, mdbRequest, 10, 2); return(mdbRequest); }
protected override void WriteCommand_Execute(object obj) { try { ModbusWriteCommandParameters p = new ModbusWriteCommandParameters(6, (byte)GetWriteFunctionCode(type), address, (ushort)CommandedValue, configuration); IModbusFunction fn = FunctionFactory.CreateModbusFunction(p); this.commandExecutor.EnqueueCommand(fn); } catch (Exception ex) { string message = $"{ex.TargetSite.ReflectedType.Name}.{ex.TargetSite.Name}: {ex.Message}"; this.stateUpdater.LogMessage(message); } }
/// <inheritdoc /> public override byte[] PackRequest() { byte[] paket = new byte[12]; ModbusWriteCommandParameters write = (ModbusWriteCommandParameters)CommandParameters; Buffer.BlockCopy(BitConverter.GetBytes(IPAddress.HostToNetworkOrder((short)write.TransactionId)), 0, paket, 0, 2); Buffer.BlockCopy(BitConverter.GetBytes(IPAddress.HostToNetworkOrder((short)write.ProtocolId)), 0, paket, 2, 2); Buffer.BlockCopy(BitConverter.GetBytes(IPAddress.HostToNetworkOrder((short)write.Length)), 0, paket, 4, 2); paket[6] = write.UnitId; paket[7] = write.FunctionCode; Buffer.BlockCopy(BitConverter.GetBytes(IPAddress.HostToNetworkOrder((short)write.OutputAddress)), 0, paket, 8, 2); Buffer.BlockCopy(BitConverter.GetBytes(IPAddress.HostToNetworkOrder((short)write.Value)), 0, paket, 10, 2); return(paket); }
public override Dictionary <Tuple <PointType, ushort>, ushort> ParseResponse(byte[] response) { ModbusWriteCommandParameters mdmWriteCommParams = this.CommandParameters as ModbusWriteCommandParameters; Dictionary <Tuple <PointType, ushort>, ushort> dic = new Dictionary <Tuple <PointType, ushort>, ushort>(); byte port1 = response[11]; byte port2 = response[10]; ushort value = (ushort)(port1 + (port2 << 8)); dic.Add(new Tuple <PointType, ushort>(PointType.HR_INT, mdmWriteCommParams.OutputAddress), value); return(dic); }
/// <inheritdoc /> public override byte[] PackRequest() { byte[] req = new byte[12]; ModbusWriteCommandParameters mbParams = (ModbusWriteCommandParameters)CommandParameters; Buffer.BlockCopy(BitConverter.GetBytes(Htons((short)mbParams.TransactionId)), 0, req, 0, 2); Buffer.BlockCopy(BitConverter.GetBytes(Htons((short)mbParams.ProtocolId)), 0, req, 2, 2); Buffer.BlockCopy(BitConverter.GetBytes(Htons((short)mbParams.Length)), 0, req, 4, 2); req[6] = mbParams.UnitId; req[7] = mbParams.FunctionCode; Buffer.BlockCopy(BitConverter.GetBytes(Htons((short)mbParams.OutputAddress)), 0, req, 8, 2); Buffer.BlockCopy(BitConverter.GetBytes(Htons((short)mbParams.Value)), 0, req, 10, 2); return(req); }
protected override void WriteCommand_Execute(object obj) { try { // TODO implement ushort raw = 0; raw = EGUConverter.ConvertToRaw(configItem.ScaleFactor, configItem.Deviation, CommandedValue); ModbusWriteCommandParameters p = new ModbusWriteCommandParameters(6, (byte)GetWriteFunctionCode(type), address, raw, configuration); Common.IModbusFunction fn = FunctionFactory.CreateModbusFunction(p); this.commandExecutor.EnqueueCommand(fn); } catch (Exception ex) { string message = $"{ex.TargetSite.ReflectedType.Name}.{ex.TargetSite.Name}: {ex.Message}"; this.stateUpdater.LogMessage(message); } }
/// <inheritdoc /> public override byte[] PackRequest() { ModbusWriteCommandParameters para = this.CommandParameters as ModbusWriteCommandParameters; byte[] retVal = new byte[12]; Buffer.BlockCopy(BitConverter.GetBytes(IPAddress.HostToNetworkOrder((short)para.TransactionId)), 0, retVal, 0, 2); Buffer.BlockCopy(BitConverter.GetBytes(IPAddress.HostToNetworkOrder((short)para.ProtocolId)), 0, retVal, 2, 2); Buffer.BlockCopy(BitConverter.GetBytes(IPAddress.HostToNetworkOrder((short)para.Length)), 0, retVal, 4, 2); retVal[6] = para.UnitId; retVal[7] = para.FunctionCode; Buffer.BlockCopy(BitConverter.GetBytes(IPAddress.HostToNetworkOrder((short)para.OutputAddress)), 0, retVal, 8, 2); Buffer.BlockCopy(BitConverter.GetBytes(IPAddress.HostToNetworkOrder((short)para.Value)), 0, retVal, 10, 2); return(retVal); }
/// <inheritdoc /> public override Dictionary <Tuple <PointType, ushort>, ushort> ParseResponse(byte[] response) { //Extract all the data bytes from the entire response short dataShort = BitConverter.ToInt16(response, 10); dataShort = IPAddress.NetworkToHostOrder(dataShort); Dictionary <Tuple <PointType, ushort>, ushort> odgovor = new Dictionary <Tuple <PointType, ushort>, ushort>(); ModbusWriteCommandParameters parameters = (ModbusWriteCommandParameters)CommandParameters; odgovor.Add(new Tuple <PointType, ushort>(PointType.DIGITAL_OUTPUT, parameters.OutputAddress), (ushort)dataShort); return(odgovor); //// this is the solution for a single bit ////byte dataByte = response[9]; ////ushort dataBit = (ushort)(dataByte & 1); //Dictionary<Tuple<PointType, ushort>, ushort> odgovor = new Dictionary<Tuple<PointType, ushort>, ushort>(); //ModbusWriteCommandParameters parameters = (ModbusWriteCommandParameters)CommandParameters; //// used for counting the amount of data in the dictionary and comparing that to the quantity of data in the response //ushort bitCounter = 0; ////byte for loop, 9 is the first byte of data in the response //for (int i = 9; i < response.Length; i++) //{ // // bit for loop (8 bits in 1 byte) // for (int j = 0; j < 8; j++) // { // // shift the mask to the left j number of times // ushort dataBit = (ushort)(response[i] & (1 << j)); // odgovor.Add(new Tuple<PointType, ushort>(PointType.DIGITAL_OUTPUT, (ushort)(parameters.OutputAddress + bitCounter)), dataBit); // bitCounter++; // } //} //return odgovor; }
public override Dictionary <Tuple <PointType, ushort>, ushort> ParseResponse(byte[] response) { ModbusWriteCommandParameters mdb_write_comm_pars = this.CommandParameters as ModbusWriteCommandParameters; Dictionary <Tuple <PointType, ushort>, ushort> returnResponse = new Dictionary <Tuple <PointType, ushort>, ushort>(); if (response[7] == (byte)ModbusFunctionCode.WRITE_SINGLE_REGISTER) { byte[] array = new byte[2]; array[0] = response[9]; array[1] = response[8]; ushort out_a = BitConverter.ToUInt16(array, 0); array[0] = response[11]; array[1] = response[10]; ushort value = BitConverter.ToUInt16(array, 0); returnResponse.Add(new Tuple <PointType, ushort>(PointType.ANALOG_OUTPUT, out_a), value); } return(returnResponse); }
/// <summary> /// Method that is executed when write button is clicked on control window; /// Method should create write command parameters and provide it to FunctionFactory /// </summary> /// <param name="obj">Not used</param> private void WriteCommand_Execute(object obj) { try { ModbusWriteCommandParameters mwp = null; if (type == PointType.DIGITAL_OUTPUT) { mwp = new ModbusWriteCommandParameters(6, (byte)ModbusFunctionCode.WRITE_SINGLE_COIL, address, rawValue); ModbusFunction fn = FunctionFactory.CreateModbusFunction(mwp); this.commandExecutor.EnqueueCommand(fn); } else if (type == PointType.ANALOG_OUTPUT) { mwp = new ModbusWriteCommandParameters(6, (byte)ModbusFunctionCode.WRITE_SINGLE_REGISTER, address, rawValue); ModbusFunction fn = FunctionFactory.CreateModbusFunction(mwp); this.commandExecutor.EnqueueCommand(fn); } } catch (Exception ex) { string message = $"{ex.TargetSite.ReflectedType.Name}.{ex.TargetSite.Name}: {ex.Message}"; this.stateUpdater.LogMessage(message); } }
public void SendListOfGenerators(Dictionary <long, double> generators) { foreach (KeyValuePair <long, double> generator in generators) { //if (analogniStari.ContainsKey(generator.Key)) //{ foreach (KeyValuePair <List <long>, ushort> gidoviNaAdresu in GidoviNaAdresu) { if (generator.Key == gidoviNaAdresu.Key[0]) { if (analogniStari.Keys.Contains(gidoviNaAdresu.Key[1])) { if (analogniStari[gidoviNaAdresu.Key[1]].Description == "Commanding") { { KeyValuePair <long, IdentifiedObject> a = analogniStari.ElementAt(gidoviNaAdresu.Value - 3000 - 1); float zbir = ((Analog)a.Value).NormalValue + (float)generator.Value * ((Analog)a.Value).NormalValue / 100; ((Analog)a.Value).NormalValue = zbir; zbir = (float)Math.Round(zbir); double vred = (generator.Value * ((Analog)a.Value).NormalValue / 100); vred = (double)Math.Round(vred); if (vred < 0) { vred = vred * (-1); } ModbusWriteCommandParameters p = new ModbusWriteCommandParameters(6, (byte)ModbusFunctionCode.WRITE_SINGLE_REGISTER, gidoviNaAdresu.Value, (ushort)vred, configuration); Common.IModbusFunction fn = FunctionFactory.CreateModbusFunction(p); commandExecutor.EnqueueCommand(fn); ModbusWriteCommandParameters p1 = new ModbusWriteCommandParameters(6, (byte)ModbusFunctionCode.WRITE_SINGLE_REGISTER, (ushort)(gidoviNaAdresu.Value - 2), (ushort)zbir, configuration); Common.IModbusFunction fn1 = FunctionFactory.CreateModbusFunction(p1); commandExecutor.EnqueueCommand(fn1); } } } else if (digitalniStari.Keys.Contains(gidoviNaAdresu.Key[1])) { if (digitalniStari[gidoviNaAdresu.Key[1]].Description == "Commanding") { { ModbusWriteCommandParameters p = new ModbusWriteCommandParameters(6, (byte)ModbusFunctionCode.WRITE_SINGLE_COIL, gidoviNaAdresu.Value, (ushort)generator.Value, configuration); Common.IModbusFunction fn = FunctionFactory.CreateModbusFunction(p); commandExecutor.EnqueueCommand(fn); } } } } //else if (digitalniStari.ContainsKey(generator.Key)) //{ // foreach (KeyValuePair<List<long>, ushort> gidoviNaAdresu in GidoviNaAdresu) // { // if (generator.Key == gidoviNaAdresu.Key[0] && gidoviNaAdresu.Key[2] == 1) // { // ushort raw = 0; // raw = EGUConverter.ConvertToRaw(2, 5, generator.Value); // ModbusWriteCommandParameters p = new ModbusWriteCommandParameters(6, (byte)ModbusFunctionCode.WRITE_SINGLE_COIL, gidoviNaAdresu.Value, raw, configuration); // Common.IModbusFunction fn = FunctionFactory.CreateModbusFunction(p); // commandExecutor.EnqueueCommand(fn); // } // } //} } // LISTA GENERATORA KOJI SU PROMENILI FLEXIBILITY } }
public async Task <bool> GetWeatherForecastAsyncSimulate() { //MOCK_Start bool isFileFull = true; Dictionary <long, List <HourDataPoint> > keyValuePairs = new Dictionary <long, List <HourDataPoint> >(); //Dictionary<long, List<HourDataPoint>> keyValuePairs = cache.ReadFromFileDataPoint(); if (keyValuePairs.Count == 0) { isFileFull = false; } //MOCK_End foreach (KeyValuePair <long, IdentifiedObject> kvp in analogniStari) { List <HourDataPoint> hourDataPoints; //MOCK_Start if (!isFileFull) { //MOCK_End Forecast result = await darkSkyProxy.GetTimeMachineWeatherAsync(((Analog)kvp.Value).Longitude, ((Analog)kvp.Value).Latitude, DateTime.Now, Unit.Auto); hourDataPoints = result.Hourly.Hours.ToList(); //MOCK_Start keyValuePairs.Add(((Analog)kvp.Value).GlobalId, hourDataPoints); } else { hourDataPoints = keyValuePairs[((Analog)kvp.Value).GlobalId]; DateTimeOffset timeOffset = DateTimeOffset.Parse("00:00 AM"); foreach (HourDataPoint dataPoint in hourDataPoints) { dataPoint.Time = timeOffset; timeOffset = timeOffset.AddHours(1); } } //MOCK_End DERMSCommon.WeatherForecast.WeatherForecast weatherForecast = new DERMSCommon.WeatherForecast.WeatherForecast(1001, 1, 1, 1, 1, DateTime.Now, ""); foreach (HourDataPoint hdr in hourDataPoints) { if (hdr.Time.Hour.Equals(DateTime.Now.Hour)) { hourDataPoint = hdr; } } float vrednost = 0; vrednost = CalculateHourAhead(((Analog)kvp.Value).Name, ((Analog)kvp.Value).NormalValue, ((Analog)kvp.Value).Latitude, ((Analog)kvp.Value).Longitude); foreach (KeyValuePair <List <long>, ushort> gidoviNaAdresu in GidoviNaAdresu) { if (gidoviNaAdresu.Key[1] == (((Analog)kvp.Value).GlobalId) && ((Analog)kvp.Value).Description == "Simulation") { try { ModbusWriteCommandParameters p = new ModbusWriteCommandParameters(6, (byte)ModbusFunctionCode.WRITE_SINGLE_REGISTER, gidoviNaAdresu.Value, (ushort)vrednost, configuration); Common.IModbusFunction fn = FunctionFactory.CreateModbusFunction(p); commandExecutor.EnqueueCommand(fn); ((Analog)kvp.Value).NormalValue = vrednost; ModbusWriteCommandParameters p1 = new ModbusWriteCommandParameters(6, (byte)ModbusFunctionCode.WRITE_SINGLE_REGISTER, (ushort)(gidoviNaAdresu.Value - 1), (ushort)vrednost, configuration); Common.IModbusFunction fn1 = FunctionFactory.CreateModbusFunction(p1); commandExecutor.EnqueueCommand(fn1); ModbusWriteCommandParameters p12 = new ModbusWriteCommandParameters(6, (byte)ModbusFunctionCode.WRITE_SINGLE_REGISTER, (ushort)(gidoviNaAdresu.Value - 2), 0, configuration); Common.IModbusFunction fn12 = FunctionFactory.CreateModbusFunction(p12); commandExecutor.EnqueueCommand(fn12); } catch (Exception ex) { string message = $"{ex.TargetSite.ReflectedType.Name}.{ex.TargetSite.Name}: {ex.Message}"; return(false); } } } } //MOCK_Start if (!isFileFull) { cache.WriteToFile(keyValuePairs); } //MOCK_End //foreach (KeyValuePair<long, IdentifiedObject> kvp in digitalniStari) //{ // float vrednost = 0; // List<Forecast> fo = new List<Forecast>(); // GetWeatherForecastAsync(((Discrete)kvp.Value).Latitude, ((Discrete)kvp.Value).Longitude); // vrednost = CalculateHourAhead(((Discrete)kvp.Value).Name, ((Discrete)kvp.Value).NormalValue, ((Discrete)kvp.Value).Latitude, ((Discrete)kvp.Value).Latitude); // foreach (KeyValuePair<List<long>, ushort> gidoviNaAdresu in GidoviNaAdresu) // { // if (gidoviNaAdresu.Key.Contains(((Discrete)kvp.Value).GlobalId)) // { // ushort raw = 0; // raw = EGUConverter.ConvertToRaw(2, 5, vrednost); // ModbusWriteCommandParameters p = new ModbusWriteCommandParameters(6, (byte)ModbusFunctionCode.WRITE_SINGLE_COIL, gidoviNaAdresu.Value, raw, configuration); // IModbusFunction fn = FunctionFactory.CreateModbusFunction(p); // commandExecutor.EnqueueCommand(fn); // } // } //} if (analogniStari.Count.Equals(0)) { return(false); } return(true); }