public bool TryPrepareValues(CurrentValue[] aCurrentValues) { logger.Info("Подготовка данных..."); if (!IsInitialized()) { logger.Info("Нельзя подготовить данные без инициализации."); return false; } try { lock (currentValueIds) { foreach (var currentValue in aCurrentValues) { var isFind = false; foreach (var currentValueInfo in currentValueInfos) { if (currentValue.Info.Equals(currentValueInfo)) { currentValue.Ids = currentValueIds[currentValueInfo].GetCopy(); isFind = true; break; } } if (!isFind) { logger.Info("Для текущего показания не обнаружены идентификаторы: " + currentValue.Info.DataName); } } } } catch (Exception ex) { logger.Error("Ошибка при подготовке данных: " + ex.Message); return false; } logger.Info("Данные подготовлены успешно."); return true; }
internal PinEventConfiguration(int gpioPin, PinEventState eventState, CurrentValue currentValue, PreviousValue previousValue, CancellationTokenSource?token = default) { GpioPin = gpioPin; EventState = eventState; EventToken = token == null ? new CancellationTokenSource() : token; Current = currentValue; Previous = previousValue; }
public string FormatValue() { if (isUpperLetter) { return(Convert.ToChar(('A' + CurrentValue - 1)).ToString(CultureInfo.InvariantCulture)); } return(CurrentValue.ToString(CultureInfo.InvariantCulture)); }
private void SerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e) { CurrentValue = _serialPort.ReadLine(); if (!string.IsNullOrWhiteSpace(CurrentValue)) { ParsedValue = ParseSerialPortData(CurrentValue.Trim('\r')); } }
/// <summary> /// Create a list of key value grouped by GID /// </summary> /// <param name="LoopIDToExtract">Value to extract</param> /// <returns>A list that contains all Key and Values into strings</returns> private List <StructValueList> ExtractValues(int LoopIDToExtract) { List <StructValueList> RetNotSorted = null; StructValueList ValueToAdd; bool IsValueAdded = false; if (_Items != null) { // Read all items and try to add values into list foreach (StructuredFileKey CurrentValue in _Items) { // Clear added flags IsValueAdded = false; // Check if current value is included in a loop if (CurrentValue.GetLoopID() == LoopIDToExtract) { int CaseID = CurrentValue.GetLoopID() * 100 + CurrentValue.GetGID(); if (RetNotSorted == null) { RetNotSorted = new List <StructValueList>(); IsValueAdded = false; } else { // Read all ValueList and add the current value (and key) into the correct loop for (int i = 0; i < RetNotSorted.Count(); i++) { if (RetNotSorted[i].CaseID == CaseID) { ValueToAdd.CaseID = CaseID; ValueToAdd.KeyList = RetNotSorted[i].KeyList + "|" + CurrentValue.GetName(); ValueToAdd.ValueList = RetNotSorted[i].ValueList + "|" + CurrentValue.GetValue(); RetNotSorted[i] = ValueToAdd; IsValueAdded = true; } } } // If current value has not been added, we create a new entry if (IsValueAdded == false) { // Create the new entry ValueToAdd.CaseID = CaseID; ValueToAdd.KeyList = CurrentValue.GetName(); ValueToAdd.ValueList = CurrentValue.GetValue(); RetNotSorted.Add(ValueToAdd); } } } } return(RetNotSorted); }
private void BackSpace(object obj) { if (currentValue.Length == 0) { return; } CurrentValue = CurrentValue.Remove(CurrentValue.Length - 1); }
public bool IsLocalOverrideDifferentFromCentralValue() { if (!HasLocalOverride) { return(false); } return(!CurrentValue.Equals(CentralValue)); }
void BtnMinus_Click(object sender, EventArgs e) { if (CurrentValue > MinValue) { CurrentValue--; txtValue.Text = CurrentValue.ToString(); OnNumberChanged?.Invoke(CurrentValue); } }
void BtnPlus_Click(object sender, EventArgs e) { if (CurrentValue < MaxValue) { CurrentValue++; txtValue.Text = CurrentValue.ToString(); OnNumberChanged?.Invoke(CurrentValue); } }
void SubscriberDataUpdated(object sender, DataUpdatedEventArgs <T> e) { OnDataUpdated(e); CurrentValue = e.Data.GetValue(); CurrentValueString = CurrentValue.ToString(); RefreshRate = (int)(e.Data.TimeStamp - TimeStamp).TotalMilliseconds; TimeStamp = e.Data.TimeStamp; Quality = e.Data.Quality.ToString(); }
public string ToSaveGameValue() { StringBuilder sb = new StringBuilder(); sb.Append(CurrentValue.ToSaveGameValue()); sb.Append(";"); sb.Append(MaximumValue.ToSaveGameValue()); return(sb.ToString()); }
private void UpdateText() { if (OnValueChange != null) { OnValueChange(CurrentValue, this); } string format = "F" + Digits.ToString(); _valueDisplay.SetText(CurrentValue.ToString(format)); }
public override void SetValue(ISelectable value) { if ((value == null || CurrentValue != value) && CurrentValue != null) { CurrentValue.Deselect(); } base.SetValue(value); CurrentValue?.Select(); }
public void MustBeContainedIn(Interval i) { CSP.AssertConfigurationPhase(); Interval intersection = Interval.Intersection(Value, i); if (intersection.Empty) { throw new ArgumentException("Argument out of current range of variable."); } CurrentValue.SetInitialValue(intersection); }
} // mozda ima sredjivanja private void del_Click(object sender, RoutedEventArgs e) { if (CurrentValue != "0") { CurrentValue = CurrentValue.Substring(0, CurrentValue.Length - 1); } if (CurrentValue == "") { CurrentValue = "0"; } } // Treba da se sredi malo
/// <summary> /// Converts the CurrentValue to its reciprocal. If the current value is /// equal to zero. Take the passedVar and divide it by one to get the inverse of it. /// If it is not equal to zero, process the operation and call the Equals method to /// keep performing operations. /// </summary> /// <param name="passedVar">The passed variable.</param> public void ToReciprocal(double passedVar) { if (CurrentValue.CompareTo(passedVar) == 0) { CurrentValue = 1 / CurrentValue; } else { Operand2 = 1 / CurrentValue; Equals(); } }
public Boolean Contains(String Key, Object Value) { Object CurrentValue; if (!_Dictionary.TryGetValue(Key, out CurrentValue)) { return(false); } return(CurrentValue.ToString() == Value.ToString()); }
/// <summary> /// Converts the CurrentValue to a negative number if the number is /// equal to zero. If the number is equal to zero make it (number 0) equal /// to the second operand and call the Equals method to keep performing operations. /// </summary> /// <param name="passedVar">The passed variable.</param> public void ToNegativeNumber(double passedVar) { if (CurrentValue.CompareTo(passedVar) == 0) { CurrentValue = CurrentValue * -1; } else { Operand2 = passedVar * -1; Equals(); } }
/// <summary> /// Squares the root if the value being square rooted is equal to zero. /// If the value is equal to zero. Process the operation and call the /// equals method to keep performing operations. /// </summary> /// <param name="passedVar">The passed variable.</param> public void SquareRoot(double passedVar) { if (CurrentValue.CompareTo(passedVar) == 0) { CurrentValue = Math.Sqrt(CurrentValue); } else { Operand2 = Math.Sqrt(passedVar); Equals(); } }
async Task HandleAction(PickerItem item) { if (!MultiSelect) { foreach (var val in CurrentValue.Where(x => x.ID != item.ID)) { val.Selected = false; } await Done(); } }
public T As <T>() { if (!CurrentValue.GetType().IsAssignableFrom(typeof(T)) && World.Instance.Ktd.ContainsType(Type.Name)) { KtdType typeAsKtdType = World.Instance.Ktd.GetKtdType(Type.Name); Type t = typeof(T); return((T)typeAsKtdType.AssignValuesToNativeType(Value, t)); } else { return((T)Value); } }
public string FormatValue() { StringBuilder sb = new StringBuilder(); if (CurrentValue != null) { sb.Append(CurrentValue.ToString()); if (CurrentValueUnit != null && CurrentValueUnit.Length > 0) { sb.Append(" " + CurrentValueUnit); } } return(sb.ToString()); }
private void TimerOnTick(int counttick) { if (CurrentValue.Alpha < Target.Alpha) { CurrentValue.WithAlpha((byte)(CurrentValue.Alpha + Step.Alpha)); CurrentValue.WithRed((byte)(CurrentValue.Red + Step.Red)); CurrentValue.WithGreen((byte)(CurrentValue.Green + Step.Green)); CurrentValue.WithBlue((byte)(CurrentValue.Blue + Step.Blue)); } else { Stop(); } }
public void SimulateDataChange() { CurrentValue dummyDataChangeEvent = new CurrentValue(); dummyDataChangeEvent.Tagname = TagName; dummyDataChangeEvent.Value = 1; dummyDataChangeEvent.Time = DateTime.Now; dummyDataChangeEvent.Quality = DataQuality.Good; List <CurrentValue> dummyValues = new List <CurrentValue>(); dummyValues.Add(dummyDataChangeEvent); _testModule.Historian_DataChangedEvent(dummyValues); }
public void FromSaveGameValue(string dataStr) { string[] tokens = dataStr.Split(';'); if (tokens.Length == 2) { try { MaximumValue.FromSaveGameValue(tokens[1]); CurrentValue.FromSaveGameValue(tokens[0]); } catch (System.Exception) { Debug.LogError("invalid format of " + dataStr); } } }
public override string GetResult() { var s = ""; s += "Backtesting Project " + Name + " from " + TestStartTime.ToString() + " to " + TestEndTime.ToString() + "\n"; s += "Current Value:" + CurrentValue.ToString() + "\n"; s += "Pnl:" + Pnl.ToString() + "\n"; s += "Efficiency:" + Efficiency.ToString() + "\n"; s += "AverageEfficiency:" + AverageEfficiency.ToString() + "\n"; s += "Max Lost:" + MaxLost.ToString() + "\n"; s += "Max Capital:" + MaxCapital.ToString() + "\n"; s += "Max Lost Percent:" + MaxLostPercent.ToString() + "\n"; return(s); }
public override void Draw(SpriteBatch spriteBatch) { //We want to preserve the slider skin's original height. SliderRange.Draw(spriteBatch, AbsolutePosition, Width, SliderRange.BottomMostPatch - SliderRange.TopMostPatch, 0f, EffectiveOpacity); spriteBatch.Draw(CurSliderTexture, new Vector2(AbsoluteX + SliderRange.LeftWidth - (CurSliderTexture.Width) + SliderPosition, AbsoluteY), null, Color.White * EffectiveOpacity, 0f, new Vector2(CurSliderTexture.Width / -2, 0), 1f, SpriteEffects.None, 0f); if (DrawText) { int drawX = AbsoluteX + (Width) / 2; int drawY = AbsoluteY; Vector2 offset = GeeUIMain.Font.MeasureString(CurrentValue.ToString()); offset.X = (int)(offset.X / 2); spriteBatch.DrawString(GeeUIMain.Font, CurrentValue.ToString(), new Vector2(drawX, drawY), TextColor * EffectiveOpacity, 0f, offset, 1f, SpriteEffects.None, 0f); } base.Draw(spriteBatch); }
public void RemoveCode() { if (string.IsNullOrEmpty(CurrentValue)) { if (Values.Count > 0) { var value = Values.Pop(); CurrentValue = value.ToString(); } } else { CurrentValue = CurrentValue.Substring(0, CurrentValue.Length - 1); } ValuesChanged?.Invoke(this, EventArgs.Empty); }
/// <summary> /// Updates FrontImage Size and LocalPosition and other Value Label text /// </summary> private void UpdateUIFromValueChange() { float valueMappedToZeroOne = (CurrentValue - MinValue) / (MaxValue - MinValue); float newX = Size.X * (valueMappedToZeroOne - 1) * 0.5f; FrontImage.LocalPosition = new Vector2(newX, 0); FrontImage.Size = new Vector2(valueMappedToZeroOne * Size.X, Size.Y); // Update our value label text ValueLabel.Text = CurrentValue.ToString(); if (OnValueChanged != null) { OnValueChanged(this); } }
protected override void Reevaluate() { if (_reevaluate != null) { _reevaluate(this); } if (CurrentMin.CompareTo(CurrentValue) > 0) { CurrentValue = CurrentMin; } if (CurrentValue.CompareTo(CurrentMax) > 0) { CurrentValue = CurrentMax; } }
public override bool Equals(object obj) { var other = obj as EnumValueCollection; if (other != null) { if (string.Equals(SourceEnum, other.SourceEnum)) { if (CurrentValue.Equals(other.CurrentValue)) { return(true); } } } return(false); }
public bool TryAddCurrentValues(CurrentValue[] aCurrentValues) { logger.Info("Добавление информации текущих параметров..."); try { var connection = connectionHolder.WaitConnection(); var properties = OracleCommands.Default; using (var transaction = connection.BeginTransaction()) using (var command = new OracleCommand(properties.InsertCurrentValueCommand)) { command.Connection = connection; command.Transaction = transaction; command.Parameters.Add(properties.pDataInfoId, OracleDbType.Int32); command.Parameters.Add(properties.pObjectInfoId, OracleDbType.Int32); command.Parameters.Add(properties.pValueTime, OracleDbType.Date); command.Parameters.Add(properties.pValue, OracleDbType.Double); if (aCurrentValues != null) { foreach (var currentValue in aCurrentValues) { command.Parameters[properties.pDataInfoId].Value = currentValue.Ids.DataId; command.Parameters[properties.pObjectInfoId].Value = currentValue.Ids.ObjectId; command.Parameters[properties.pValueTime].Value = currentValue.ValueTime; command.Parameters[properties.pValue].Value = currentValue.Value; command.ExecuteNonQuery(); } } transaction.Commit(); } logger.Info("Текущие параметры успешно добавлены в ИТС."); return true; } catch (Exception ex) { logger.Error("Ошибка при добавлении текущих параметров: " + ex.Message); return false; } finally { connectionHolder.ReleaseConnection(); } }
public void AddCurrentValues(CurrentValue[] aCurrentValues) { lock (currentValues) { currentValues.AddRange(aCurrentValues); } }
public object QueryCurrentValue(params string[] tags) { ItemErrors errors; Proficy.Historian.ClientAccess.API.DataSet set = new Proficy.Historian.ClientAccess.API.DataSet(); DataQueryParams query = new CurrentValueQuery(tags) { Fields = DataFields.Time | DataFields.Value | DataFields.Quality }; CurrentValue cv= new CurrentValue(); sc.IData.Query(ref query, out set, out errors); return set; }
public bool TryAddCurrentValue(CurrentValue aCurrentValue) { return TryAddCurrentValues(new [] { aCurrentValue }); }
private void ReadCurrentValues(object sender, ElapsedEventArgs e) { lock (isActiveLock) { if (isActive) { return; } isActive = true; } try { var results = new List<CurrentValue>(); var currentValueInfos = opcTag.Keys; foreach (var currentValueInfo in currentValueInfos) { var value = opcTag[currentValueInfo].ReadCurrentValue(); var result = new CurrentValue(); result.Info = currentValueInfo; result.ValueTime = DateTime.Now; result.Value = Convert.ToDouble(value); results.Add(result); } if (results.Count > 0) { if (callback != null) { callback.OnCurrentValueReceived(this, results.ToArray()); } } } catch (Exception ex) { logger.Error("Ошибка при чтении текущего значения: " + ex.Message); } finally { lock (isActiveLock) { isActive = false; } } }