예제 #1
0
        /*
         *  1 byte (header byte 0x0) [0]
         *  5 bytes upper left LCD   [1 - 5]
         *  5 bytes upper right LCD  [6 - 10]
         *  5 bytes lower left LCD   [11- 15]
         *  5 bytes lower right LCD  [16- 20]
         *
         *  0x01 - 0x09 displays the figure 1-9
         *  0xD1 - 0xD9 displays the figure 1.-9. (figure followed by dot)
         *  0xFF -> blank, nothing is shown in that spot.
         *
         *  var bytes = new byte[21];
         *  bytes[0] = 0x0;
         *  bytes = SetPZ69FrequencyBytes(bytes, _lcdFrequencyActiveUpper, 1);
         *  bytes = SetPZ69FrequencyBytes(bytes, _lcdFrequencyStandbyUpper, 6);
         *  bytes = SetPZ69FrequencyBytes(bytes, _lcdFrequencyActiveLower, 11);
         *  bytes = SetPZ69FrequencyBytes(bytes, _lcdFrequencyStandbyLower, 16);
         */
        protected void SetPZ69DisplayBytesInteger(ref byte[] bytes, int digits, PZ69LCDPosition pz69LCDPosition)
        {
            var arrayPosition  = GetArrayPosition(pz69LCDPosition);
            var i              = 0;
            var digitsAsString = digits.ToString().PadLeft(5);

            //D = DARK
            //116 should become DD116!
            //Common.DebugP("Arrayposition : " + arrayPosition + " is " + frequencyAsString);
            do
            {
                //5 digits can be displayed
                //12345 -> 12345
                //116   -> DD116
                //1     -> DDDD1

                byte b;
                if (digitsAsString[i].ToString().Equals(" "))
                {
                    b = 0xFF;
                }
                else
                {
                    b = Byte.Parse(digitsAsString[i].ToString());
                }
                bytes[arrayPosition] = b;
                //Common.DebugP("Byte [" + arrayPosition + "] has been set to " + b);
                arrayPosition++;
                i++;
            } while (i < digitsAsString.Length && i < 6);
        }
예제 #2
0
        private int GetArrayPosition(PZ69LCDPosition pz69LCDPosition)
        {
            switch (pz69LCDPosition)
            {
            case PZ69LCDPosition.UPPER_LEFT:
            {
                return(1);
            }

            case PZ69LCDPosition.UPPER_RIGHT:
            {
                return(6);
            }

            case PZ69LCDPosition.LOWER_LEFT:
            {
                return(11);
            }

            case PZ69LCDPosition.LOWER_RIGHT:
            {
                return(16);
            }
            }
            return(1);
        }
예제 #3
0
        private void ShowIdentifyingValue()
        {
            try
            {
                var bytes = new byte[21];
                bytes[0] = 0x0;
                PZ69LCDPosition pz69LCDPosition  = PZ69LCDPosition.UPPER_ACTIVE_LEFT;
                var             random           = new Random();
                var             lcdPositionArray = Enum.GetValues(typeof(PZ69LCDPosition));
                var             lcdValueArray    = new string[] { "00000", "11111", "22222", "33333", "44444", "55555", "66666", "77777", "88888", "99999" };
                var             spins            = 8;

                while (spins > 0)
                {
                    var position = (PZ69LCDPosition)lcdPositionArray.GetValue(random.Next(lcdPositionArray.Length));
                    var value    = (string)lcdValueArray.GetValue(random.Next(lcdValueArray.Length));

                    SetPZ69DisplayBytesString(ref bytes, value, position);
                    SendLCDData(bytes);

                    Thread.Sleep(500);
                    spins--;
                }
            }
            catch (Exception e)
            {
            }
        }
예제 #4
0
        public void AddOrUpdateLCDBinding(DCSBIOSOutputFormula dcsbiosOutputFormula, PZ69LCDPosition pz69LCDPosition)
        {
            var found            = false;
            var pz69DialPosition = _pz69UpperDialPosition;

            if (pz69LCDPosition == PZ69LCDPosition.LOWER_STBY_RIGHT || pz69LCDPosition == PZ69LCDPosition.LOWER_ACTIVE_LEFT)
            {
                pz69DialPosition = _pz69LowerDialPosition;
            }
            foreach (var dcsBiosBindingLCD in _dcsBiosLcdBindings)
            {
                if (dcsBiosBindingLCD.DialPosition == pz69DialPosition && dcsBiosBindingLCD.PZ69LcdPosition == pz69LCDPosition)
                {
                    dcsBiosBindingLCD.DCSBIOSOutputFormulaObject = dcsbiosOutputFormula;
                    Debug.Print("3 found");
                    found = true;
                    break;
                }
            }
            if (!found)
            {
                var dcsBiosBindingLCD = new DCSBIOSBindingLCDPZ69();
                dcsBiosBindingLCD.DialPosition = pz69DialPosition;
                dcsBiosBindingLCD.DCSBIOSOutputFormulaObject = dcsbiosOutputFormula;
                dcsBiosBindingLCD.PZ69LcdPosition            = pz69LCDPosition;
                _dcsBiosLcdBindings.Add(dcsBiosBindingLCD);
            }
            IsDirtyMethod();
        }
        /*
         *  1 byte (header byte 0x0) [0]
         *  5 bytes upper left LCD   [1 - 5]
         *  5 bytes upper right LCD  [6 - 10]
         *  5 bytes lower left LCD   [11- 15]
         *  5 bytes lower right LCD  [16- 20]
         *
         *  0x01 - 0x09 displays the figure 1-9
         *  0xD1 - 0xD9 displays the figure 1.-9. (figure followed by dot)
         *  0xFF -> blank, nothing is shown in that spot.
         *
         *  var bytes = new byte[21];
         *  bytes[0] = 0x0;
         *  bytes = SetPZ69FrequencyBytes(bytes, _lcdFrequencyActiveUpper, 1);
         *  bytes = SetPZ69FrequencyBytes(bytes, _lcdFrequencyStandbyUpper, 6);
         *  bytes = SetPZ69FrequencyBytes(bytes, _lcdFrequencyActiveLower, 11);
         *  bytes = SetPZ69FrequencyBytes(bytes, _lcdFrequencyStandbyLower, 16);
         */
        protected void SetPZ69DisplayBytesInteger(ref byte[] bytes, int digits, PZ69LCDPosition pz69LCDPosition)
        {
            var arrayPosition    = GetArrayPosition(pz69LCDPosition);
            var maxArrayPosition = GetArrayPosition(pz69LCDPosition) + 5;
            var i = 0;
            var digitsAsString = digits.ToString().PadLeft(5);

            //D = DARK
            //116 should become DD116!

            do
            {
                //5 digits can be displayed
                //12345 -> 12345
                //116   -> DD116
                //1     -> DDDD1

                byte b;
                b = digitsAsString[i].ToString().Equals(" ") ? (byte)0xFF : byte.Parse(digitsAsString[i].ToString());
                bytes[arrayPosition] = b;

                arrayPosition++;
                i++;
            } while (i < digitsAsString.Length && arrayPosition < maxArrayPosition + 1);
        }
 /// <summary>
 /// Expect a string of 5 chars that are going to be displayed as it.
 /// Can deal with multiple '.' chars.
 /// If size does not match 5, it will NOT replace previous characters in the array (no padding left or right).
 /// </summary>
 protected void SetPZ69DisplayBytesDefault(ref byte[] bytes, string digits, PZ69LCDPosition pz69LCDPosition)
 {
     try
     {
         _pZ69DisplayBytes.DefaultStringAsIs(ref bytes, digits, pz69LCDPosition);
     }
     catch (Exception ex)
     {
         logger.Error(ex, "SetPZ69DisplayBytesDefault()");
     }
 }
예제 #7
0
        public void DoubleJustifyLeft(ref byte[] bytes, double digits, PZ69LCDPosition pz69LCDPosition)
        {
            var arrayPosition    = GetArrayPosition(pz69LCDPosition);
            var maxArrayPosition = GetArrayPosition(pz69LCDPosition) + 4;

            // Debug.WriteLine("LCD position is " + pz69LCDPosition);
            // Debug.WriteLine("Array position = " + arrayPosition);
            // Debug.WriteLine("Max array position = " + (maxArrayPosition));
            var i = 0;
            var numberFormatInfoFullDisplay = new NumberFormatInfo()
            {
                NumberDecimalSeparator = ".",
                NumberDecimalDigits    = 4,
                NumberGroupSeparator   = string.Empty
            };

            var digitsAsString = digits.ToString("0.0000", numberFormatInfoFullDisplay);

            // 116 should become 116.00!
            do
            {
                // 5 digits can be displayed
                // 1.00000011241 -> 1.0000
                // 116.0434      -> 116.04
                // 1199330.12449 -> 11993
                if (digitsAsString[i] == '.')
                {
                    // skip to next position, this has already been dealt with
                    i++;
                }

                try
                {
                    var tmp = digitsAsString[i].ToString();
                    var b   = byte.Parse(tmp);
                    bytes[arrayPosition] = b;
                    // Debug.WriteLine("Current string char is " + tmp + " from i = " + i + ", writing byte " + b + " to array position " + arrayPosition);
                }
                catch (Exception ex)
                {
                    logger.Error(ex, $"SetPZ69DisplayBytesDefault() digitsAsString.Length = {digitsAsString.Length}");
                }

                if (digitsAsString.Length > i + 1 && digitsAsString[i + 1] == '.')
                {
                    // Add decimal marker
                    bytes[arrayPosition] = (byte)(bytes[arrayPosition] + 0xd0);
                    // Debug.WriteLine("Writing decimal marker to array position " + arrayPosition);
                }

                arrayPosition++;
                i++;
            }while (i < digitsAsString.Length && arrayPosition < maxArrayPosition + 1);
        }
예제 #8
0
        protected void SetPZ69DisplayBlank(ref byte[] bytes, PZ69LCDPosition pz69LCDPosition)
        {
            var arrayPosition = GetArrayPosition(pz69LCDPosition);
            var i             = 0;

            do
            {
                bytes[arrayPosition] = 0xFF;
                arrayPosition++;
                i++;
            } while (i < 5);
        }
예제 #9
0
        /// <summary>
        /// Sets the given position to blank without modifying the other positions in the array
        /// </summary>
        public void SetPositionBlank(ref byte[] bytes, PZ69LCDPosition pz69LCDPosition)
        {
            var arrayPosition = GetArrayPosition(pz69LCDPosition);
            var i             = 0;

            do
            {
                bytes[arrayPosition] = 0xFF;
                arrayPosition++;
                i++;
            }while (i < 5);
        }
        protected void SetPZ69DisplayBytesDefault(ref byte[] bytes, double digits, PZ69LCDPosition pz69LCDPosition)
        {
            var arrayPosition    = GetArrayPosition(pz69LCDPosition);
            var maxArrayPosition = GetArrayPosition(pz69LCDPosition) + 4;

            //Debug.WriteLine("LCD position is " + pz69LCDPosition);
            //Debug.WriteLine("Array position = " + arrayPosition);
            //Debug.WriteLine("Max array position = " + (maxArrayPosition));
            var i = 0;
            var digitsAsString = digits.ToString("0.0000", NumberFormatInfoFullDisplay);

            //116 should become 116.00!

            do
            {
                //5 digits can be displayed
                //1.00000011241 -> 1.0000
                //116.0434      -> 116.04
                //1199330.12449 -> 11993
                if (digitsAsString[i] == '.')
                {
                    //skip to next position, this has already been dealt with
                    i++;
                }

                try
                {
                    var tmp = digitsAsString[i].ToString();
                    var b   = byte.Parse(tmp);
                    bytes[arrayPosition] = b;
                    //Debug.WriteLine("Current string char is " + tmp + " from i = " + i + ", writing byte " + b + " to array position " + arrayPosition);
                }
                catch (Exception e)
                {
                    Common.LogError(38410, e, "SetPZ69DisplayBytesDefault() digitsAsString.Length = " + digitsAsString.Length);
                }

                if (digitsAsString.Length > i + 1 && digitsAsString[i + 1] == '.')
                {
                    //Add decimal marker
                    bytes[arrayPosition] = (byte)(bytes[arrayPosition] + 0xd0);
                    //Debug.WriteLine("Writing decimal marker to array position " + arrayPosition);
                }

                arrayPosition++;
                i++;
            } while (i < digitsAsString.Length && arrayPosition < maxArrayPosition + 1);
        }
예제 #11
0
        internal void ImportSettings(string settings)
        {
            if (string.IsNullOrEmpty(settings))
            {
                throw new ArgumentException("Import string empty. (DCSBIOSBindingPZ69)");
            }
            if (settings.StartsWith("RadioPanelDCSBIOSLCD{") && settings.Contains("DCSBiosOutput{"))
            {
                //RadioPanelDCSBIOSLCD{COM1}\o/{LowerLCD}\o/DCSBiosOutput{ANT_EGIHQTOD|Equals|0}
                var parameters = settings.Split(new[] { Constants.SEPARATOR_SYMBOL }, StringSplitOptions.RemoveEmptyEntries);

                //[0]
                //RadioPanelDCSBIOSLCD{COM1}
                var param0 = parameters[0].Replace("RadioPanelDCSBIOSLCD{", "").Replace("}", "");
                _pz69DialPosition = (PZ69DialPosition)Enum.Parse(typeof(PZ69DialPosition), param0);

                //[1]
                //{LowerLCD}
                var param1 = parameters[1].Replace("{", "").Replace("}", "").Trim();
                _pz69LCDPosition = (PZ69LCDPosition)Enum.Parse(typeof(PZ69LCDPosition), param1);

                //[2]
                //DCSBiosOutput{ANT_EGIHQTOD|Equals|0}
                _dcsbiosOutput = new DCSBIOSOutput();
                _dcsbiosOutput.ImportString(parameters[2]);
            }
            if (settings.StartsWith("RadioPanelDCSBIOSLCD{") && settings.Contains("DCSBiosOutputFormula{"))
            {
                //RadioPanelDCSBIOSLCD{COM1}\o/{UpperLCD}\o/DCSBiosOutputFormula{ANT_EGIHQTOD+10}
                var parameters = settings.Split(new[] { Constants.SEPARATOR_SYMBOL }, StringSplitOptions.RemoveEmptyEntries);

                //[0]
                //MultiPanelDCSBIOSFormulaLCD{COM1}
                var param0 = parameters[0].Replace("RadioPanelDCSBIOSLCD{", "").Replace("}", "").Trim();
                _pz69DialPosition = (PZ69DialPosition)Enum.Parse(typeof(PZ69DialPosition), param0);

                //[1]
                //{UpperLCD}
                var param1 = parameters[1].Replace("{", "").Replace("}", "").Trim();
                _pz69LCDPosition = (PZ69LCDPosition)Enum.Parse(typeof(PZ69LCDPosition), param1);

                //[2]
                //DCSBiosOutputFormula{ANT_EGIHQTOD+10}
                _dcsbiosOutputFormula = new DCSBIOSOutputFormula();
                _dcsbiosOutputFormula.ImportString(parameters[2]);
            }
        }
예제 #12
0
        protected void SetPZ69DisplayBytesDefault(ref byte[] bytes, double digits, PZ69LCDPosition pz69LCDPosition)
        {
            var arrayPosition  = GetArrayPosition(pz69LCDPosition);
            var i              = 0;
            var digitsAsString = digits.ToString("0.0000", NumberFormatInfoFullDisplay);

            //116 should become 116.00!
            //Common.DebugP("Arrayposition : " + arrayPosition + " is " + frequencyAsString);
            do
            {
                //5 digits can be displayed
                //1.00000011241 -> 1.0000
                //116.0434      -> 116.04
                //1199330.12449 -> 11993
                if (digitsAsString[i] == '.')
                {
                    //skip to next position, this has already been dealt with
                    i++;
                }

                byte b = 0;
                try
                {
                    b = Byte.Parse(digitsAsString[i].ToString());
                    bytes[arrayPosition] = b;
                }
                catch (Exception e)
                {
                    Common.LogError(38410, e, "SetPZ69DisplayBytesDefault()");
                }
                //Common.DebugP("Byte [" + arrayPosition + "] has been set to " + b);
                if (digitsAsString.Length > i + 1 && digitsAsString[i + 1] == '.')
                {
                    //Common.DebugP("We are at Byte[" + arrayPosition + "] (" + frequencyAsString[i] + ") and next comes the decimal marker");
                    //Add decimal marker
                    //Common.DebugP("Byte is before addition " + bytes[arrayPosition]);
                    bytes[arrayPosition] = (byte)(bytes[arrayPosition] + 0xd0);
                    //Common.DebugP("Byte is after addition " + bytes[arrayPosition]);
                }

                arrayPosition++;
                i++;
            } while (i < digitsAsString.Length && i < 6);
        }
예제 #13
0
        public void DeleteDCSBIOSLcdBinding(PZ69LCDPosition pz69LCDPosition)
        {
            var pz69DialPosition = _pz69UpperDialPosition;

            if (pz69LCDPosition == PZ69LCDPosition.LOWER_STBY_RIGHT || pz69LCDPosition == PZ69LCDPosition.LOWER_ACTIVE_LEFT)
            {
                pz69DialPosition = _pz69LowerDialPosition;
            }
            //Removes config
            foreach (var dcsBiosBindingLCD in _dcsBiosLcdBindings)
            {
                if (dcsBiosBindingLCD.DialPosition == pz69DialPosition && dcsBiosBindingLCD.PZ69LcdPosition == pz69LCDPosition)
                {
                    dcsBiosBindingLCD.DCSBIOSOutputObject = null;
                    break;
                }
            }
            IsDirtyMethod();
        }
        protected void SetPZ69DisplayBytesDefault(ref byte[] bytes, string digits, PZ69LCDPosition pz69LCDPosition)
        {
            var arrayPosition    = GetArrayPosition(pz69LCDPosition);
            var maxArrayPosition = GetArrayPosition(pz69LCDPosition) + 4;
            var i = 0;

            do
            {
                if (digits[i] == '.')
                {
                    //skip to next position, this has already been dealt with
                    i++;
                }

                try
                {
                    if (digits[i] == ' ')
                    {
                        bytes[arrayPosition] = 0xff;
                    }
                    else
                    {
                        var b = byte.Parse(digits[i].ToString());
                        bytes[arrayPosition] = b;
                    }
                }
                catch (Exception e)
                {
                    Common.LogError(38410, e, "SetPZ69DisplayBytesDefault()");
                }
                if (digits.Length > i + 1 && digits[i + 1] == '.')
                {
                    //Add decimal marker
                    bytes[arrayPosition] = (byte)(bytes[arrayPosition] + 0xd0);
                }

                arrayPosition++;
                i++;
            } while (i < digits.Length && arrayPosition < maxArrayPosition + 1);
        }
예제 #15
0
        /// <summary>
        /// Expect a string of 5 chars that are going to be displayed as it.
        /// Can deal with multiple '.' chars.
        /// If size does not match 5, it will NOT replace previous characters in the array (no padding left or right).
        /// </summary>
        public void DefaultStringAsIs(ref byte[] bytes, string digits, PZ69LCDPosition pz69LCDPosition)
        {
            var arrayPosition    = GetArrayPosition(pz69LCDPosition);
            var maxArrayPosition = GetArrayPosition(pz69LCDPosition) + 4;
            var i = 0;

            digits = digits.PadLeft(5); //Makes text right justified in the screen

            do
            {
                if (digits[i] == '.')
                {
                    // skip to next position, this has already been dealt with
                    i++;
                }

                if (digits[i] == ' ')
                {
                    bytes[arrayPosition] = 0xff;
                }
                else
                {
                    var b = byte.Parse(digits[i].ToString());
                    bytes[arrayPosition] = b;
                }

                if (digits.Length > i + 1 && digits[i + 1] == '.')
                {
                    // Add decimal marker
                    bytes[arrayPosition] = (byte)(bytes[arrayPosition] + 0xd0);
                }

                arrayPosition++;
                i++;
            }while (i < digits.Length && arrayPosition < maxArrayPosition + 1);
        }
예제 #16
0
        protected void SetPZ69DisplayBytes(ref byte[] bytes, double digits, int decimals, PZ69LCDPosition pz69LCDPosition)
        {
            var arrayPosition  = GetArrayPosition(pz69LCDPosition);
            var i              = 0;
            var formatString   = "0.".PadRight(decimals + 2, '0');
            var digitsAsString = digits.ToString(formatString, NumberFormatInfoEmpty).PadLeft(6);

            do
            {
                if (digitsAsString[i] == '.')
                {
                    //skip to next position, this has already been dealt with
                    i++;
                }
                byte b;
                if (digitsAsString[i].ToString().Equals(" "))
                {
                    b = 0xFF;
                }
                else
                {
                    b = Byte.Parse(digitsAsString[i].ToString());
                }
                bytes[arrayPosition] = b;
                if (digitsAsString.Length > i + 1 && digitsAsString[i + 1] == '.')
                {
                    bytes[arrayPosition] = (byte)(bytes[arrayPosition] + 0xd0);
                }
                arrayPosition++;
                i++;
            } while (i < digitsAsString.Length && i < 6);
        }
        /*
         *  1 byte (header byte 0x0) [0]
         *  5 bytes upper left LCD   [1 - 5]
         *  5 bytes upper right LCD  [6 - 10]
         *  5 bytes lower left LCD   [11- 15]
         *  5 bytes lower right LCD  [16- 20]
         *
         *  0x01 - 0x09 displays the figure 1-9
         *  0xD1 - 0xD9 displays the figure 1.-9. (figure followed by dot)
         *  0xFF -> blank, nothing is shown in that spot.
         *
         *  var bytes = new byte[21];
         *  bytes[0] = 0x0;
         *  bytes = SetPZ69FrequencyBytes(bytes, _lcdFrequencyActiveUpper, 1);
         *  bytes = SetPZ69FrequencyBytes(bytes, _lcdFrequencyStandbyUpper, 6);
         *  bytes = SetPZ69FrequencyBytes(bytes, _lcdFrequencyActiveLower, 11);
         *  bytes = SetPZ69FrequencyBytes(bytes, _lcdFrequencyStandbyLower, 16);
         */

        /// <summary>
        /// Sets the given position to blank without modifying the other positions in the array
        /// </summary>
        protected void SetPZ69DisplayBlank(ref byte[] bytes, PZ69LCDPosition pz69LCDPosition)
        {
            _pZ69DisplayBytes.SetPositionBlank(ref bytes, pz69LCDPosition);
        }
 protected void SetPZ69DisplayBytesDefault(ref byte[] bytes, double digits, PZ69LCDPosition pz69LCDPosition)
 {
     _pZ69DisplayBytes.DoubleJustifyLeft(ref bytes, digits, pz69LCDPosition);
 }
 protected void SetPZ69DisplayBytes(ref byte[] bytes, double digits, int decimals, PZ69LCDPosition pz69LCDPosition)
 {
     _pZ69DisplayBytes.DoubleWithSpecifiedDecimalsPlaces(ref bytes, digits, decimals, pz69LCDPosition);
 }
 /// <summary>
 /// Right justify, pad left with blanks.
 /// </summary>
 protected void SetPZ69DisplayBytesUnsignedInteger(ref byte[] bytes, uint digits, PZ69LCDPosition pz69LCDPosition)
 {
     _pZ69DisplayBytes.UnsignedInteger(ref bytes, digits, pz69LCDPosition);
 }
예제 #21
0
        public void DoubleWithSpecifiedDecimalsPlaces(ref byte[] bytes, double digits, int decimals, PZ69LCDPosition pz69LCDPosition)
        {
            var arrayPosition    = GetArrayPosition(pz69LCDPosition);
            var maxArrayPosition = GetArrayPosition(pz69LCDPosition) + 4;
            var i            = 0;
            var formatString = "0.".PadRight(decimals + 2, '0');

            var numberFormatInfoEmpty = new NumberFormatInfo()
            {
                NumberDecimalSeparator = ".",
                NumberGroupSeparator   = string.Empty
            };

            var digitsAsString = digits.ToString(formatString, numberFormatInfoEmpty).PadLeft(6);

            do
            {
                if (digitsAsString[i] == '.')
                {
                    // skip to next position, this has already been dealt with
                    i++;
                }

                byte b;
                b = digitsAsString[i].ToString().Equals(" ") ? (byte)0xFF : byte.Parse(digitsAsString[i].ToString());
                bytes[arrayPosition] = b;
                if (digitsAsString.Length > i + 1 && digitsAsString[i + 1] == '.')
                {
                    bytes[arrayPosition] = (byte)(bytes[arrayPosition] + 0xd0);
                }

                arrayPosition++;
                i++;
            }while (i < digitsAsString.Length && arrayPosition < maxArrayPosition + 1);
        }
        protected void SetPZ69DisplayBytesUnsignedInteger(ref byte[] bytes, uint digits, PZ69LCDPosition pz69LCDPosition)
        {
            var arrayPosition    = GetArrayPosition(pz69LCDPosition);
            var maxArrayPosition = GetArrayPosition(pz69LCDPosition) + 4;
            var i = 0;
            var digitsAsString = digits.ToString().PadLeft(5);


            //Debug.WriteLine("LCD position is " + pz69LCDPosition);
            //Debug.WriteLine("Array position = " + arrayPosition);
            //Debug.WriteLine("Max array position = " + (maxArrayPosition));
            //Debug.WriteLine("digitsAsString = >" + digitsAsString + "< length=" + digitsAsString.Length);
            //D = DARK
            //116 should become DD116!

            do
            {
                //5 digits can be displayed
                //12345 -> 12345
                //116   -> DD116
                //1     -> DDDD1

                byte b;
                b = digitsAsString[i].ToString().Equals(" ") ? (byte)0xFF : byte.Parse(digitsAsString[i].ToString());
                bytes[arrayPosition] = b;

                arrayPosition++;
                i++;
            } while (i < digitsAsString.Length && arrayPosition < maxArrayPosition + 1);
        }
        protected void SetPZ69DisplayBytesCustom1(ref byte[] bytes, byte[] bytesToBeInjected, PZ69LCDPosition pz69LCDPosition)
        {
            var arrayPosition = GetArrayPosition(pz69LCDPosition);
            var i             = 0;

            do
            {
                //5 digits can be displayed
                //12345 -> 12345
                //116   -> DD116
                //1     -> DDDD1

                bytes[arrayPosition] = bytesToBeInjected[i];

                arrayPosition++;
                i++;
            } while (i < bytesToBeInjected.Length && i < 5);
        }
예제 #24
0
        protected void SetPZ69DisplayBytesCustom1(ref byte[] bytes, byte[] bytesToBeInjected, PZ69LCDPosition pz69LCDPosition)
        {
            var arrayPosition = GetArrayPosition(pz69LCDPosition);
            var i             = 0;

            //Common.DebugP("Arrayposition : " + arrayPosition + " is " + frequencyAsString);
            do
            {
                //5 digits can be displayed
                //12345 -> 12345
                //116   -> DD116
                //1     -> DDDD1

                bytes[arrayPosition] = bytesToBeInjected[i];
                //Common.DebugP("Byte [" + arrayPosition + "] has been set to " + b);
                arrayPosition++;
                i++;
            } while (i < bytesToBeInjected.Length && i < 5);
        }
        protected void SetPZ69DisplayBytesString(ref byte[] bytes, string digitString, PZ69LCDPosition pz69LCDPosition)
        {
            var arrayPosition    = GetArrayPosition(pz69LCDPosition);
            var maxArrayPosition = GetArrayPosition(pz69LCDPosition) + 4;
            var i      = 0;
            var digits = "";

            if (digitString.Length > 5)
            {
                if (digitString.Contains("."))
                {
                    digits = digitString.Substring(0, 6);
                }
                else
                {
                    digits = digitString.Substring(0, 5);
                }
            }
            else if (digitString.Length < 5)
            {
                if (digitString.Contains("."))
                {
                    digits = digitString.PadLeft(6, ' ');
                }
                else
                {
                    digits = digitString.PadLeft(5, ' ');
                }
            }
            else if (digitString.Length == 5)
            {
                if (digitString.Contains("."))
                {
                    digits = digitString.PadLeft(1, ' ');
                }
                else
                {
                    digits = digitString;
                }
            }

            do
            {
                if (digits[i] == '.')
                {
                    //skip to next position, this has already been dealt with
                    i++;
                }

                try
                {
                    if (digits[i] == ' ')
                    {
                        bytes[arrayPosition] = 0xff;
                    }
                    else
                    {
                        var b = byte.Parse(digits[i].ToString());
                        bytes[arrayPosition] = b;
                    }
                }
                catch (Exception e)
                {
                    Common.LogError(38410, e, "SetPZ69DisplayBytesDefault()");
                }
                if (digits.Length > i + 1 && digits[i + 1] == '.')
                {
                    //Add decimal marker
                    bytes[arrayPosition] = (byte)(bytes[arrayPosition] + 0xd0);
                }

                arrayPosition++;
                i++;
            } while (i < digits.Length && arrayPosition < maxArrayPosition + 1);
        }