Пример #1
0
        internal void UpdateCloseValue(double averageSensorValue, device_type_t deviceType)
        {
            var       values = Enum.GetValues(typeof(CloseValue));
            HandValue handValue;

            if (deviceType == device_type_t.GLOVE_LEFT)
            {
                handValue = _handValues[0];
            }
            else
            {
                handValue = _handValues[1];
            }

            CloseValue closest = CloseValue.Open;
            // Save the old value for comparisment
            CloseValue oldClose = handValue.CloseValue;

            // Get the current close value
            foreach (CloseValue item in values)
            {
                // Div by 100.0 is used because an enum can only contain ints
                if (averageSensorValue > (double)item / 100.0)
                {
                    closest = item;
                }
            }

            handValue.CloseValue = closest;

            // Invoke the on value changed event
            if (oldClose != handValue.CloseValue && handValue.OnValueChanged != null)
            {
                handValue.OnValueChanged.Invoke(handValue.CloseValue);
            }

            // Check if the hand just closed
            handValue.HandClosed = oldClose == CloseValue.Tiny && handValue.CloseValue == CloseValue.Small;
            // Check if the hand just opened
            handValue.HandOpened = (oldClose == CloseValue.Small && handValue.CloseValue == CloseValue.Open);

            if (deviceType == device_type_t.GLOVE_LEFT)
            {
                _handValues[0] = handValue;
            }
            else
            {
                _handValues[1] = handValue;
            }
        }
        public string ToHtmlString()
        {
            StringBuilder b = new StringBuilder();

            b.Append("mark:        <b>" + Mark + "</b><br>");
            b.Append("amount:      <b>" + OpenAmount.ToString("0.########") + "</b><br>");
            b.Append("open price:  <b>" + OpenValue.ToString("0.########") + "</b><br>");
            b.Append("close price: <b>" + CloseValue.ToString("0.########") + "</b><br>");
            b.Append("stoploss:    <b>" + StopLoss.ToString("0.########") + "</b><br>");
            b.Append("change:      <b>" + Change.ToString("0.##") + "%</b><br>");
            b.Append("spent:       <b>" + Spent.ToString("0.########") + "</b><br>");
            b.Append("earned:      <b>" + Earned.ToString("0.########") + "</b><br>");
            b.Append("profit:      <b>" + Profit.ToString("0.########") + "</b><br>");
            return(b.ToString());
        }