/// <summary> /// Does the simulation. /// </summary> /// <param name="state">The state.</param> private void DoSimulation(object state) { try { lock (m_lock) { foreach (var blockAddress in m_blocks) { for (int ii = 0; ii < blockAddress.Value.Properties.Count - 1; ii++) { string firstName = blockAddress.Value.Properties[ii].Name; string secondName = blockAddress.Value.Properties[ii + 1].Name; if (!secondName.StartsWith(firstName) || !secondName.EndsWith("SetPoint")) { continue; } int valueOffset = blockAddress.Value.Properties[ii].Offset; int setpointOffset = blockAddress.Value.Properties[ii + 1].Offset; double value = (double)Read(blockAddress.Key, valueOffset); double setpoint = (double)Read(blockAddress.Key, setpointOffset); Write(blockAddress.Key, valueOffset, Adjust(value, setpoint)); } } } } catch (Exception e) { TraceServer.Error(e, "Failed run simulation."); } }