public void Setup()
        {
            //Instance Fields Setup
            BooleanField = null;
            ByteField = null;
            SByteField = null;
            IntField = null;
            LongField = null;
            Int16Field = null;
            UInt16Field = null;
            Int32Field = null;
            UInt32Field = null;
            Int64Field = null;
            UInt64Field = null;
            CharField = null;
            DoubleField = null;
            FloatField = null;

            //Static Fields Setup
            BooleanFieldStatic = null;
            ByteFieldStatic = null;
            SByteFieldStatic = null;
            IntFieldStatic = null;
            LongFieldStatic = null;
            Int16FieldStatic = null;
            UInt16FieldStatic = null;
            Int32FieldStatic = null;
            UInt32FieldStatic = null;
            Int64FieldStatic = null;
            UInt64FieldStatic = null;
            CharFieldStatic = null;
            DoubleFieldStatic = null;
            FloatFieldStatic = null;
        }
Ejemplo n.º 2
0
 public void Init(ParsingContext context, ParseTreeNode parseNode)
 {
     _Shards = null;
     if (parseNode.ChildNodes != null && parseNode.ChildNodes.Count != 0)
     {
         _Shards = UInt16.Parse(parseNode.ChildNodes[1].Token.ValueString);
     }
 }
Ejemplo n.º 3
0
 private void GetContent(CompilerContext context, ParseTreeNode parseNode)
 {
     _Shards = null;
     if (parseNode.HasChildNodes())
     {
         _Shards = UInt16.Parse(parseNode.ChildNodes[1].Token.ValueString);
     }
 }
Ejemplo n.º 4
0
 public Rider(byte[] idArray)
 {
     uuid = idArray;
     rpm = hr = power = kcal = clock = gear = null;
     rssi = null;
     updates = 0;
     timeFromStart = Stopwatch.StartNew();
     timeFromUpdate = Stopwatch.StartNew();
 }
Ejemplo n.º 5
0
 public Rider(UInt16 id)
 {
     this.id = id;
     rpm = hr = power = kcal = clock = gear = null;
     rssi = null;
     updates = 0;
     timeFromStart = Stopwatch.StartNew();
     timeFromUpdate = Stopwatch.StartNew();
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Splits a given strings into elements by a given sperator.
 /// </summary>
 /// <param name="SourcePipe">An enumeration of strings.</param>
 /// <param name="IgnoreLines">A regular expression indicating which input strings should be ignored. Default: All lines starting with a '#'.</param>
 /// <param name="Seperators">An array of string used to split the input strings.</param>
 /// <param name="StringSplitOptions">Split options, e.g. remove empty entries.</param>
 /// <param name="ExpectedNumberOfColumns">If the CSV file had a schema, a specific number of columns can be expected. If instead it is a list of values no such value can be expected.</param>
 /// <param name="FailOnWrongNumberOfColumns">What to do when the current and expected number of columns do not match.</param>
 /// <param name="TrimColumns">Remove leading and trailing whitespaces.</param>
 /// <returns>An enumeration of string arrays.</returns>
 public static IEndPipe <String[]> ToCSV(this IEndPipe <String> SourcePipe,
                                         Regex IgnoreLines = null,
                                         String[]            Seperators        = null,
                                         StringSplitOptions StringSplitOptions = StringSplitOptions.None,
                                         UInt16?ExpectedNumberOfColumns        = null,
                                         Boolean FailOnWrongNumberOfColumns    = false,
                                         Boolean TrimColumns = true)
 {
     return(new CSVReaderPipe(SourcePipe, IgnoreLines, Seperators, StringSplitOptions, ExpectedNumberOfColumns, FailOnWrongNumberOfColumns, TrimColumns));
 }
Ejemplo n.º 7
0
 protected virtual void Init(DateTime time, double?lat, double?lon, int?alt, UInt16?speed, UInt16?heading, byte?sats)
 {
     this._time    = time;
     this._lat     = lat;
     this._lon     = lon;
     this._alt     = alt;
     this._speed   = speed;
     this._heading = heading;
     this._sats    = sats;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Splits a given strings into elements by a given sperator.
 /// </summary>
 /// <param name="IEnumerator">An enumerator of strings.</param>
 /// <param name="IgnoreLines">A regular expression indicating which input strings should be ignored. Default: All lines starting with a '#'.</param>
 /// <param name="Seperators">An array of string used to split the input strings.</param>
 /// <param name="StringSplitOptions">Split options, e.g. remove empty entries.</param>
 /// <param name="ExpectedNumberOfColumns">If the CSV file had a schema, a specific number of columns can be expected. If instead it is a list of values no such value can be expected.</param>
 /// <param name="FailOnWrongNumberOfColumns">What to do when the current and expected number of columns do not match.</param>
 /// <param name="TrimColumns">Remove leading and trailing whitespaces.</param>
 /// <returns>An enumeration of string arrays.</returns>
 public static IEnumerable <String[]> CSVPipe(this IEnumerator <String> IEnumerator,
                                              Regex IgnoreLines = null,
                                              String[]            Seperators        = null,
                                              StringSplitOptions StringSplitOptions = StringSplitOptions.None,
                                              UInt16?ExpectedNumberOfColumns        = null,
                                              Boolean FailOnWrongNumberOfColumns    = false,
                                              Boolean TrimColumns = true)
 {
     return(new CSVReaderPipe(IgnoreLines, Seperators, StringSplitOptions, ExpectedNumberOfColumns, FailOnWrongNumberOfColumns, TrimColumns, null, IEnumerator));
 }
Ejemplo n.º 9
0
        public static byte[] CreateFakePatch(byte[] patch, UInt16?raw_glucose = null, UInt16?raw_temp = null)
        {
            //glucoseByte2,glucoseByte1, flag1, tempByte2, tempByte1, flag2
            var value = new byte[] { 0xff, 0x3f, 0xc8, 0xfc, 0xd8, 0x00 };

            if (raw_glucose != null)
            {
                value[0] = Convert.ToByte(raw_glucose & 0xFF);
                value[1] = Convert.ToByte(raw_glucose >> 8);
            }
            if (raw_temp != null)
            {
                value[3] = Convert.ToByte(raw_temp & 0xFF);
                value[4] = Convert.ToByte(raw_temp >> 8);
            }

            var modifiedPatch = new List <byte[]>();

            //changes sensorstatusbyte to ready
            patch[4] = 0x03;

            //24 bytes of header
            modifiedPatch.Add(new ArraySegment <byte>(patch, 0, 24).ToArray());

            // + 4 bytes of body(crc, trend and history index
            // this could be from the original patch, but wouldn't work for sensors
            // warming up or pre-initialixing,
            // so fill it with trend and history from a known good patch
            // no matter what we will fix the crcs with bytesWithCorrectCRC()
            // anyway

            //modifiedPatch.Add(new ArraySegment<byte>(patch, 24, 4).ToArray());
            modifiedPatch.Add(new ArraySegment <byte>(LibreUtils.TestPatchAlwaysReturning63, 24, 4).ToArray());



            //fake body values
            for (var i = 0; i < 48; i++)
            {
                modifiedPatch.Add(value);
            }

            //rest of data, minute counter and two zeroes
            //modifiedPatch.Add(new ArraySegment<byte>(patch, 316, 4).ToArray());
            modifiedPatch.Add(new ArraySegment <byte>(LibreUtils.TestPatchAlwaysReturning63, 316, 4).ToArray());

            //footer
            modifiedPatch.Add(new ArraySegment <byte>(patch, 320, 24).ToArray());

            var flattened = modifiedPatch.SelectMany(x => x).ToArray();



            return(LibreUtils.bytesWithCorrectCRC(flattened));
        }
Ejemplo n.º 10
0
 public static UInt16 GetCheckNullUint16Value(UInt16?value, UInt16 defaultvalue = 0xFFFF)
 {
     if (value == null)
     {
         return(defaultvalue);
     }
     else
     {
         return((UInt16)value);
     }
 }
Ejemplo n.º 11
0
 public void MinTest_NullableUInt16_WithDefault()
 {
     for (int i = 0; i < 100; i++)
     {
         var    a     = (UInt16)listAUInt16[i];
         UInt16?nullA = a;
         Assert.AreEqual(Math.Min(a, (UInt16)0), Numbers.Min(nullA, null, (UInt16)0));
         Assert.AreEqual(Math.Min(a, (UInt16)0), Numbers.Min(null, nullA, (UInt16)0));
         Assert.AreEqual(Math.Min(nullA.Value, (UInt16)0), Numbers.Min(nullA, null, (UInt16)0));
     }
 }
Ejemplo n.º 12
0
 public void MinTest_NullableUInt16_WithNull()
 {
     for (int i = 0; i < 100; i++)
     {
         var    a     = (UInt16)listAUInt16[i];
         UInt16?nullA = a;
         Assert.AreEqual(Math.Min(a, UInt16.MaxValue), Numbers.Min(nullA, null));
         Assert.AreEqual(Math.Min(a, UInt16.MaxValue), Numbers.Min(null, nullA));
         Assert.AreEqual(Math.Min(nullA.Value, UInt16.MaxValue), Numbers.Min(nullA, null));
     }
 }
Ejemplo n.º 13
0
        private CommandInfo GetCommandInfo(CommandType command, String ipAddress, UInt16?port, String script, String settings)
        {
            CommandInfo info = new CommandInfo();

            info.Command      = command;
            info.IpAddress    = ipAddress;
            info.Port         = port;
            info.ScriptFile   = script;
            info.SettingsFile = settings;
            return(info);
        }
Ejemplo n.º 14
0
 /// <summary>
 /// Emits a nullable System.UInt16 to the specified string builder.
 /// </summary>
 /// <param name="builder">The string builder to append the nullable System.UInt16 to.</param>
 /// <param name="value">The nullable System.UInt16 value to emit.</param>
 /// <param name="context">The emitter context.</param>
 internal static void EmitNullableUInt16(StringBuilder builder, UInt16?value, EmitterContext context)
 {
     if (value == null)
     {
         builder.Append("null");
     }
     else
     {
         EmitUInt16(builder, value.Value, context);
     }
 }
Ejemplo n.º 15
0
 private void            _setUInt16(OptionalTags tag, UInt16?value)
 {
     if (value.HasValue)
     {
         this[tag].ValueUInt16 = value.Value;
     }
     else
     {
         Remove(tag);
     }
 }
Ejemplo n.º 16
0
        public static UInt16 GetUInt16(this XmlElement self, string name)
        {
            UInt16?value = FindUInt16(self, name);

            if (value == null)
            {
                throw Exceptions.CreateException("Аттрибут '{0}' не найден.", name);
            }

            return(value.Value);
        }
Ejemplo n.º 17
0
        public virtual bool ReadNullableUInt16(out UInt16?result)
        {
            if (!this.Read())
            {
                result = null;
                return(false);
            }

            result = this.LastReadData.IsNil ? default(UInt16? ) : this.LastReadData.AsUInt16();
            return(true);
        }
Ejemplo n.º 18
0
        //public static UInt16 ReadUInt16(System.IO.BinaryReader br)
        //{
        //    return (UInt16)ReadVarint32(br);
        //}
        #endregion UInt16

        #region UInt16?
        public static void Write(Stream stream, UInt16?value)
        {
            if (value == null)
            {
                Write(stream, (uint)0);
            }
            else
            {
                Write(stream, ((uint)value.Value) + 1);
            }
        }
Ejemplo n.º 19
0
 public void MaxTest_NullableUInt16_WithDefault()
 {
     for (int i = 0; i < 100; i++)
     {
         var    a     = (UInt16)listAUInt16[i];
         UInt16?nullA = a;
         Assert.AreEqual(Math.Max(a, (UInt16)0), Numbers.Max(nullA, null, (UInt16)0), $"#[{i}] a:{nullA} b:{null} Max:{Numbers.Max(nullA, null,(UInt16)0)}");
         Assert.AreEqual(Math.Max(a, (UInt16)0), Numbers.Max(null, nullA, (UInt16)0), $"#[{i}] a:{nullA} b:{null} Max:{Numbers.Max(null, nullA,(UInt16)0)}");
         Assert.AreEqual(Math.Max(nullA.Value, (UInt16)0), Numbers.Max(nullA, null, (UInt16)0), $"#[{i}] a:{nullA} b:{null} Max:{Numbers.Max(nullA, null,(UInt16)0)}");
     }
 }
Ejemplo n.º 20
0
        public void SetServiceStateDoIt(Guid service, bool state)
        {
            UInt16?classId16 = BluetoothService.GetAsClassId16(service);

            if (!classId16.HasValue)
            {
                throw new ArgumentException("BlueSoleil only supports standard Bluetooth UUID16 services.");
            }
            //
            // MSDN says the posible errors are:
            //   ERROR_INVALID_PARAMETER The dwServiceFlags are invalid.
            //   ERROR_SERVICE_DOES_NOT_EXIST The GUID specified in pGuidService is not supported.
            // Numerically:
            //   #define ERROR_FILE_NOT_FOUND             2L
            //   #define ERROR_SERVICE_DOES_NOT_EXIST     1060L
            //   #define ERROR_NOT_FOUND                  1168L
            //
            // Seen:
            // • 0x00000424 = 1060 ----> ERROR_SERVICE_DOES_NOT_EXIST
            // When service not present, or device not present.
            //
            // • 0x80070002        -/\-> ERROR_FILE_NOT_FOUND
            // PANU on Broadcom peer.  "No driver for service"?
            //
            // • 0x00000490 = 1168 ----> ERROR_NOT_FOUND
            // Setting 'False' on a service not set previously registered.
            //--
            BtSdkError ret;

            if (state)
            {
                UInt32 hConn;
                ret = _factory.Api.Btsdk_ConnectEx(_hDev, classId16.Value, 0, out hConn);
                if (ret != BtSdkError.OK)
                {
                    throw new Win32Exception((int)Win32Error.ERROR_SERVICE_DOES_NOT_EXIST, "Failed to enable the service.");
                }
            }
            else
            {
                var hConnList = FindConnection(_hDev, classId16.Value);
                if (hConnList == null || hConnList.Count == 0)
                {
                    throw new Win32Exception((int)Win32Error.ERROR_NOT_FOUND, "No matching enabled service found.");
                }
                // TO-DO SetServiceState, before disabling, ensure its not BluetoothClient's connection.
                Debug.Assert(hConnList.Count == 1, "SetServiceState: What to do if more than one match?");
                ret = _factory.Api.Btsdk_Disconnect(hConnList[0]);
                if (ret != BtSdkError.OK)
                {
                    throw new Win32Exception((int)Win32Error.ERROR_SERVICE_DOES_NOT_EXIST, "Failed to disabled the service.");
                }
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Generate a new HTTP hostname based on the given name and port.
        /// </summary>
        private HTTPHostname(String Name,
                             UInt16?Port)
        {
            if (Name == null)
            {
                Name = "*";
            }

            this.Name = (Name.Trim().IsNullOrEmpty() ? "*" : Name.Trim());
            this.Port = Port;
        }
Ejemplo n.º 22
0
        public static UInt16?ToUInt16(Object inValue)
        {
            UInt16?ReturnValue = null;
            UInt16 x           = 0;

            if (UInt16.TryParse(Cast.ToString(inValue), out x) == true)
            {
                ReturnValue = x;
            }
            return(ReturnValue);
        }
        public void Clear()
        {
            ID = 0;

            lastReceivedID = 0;

            firstNewID = null;

            events.Clear();
            eventLastSent.Clear();
        }
Ejemplo n.º 24
0
 public void WriteValue(UInt16?value)
 {
     if (value == null)
     {
         WriteNull();
     }
     else
     {
         WriteValue(value.Value);
     }
 }
Ejemplo n.º 25
0
 public static string DebugString(this UInt16?v)
 {
     if (v == null)
     {
         return("null".PadRight(columnWidth * 2) + typeof(UInt16?).Name);
     }
     else
     {
         return(((UInt16)v).ToString().PadLeft(columnWidth) + " " + ((UInt16)v).ToString("X4").PadRight(columnWidth)
                + v.GetType().Name);
     }
 }
Ejemplo n.º 26
0
        private static List <byte> GetPath(UInt16 Class, UInt32 Instance, UInt16?Attribute = null) // EnIPBase.cs:GetPath is wrong
        {                                                                                          // see Apendix C: Data Management:
            List <byte> lb = new List <byte>();

            lb.AddRange(ItemPath(CipLogicalType.ClassID, Class));
            lb.AddRange(ItemPath(CipLogicalType.InstanceID, Instance)); // instance = 0 -> class level
            if (Attribute != null)
            {
                lb.AddRange(ItemPath(CipLogicalType.AttributeId, Attribute.Value));
            }
            return(lb);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Parses the specified value using invariant culture (also handles hex prefix "0x").
        /// <locDE><para />Parst den angegebenen Wert mit fixierter englischer Kultureinstellung (berücksichtigt auch HEX-Präfix "0x").</locDE>
        /// </summary>
        /// <param name="value">The value.<locDE><para />Der Wert.</locDE></param>
        /// <param name="defaultValue">The default value if <paramref name="value"/> is empty or invalid. Null means throw exception for invalid value.
        /// <locDE><para />Der Standardwert, falls <paramref name="value"/> leer oder ungültig ist. Null heißt, dass bei ungültigem Wert eine Exception geworfen werden soll.</locDE></param>
        /// <returns>UInt16 value.<locDE><para />UInt16 Wert.</locDE></returns>
        public static UInt16 ParseInvariantCulture(object value, UInt16?defaultValue = null)
        {
            if (value is byte || value is sbyte || value is Int16 || value is Int32 || value is Int64 ||
                value is UInt16 || value is UInt32 || value is UInt64 || value is double || value is float || value is decimal)
            {
                return((UInt16)value);
            }

            string strDefault = defaultValue.ToStringOrDefault();

            return(Parse(value.ToStringOrDefault(strDefault), defaultValue, CultureHelper.InvariantCulture));
        }
Ejemplo n.º 28
0
        public Property(XmlNode node)
        {
            Name = node.Name;

            var typeStr = GetValue(node, "Type");

            Type = BaseType.AllTypes.Find(e => e.TypeName() == typeStr);
            if (Type == null)
            {
                Type = node.SelectSingleNode("Type").GetIType();
                if (Type == null)
                {
                    throw new ArgumentException(string.Format("Unknown type '{0}'", typeStr));
                }
            }

            Default = GetValue(node, "Default");

            var utypeStr = GetValue(node, "Utype");

            if (!string.IsNullOrEmpty(utypeStr))
            {
                Utype = UInt16.Parse(utypeStr);
            }

            var flagsStr = GetValue(node, "Flags");

            if (!string.IsNullOrEmpty(flagsStr))
            {
                Flags = (Flags)Enum.Parse(typeof(Flags), flagsStr);
            }

            var persistentStr = GetValue(node, "Persistent");

            if (!string.IsNullOrEmpty(persistentStr))
            {
                Persistent = bool.Parse(persistentStr);
            }

            var databaseLengthStr = GetValue(node, "DatabaseLength");

            if (!string.IsNullOrEmpty(databaseLengthStr))
            {
                DatabaseLength = uint.Parse(databaseLengthStr);
            }

            var indexTypeStr = GetValue(node, "Index");

            if (!string.IsNullOrEmpty(indexTypeStr))
            {
                IndexType = (IndexType)Enum.Parse(typeof(IndexType), indexTypeStr);
            }
        }
Ejemplo n.º 29
0
        public CharacterRun(BinaryReader reader)
        {
            try
            {
                this.Mask = (CharacterMask)reader.ReadUInt32();

                if (this.StyleFlagsFieldPresent)
                {
                    this.Style = (StyleMask)reader.ReadUInt16();
                }

                if (this.TypefacePresent)
                {
                    this.TypefaceIdx = reader.ReadUInt16();
                }

                if (this.FEOldTypefacePresent)
                {
                    this.FEOldTypefaceIdx = reader.ReadUInt16();
                }

                if (this.ANSITypefacePresent)
                {
                    this.ANSITypefaceIdx = reader.ReadUInt16();
                }

                if (this.SymbolTypefacePresent)
                {
                    this.SymbolTypefaceIdx = reader.ReadUInt16();
                }

                if (this.SizePresent)
                {
                    this.Size = reader.ReadUInt16();
                }

                if (this.ColorPresent)
                {
                    this.Color = new GrColorAtom(reader);
                }

                if (this.PositionPresent)
                {
                    this.Position = reader.ReadUInt16();
                }
            }
            catch (EndOfStreamException e)
            {
                string s = e.ToString();
                //ignore
            }
        }
Ejemplo n.º 30
0
        void numUpDownWaitTime_TextChanged(object sender, EventArgs e)
        {
            // Get value from control
            UInt16?waitTimeValue = ConvertStrToUInt16(numUpDownWaitTime.Text);

            // Update error provider
            bool noErrors = UpdateWaitTimeErrProvider(waitTimeValue);

            if (noErrors)
            {
                m_parameters.WaitTime = (byte)(waitTimeValue.Value / WAIT_TIME_MULTIPLIER);
            }
        }
Ejemplo n.º 31
0
 public void MaxTest_NullableUInt16()
 {
     for (int i = 0; i < 100; i++)
     {
         var    a     = (UInt16)listAUInt16[i];
         var    b     = (UInt16)listBUInt16[i];
         UInt16?nullA = a;
         UInt16?nullB = b;
         Assert.AreEqual(Math.Max(a, b), Numbers.Max(nullA, nullB));
         Assert.AreEqual(Math.Max(a, b), Numbers.Max(nullB, nullA));
         Assert.AreEqual(Math.Max(nullA.Value, nullB.Value), Numbers.Max(nullA, nullB));
     }
 }
        /// <summary>
        /// Sets a parameter on a IDbCommand
        /// </summary>
        /// <param name="dataParameter">the parameter</param>
        /// <param name="parameterValue">the parameter value</param>
        /// <param name="dbType">the dbType of the parameter</param>
        public override void SetParameter(IDataParameter dataParameter, object parameterValue, string dbType)
        {
            UInt16?nullableValue = (UInt16?)parameterValue;

            if (nullableValue.HasValue)
            {
                dataParameter.Value = nullableValue.Value;
            }
            else
            {
                dataParameter.Value = DBNull.Value;
            }
        }
Ejemplo n.º 33
0
 public void update_v08(UInt16 _rpm, UInt16 _hr, UInt16 _power, UInt16? _kcal = null, UInt16? _clock = null, Int16? _rssi = null)
 {
     rpm = _rpm;
     hr = _hr;
     power = _power;
     kcal = _kcal;
     clock = _clock;
     rssi = _rssi;
     updates++;
     elapsedAtLastUpdate = timeFromStart.Elapsed;
     timeFromUpdate.Reset();
     timeFromUpdate.Start();
 }
        public void Clear()
        {
            ID = 0;

            lastReceivedID = 0;

            firstNewID = null;

            events.Clear();
            eventLastSent.Clear();

            MidRoundSyncingDone = false;
        }
Ejemplo n.º 35
0
        public String GetString(ref int Idx, byte[] buf)
        {
            UInt16?t = GetUInt16(ref Idx, buf);

            if ((t != null) && (buf.Length >= Idx + t.Value))
            {
                Encoding iso = Encoding.GetEncoding("ISO-8859-1");
                String   s   = iso.GetString(buf, Idx, t.Value);
                Idx += t.Value;
                return(s);
            }
            return(null);
        }
        public override bool DecodeAttr(int AttrNum, ref int Idx, byte[] b)
        {
            switch (AttrNum)
            {
            case 1:
                Revision = GetUInt16(ref Idx, b);
                return(true);

            case 2:
                Max_Instance = GetUInt16(ref Idx, b);
                return(true);

            case 3:
                Number_of_Instances = GetUInt16(ref Idx, b);
                return(true);

            case 4:
                Number_of_Attributes = GetUInt16(ref Idx, b);
                if ((Number_of_Attributes != null) && (Number_of_Attributes.Value > 0))
                {
                    Optional_Attributes = new UInt16[Number_of_Attributes.Value];
                    for (int i = 0; i < Number_of_Attributes.Value; i++)
                    {
                        Optional_Attributes[i] = GetUInt16(ref Idx, b).Value;
                    }
                }
                return(true);

            case 5:
                Number_of_Services = GetUInt16(ref Idx, b);
                if ((Number_of_Services != null) && (Number_of_Services.Value > 0))
                {
                    Optional_Services = new UInt16[Number_of_Services.Value];
                    for (int i = 0; i < Number_of_Services.Value; i++)
                    {
                        Optional_Services[i] = GetUInt16(ref Idx, b).Value;
                    }
                }
                return(true);

            case 6:
                Maximum_ID_Number_Class_Attributes = GetUInt16(ref Idx, b);
                return(true);

            case 7:
                Maximum_ID_Number_Instance_Attributes = GetUInt16(ref Idx, b);
                return(true);
            }

            return(false);
        }
Ejemplo n.º 37
0
 public void update_v10(byte[] _uuid, UInt16 _major, UInt16 _minor, UInt16 _rpm, UInt16 _hr, UInt16 _power, UInt16 _interval, UInt16 _kcal, UInt16 _clock, UInt16 _trip, Int16 _rssi, UInt16 _gear)
 {
     uuid = _uuid;
     major = _major;
     minor = _minor;
     rpm = _rpm;
     hr = _hr;
     power = _power;
     interval = _interval;
     kcal = _kcal;
     clock = _clock;
     trip = _trip;
     rssi = _rssi;
     gear = _gear;
     updates++;
     elapsedAtLastUpdate = timeFromStart.Elapsed;
     timeFromUpdate.Reset();
     timeFromUpdate.Start();
 }
Ejemplo n.º 38
0
        protected override void LoadRegisters()
        {
            bool isFirst = true;
            BlockAllRegisters = new List<Register>();

            Registers = null;
            FirstRegister = null;
            LastRegister = null;

            foreach (RegisterSettings register in BlockSettings.RegisterList)
            {
                Register registerItem = Device.GetRegister(this, register);

                if (registerItem != null)
                {
                    UInt16? id = register.Id;
                    BlockAllRegisters.Add(registerItem);
                    if (id.HasValue)
                    {
                        if (!FirstRegister.HasValue)
                        {
                            FirstRegister = 0;
                            LastRegister = 0;
                        }
                        if (FirstRegister.Value > id.Value || isFirst)
                        {
                            FirstRegister = id.Value;
                            isFirst = false;
                        }
                        UInt16 endRegister = (UInt16)(id.Value + register.RegisterCount - 1);
                        if (LastRegister < endRegister)
                            LastRegister = endRegister;
                    }
                }
            }

            if (FirstRegister.HasValue)
                Registers = (UInt16)((LastRegister - FirstRegister) + 1);
        }
Ejemplo n.º 39
0
        protected Register(DeviceBlock deviceBlock, RegisterSettings settings)
        {
            //SendBufferStartPos = 0;
            //ReceiveBufferStartPos = 0;
            PayloadPosition = settings.Position;

            Name = settings.Name;
            Content = settings.Content;

            Settings = settings;
            DeviceBlock = deviceBlock;
            Device = deviceBlock.Device;
            ValueType = settings.Type;
            Message = settings.Message;
            BindingName = settings.Binding;
            Binding = DeviceBlock.Conversation.GetVariable(BindingName);
            if (Binding == null)
            {
                BoundToSend = false;
                BoundToRead = false;
                BoundToFind = false;
                BoundToExtract = false;
            }
            else
            {
                bool res = DeviceBlock.Conversation.GetVariableUsage(BindingName, out BoundToSend, out BoundToRead, out BoundToFind, out BoundToExtract);
                if (!res)
                    LogMessage("Register Constructor - Variable: " + BindingName + " - not used in conversation: " + DeviceBlock.Conversation, LogEntryType.ErrorMessage);
            }
            MappedToRegisterData = (DeviceBlock.GetType() == typeof(DeviceBlock_Modbus) && settings.Id.HasValue)
                || (DeviceBlock.GetType() != typeof(DeviceBlock_Modbus) && BindingName == "");
            //IsContent = Content != "";
            StartRegister = settings.Id.HasValue ? settings.Id.Value : (UInt16)0;
            RegisterCount = settings.RegisterCount;
            UInt16? size = settings.Size;
            Size = size.HasValue ? size.Value : (UInt16)(RegisterCount * 2);
            FixedSize = settings.Size;
            IsAlarmFlag = settings.IsAlarmFlag;
            IsAlarmDetail = settings.IsAlarmDetail;
            IsErrorFlag = settings.IsErrorFlag;
            IsErrorDetail = settings.IsErrorDetail;
            IsHexadecimal = settings.IsHexadecimal;
            IsCString = settings.IsCString;

            LoadValueList();
        }