예제 #1
0
        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;
        }
예제 #2
0
 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'));
     }
 }
예제 #5
0
        /// <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);
        }
예제 #6
0
        private void BackSpace(object obj)
        {
            if (currentValue.Length == 0)
            {
                return;
            }

            CurrentValue = CurrentValue.Remove(CurrentValue.Length - 1);
        }
예제 #7
0
        public bool IsLocalOverrideDifferentFromCentralValue()
        {
            if (!HasLocalOverride)
            {
                return(false);
            }

            return(!CurrentValue.Equals(CentralValue));
        }
예제 #8
0
 void BtnMinus_Click(object sender, EventArgs e)
 {
     if (CurrentValue > MinValue)
     {
         CurrentValue--;
         txtValue.Text = CurrentValue.ToString();
         OnNumberChanged?.Invoke(CurrentValue);
     }
 }
예제 #9
0
 void BtnPlus_Click(object sender, EventArgs e)
 {
     if (CurrentValue < MaxValue)
     {
         CurrentValue++;
         txtValue.Text = CurrentValue.ToString();
         OnNumberChanged?.Invoke(CurrentValue);
     }
 }
예제 #10
0
 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();
 }
예제 #11
0
        public string ToSaveGameValue()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(CurrentValue.ToSaveGameValue());
            sb.Append(";");
            sb.Append(MaximumValue.ToSaveGameValue());
            return(sb.ToString());
        }
예제 #12
0
        private void UpdateText()
        {
            if (OnValueChange != null)
            {
                OnValueChange(CurrentValue, this);
            }
            string format = "F" + Digits.ToString();

            _valueDisplay.SetText(CurrentValue.ToString(format));
        }
예제 #13
0
        public override void SetValue(ISelectable value)
        {
            if ((value == null || CurrentValue != value) && CurrentValue != null)
            {
                CurrentValue.Deselect();
            }

            base.SetValue(value);

            CurrentValue?.Select();
        }
예제 #14
0
        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
예제 #16
0
 /// <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();
     }
 }
예제 #17
0
        public Boolean Contains(String Key,
                                Object Value)
        {
            Object CurrentValue;

            if (!_Dictionary.TryGetValue(Key, out CurrentValue))
            {
                return(false);
            }

            return(CurrentValue.ToString() == Value.ToString());
        }
예제 #18
0
 /// <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();
     }
 }
예제 #19
0
 /// <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();
     }
 }
예제 #20
0
        async Task HandleAction(PickerItem item)
        {
            if (!MultiSelect)
            {
                foreach (var val in CurrentValue.Where(x => x.ID != item.ID))
                {
                    val.Selected = false;
                }

                await Done();
            }
        }
예제 #21
0
 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);
     }
 }
예제 #22
0
        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());
        }
예제 #23
0
 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);
        }
예제 #25
0
 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);
         }
     }
 }
예제 #26
0
        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);
        }
예제 #27
0
 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);
 }
예제 #28
0
 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);
 }
예제 #29
0
        /// <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);
            }
        }
예제 #30
0
        protected override void Reevaluate()
        {
            if (_reevaluate != null)
            {
                _reevaluate(this);
            }

            if (CurrentMin.CompareTo(CurrentValue) > 0)
            {
                CurrentValue = CurrentMin;
            }
            if (CurrentValue.CompareTo(CurrentMax) > 0)
            {
                CurrentValue = CurrentMax;
            }
        }
예제 #31
0
        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);
        }
예제 #32
0
파일: ItsImpl.cs 프로젝트: desla/LK
        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();
            }
        }
예제 #33
0
 public void AddCurrentValues(CurrentValue[] aCurrentValues)
 {
     lock (currentValues) {
         currentValues.AddRange(aCurrentValues);
     }
 }
예제 #34
0
        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;

        }
예제 #35
0
파일: ItsImpl.cs 프로젝트: desla/LK
 public bool TryAddCurrentValue(CurrentValue aCurrentValue)
 {
     return TryAddCurrentValues(new [] { aCurrentValue });
 }
예제 #36
0
        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;
                }
            }
        }