Ejemplo n.º 1
0
        /// <summary>
        /// Egy sor beszurása a Message táblába.
        /// </summary>
        void AddToTable(
            string name,
            DateTime timestamp,
            MessageDirection direction,
            ArbitrationIdType type,
            uint arbitrationId,
            bool isRemote,
            byte[] data,
            string documentation,
            string description)
        {
            string query = "INSERT INTO Messages " +
                           "(Name, Timestamp, Direction, Type, ArbitrationId, IsRemote, Data, Documentation, Description)" +
                           " values " +
                           "( '" + name + "', '" +
                           timestamp.Ticks + "', '" +
                           direction + "', '" +
                           type + "', '" +
                           arbitrationId.ToString() + "', '" +
                           (isRemote ? 1 : 0) + "', '" +
                           CustomDataConversion.ByteArrayToStringHighSpeed(data) + "', '" +
                           documentation + "', '" +
                           description + "')";

            var command = new SQLiteCommand(query, _connection.SqLiteConnection);

            command.ExecuteNonQuery();
        }
Ejemplo n.º 2
0
 public void _X000_StringToUInt32()
 {
     Assert.AreEqual(0, CustomDataConversion.StringToUInt32(" "));
     Assert.AreEqual(0x0A, CustomDataConversion.StringToUInt32(" 0A"));
     Assert.AreEqual(0x12345678, CustomDataConversion.StringToUInt32("12 34 56 78"));
     Assert.AreEqual(0x00000800, CustomDataConversion.StringToUInt32(" 00000800"));
     Assert.AreEqual(0, CustomDataConversion.StringToUInt32("0000 0000"));
     Assert.AreEqual(0, CustomDataConversion.StringToUInt32("00 00 00 00"));
 }
Ejemplo n.º 3
0
 public void _X000_UInt32ToString()
 {
     Assert.AreEqual("00000800", CustomDataConversion.UInt32ToString(0x00000800, "{0:X8}"));
     Assert.AreEqual("0x00000000", CustomDataConversion.UInt32ToString(0, "0x{0:X8}"));
     Assert.AreEqual("00000000", CustomDataConversion.UInt32ToString(0, "{0:X2}"));
     Assert.AreEqual("0000 0000", CustomDataConversion.UInt32ToString(0, "{0:X4} "));
     Assert.AreEqual("00 00 00 00", CustomDataConversion.UInt32ToString(0, "{0:X2} "));
     Assert.AreEqual("00000001", CustomDataConversion.UInt32ToString(1, "{0:X4}"));
     Assert.AreEqual("12345678", CustomDataConversion.UInt32ToString(0x12345678, "{0:X4}"));
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Az CAN üzenetek betöltése az adatbázis táblából.
        /// </summary>
        internal void Load()
        {
            RaiseListChangedEvents = false;
            Clear();

            int total   = Count;
            int current = 0;

            string query = "SELECT " +
                           "Id, " +
                           "Name, " +
                           "Timestamp, " +
                           "Direction, " +
                           "Type, " +
                           "ArbitrationId, " +
                           "IsRemote, " +
                           "Data, " +
                           "Documentation, " +
                           "Description " +
                           "FROM " +
                           "Messages";

            _connection.SqLiteConnection.Open();
            using (SQLiteCommand cmd = new SQLiteCommand(query, _connection.SqLiteConnection))
            {
                using (SQLiteDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        var msg = new LogMessageItem(
                            _connection,
                            reader.GetInt32(0),                                                                      /*item.Index*/
                            reader.GetString(1),                                                                     /*item.Name*/
                            new DateTime(reader.GetInt64(2)),                                                        /*Timestamp*/
                            (MessageDirection)Enum.Parse(typeof(MessageDirection), reader.GetString(3) as string),   /*Direction*/
                            (ArbitrationIdType)Enum.Parse(typeof(ArbitrationIdType), reader.GetString(4) as string), /*Type*/
                            (uint)reader.GetInt32(5),                                                                /*ArbitrationId*/
                            reader.GetBoolean(6),                                                                    /*Remote*/
                            CustomDataConversion.StringToByteArrayHighSpeed(reader.GetString(7)),                    /*Data*/
                            reader.GetString(8),                                                                     /*Documentation*/
                            reader.GetString(9));                                                                    /*Description*/
                        this.Add(msg);
                        if (current % 20 == 0)
                        {
                            OnProgressChanged(this, new ProgressChangedEventArgs((int)((current / (double)total) * 100.0), "Loading:" + msg.ToString()));
                        }
                        current++;
                    }
                    OnProgressChanged(this, new ProgressChangedEventArgs(100, "Loading Complete"));
                }
            }
            _connection.SqLiteConnection.Close();
            RaiseListChangedEvents = true;
            ResetBindings();
        }
Ejemplo n.º 5
0
 public void _4001_StringToUInt32HighSpeed()
 {
     Assert.AreEqual(0, CustomDataConversion.StringToUInt32HighSpeed(""));
     Assert.AreEqual(0, CustomDataConversion.StringToUInt32HighSpeed(" "));
     Assert.AreEqual(0, CustomDataConversion.StringToUInt32HighSpeed("00000000"));
     Assert.AreEqual(0, CustomDataConversion.StringToUInt32HighSpeed("00000000 "));
     Assert.AreEqual(0, CustomDataConversion.StringToUInt32HighSpeed(" 00000000 "));
     Assert.AreEqual(0, CustomDataConversion.StringToUInt32HighSpeed(" 00000000 "));
     Assert.AreEqual(0x00000000, CustomDataConversion.StringToUInt32HighSpeed(" 00000000 "));
     Assert.AreEqual(0xFFFFFFFF, CustomDataConversion.StringToUInt32HighSpeed("FFFFFFFF"));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Lista másolása a projectbe.
 /// </summary>
 /// <param name="target">Project cél.</param>
 public void CopyTo(StorageCanTxMessageItem target)
 {
     target.Name          = Name;
     target.Key           = Key;
     target.IsPeriod      = IsPeriod;
     target.PeriodTime    = PeriodTime;
     target.Type          = Type;
     target.Remote        = Remote;
     target.ArbitrationId = CustomDataConversion.UInt32ToStringHighSpeed(ArbitrationId);
     target.Data          = CustomDataConversion.ByteArrayToStringHighSpeed(Data);
     target.Documentation = _documentation;
     target.Description   = Description;
 }
Ejemplo n.º 7
0
 private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
 {
     if (dataGridView1.Columns[e.ColumnIndex].Tag is CustomArbIdColumnItem)
     {
         var arbId      = (UInt32)dataGridView1.Rows[e.RowIndex].Cells["columnArbitrationId"].Value;
         var customizer = (CustomArbIdColumnItem)(dataGridView1.Columns[e.ColumnIndex].Tag);
         if ((ArbitrationIdType)dataGridView1.Rows[e.RowIndex].Cells["columnType"].Value == customizer.Type)
         {
             UInt32 customValue = CustomDataConversion.StringToUInt32(dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value as string);
             dataGridView1.Rows[e.RowIndex].Cells["columnArbitrationId"].Value = customizer.SetValue(customValue, arbId).ToString(customizer.Format);
         }
     }
 }
Ejemplo n.º 8
0
        public void _2020_StringToByteArray()
        {
            Assert.AreEqual(new byte[] { }, CustomDataConversion.StringToByteArray("   "));
            Assert.AreEqual(new byte[] { }, CustomDataConversion.StringToByteArray(" "));
            Assert.AreEqual(new[] { 0x00 }, CustomDataConversion.StringToByteArray(" 00"));
            Assert.AreEqual(new[] { 0x0A }, CustomDataConversion.StringToByteArray(" A"));
            Assert.AreEqual(new[] { 0x00 }, CustomDataConversion.StringToByteArray("0"));

            Assert.AreEqual(new[] { 0x01, 0x00 }, CustomDataConversion.StringToByteArray("01 0"));
            Assert.AreEqual(new[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 }, CustomDataConversion.StringToByteArray("01 02 03 04 05 06 07 08"));

            Assert.AreEqual(new[] { 0x01, 0x02, 0x00 }, CustomDataConversion.StringToByteArray("01020"));
            Assert.AreEqual(new[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 }, CustomDataConversion.StringToByteArray("0102030405060708"));

            Assert.AreEqual(new[] { 0x00 }, CustomDataConversion.StringToByteArray("0x"));
            Assert.AreEqual(new[] { 0x00 }, CustomDataConversion.StringToByteArray("0x00"));
            Assert.AreEqual(new[] { 0x00, 0x10 }, CustomDataConversion.StringToByteArray("0x00 0x10"));
            Assert.AreEqual(new[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 }, CustomDataConversion.StringToByteArray("0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08"));

            Assert.AreEqual(new[] { 0x00, 0x10 }, CustomDataConversion.StringToByteArray("0x00, 0x10"));
            Assert.AreEqual(new[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 }, CustomDataConversion.StringToByteArray("0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08"));
        }
Ejemplo n.º 9
0
 public void _3004_StringToByteArrayHighSpeed()
 {
     Assert.AreEqual(new byte[0], CustomDataConversion.StringToByteArrayHighSpeed(""));
     Assert.AreEqual(new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 }, CustomDataConversion.StringToByteArrayHighSpeed("01 02 03 04 05 06 07 08"));
 }
Ejemplo n.º 10
0
 public void _3002_ByteArrayToStringHighSpeed()
 {
     Assert.AreEqual("", CustomDataConversion.ByteArrayToStringHighSpeed(null));
     Assert.AreEqual("01 02 03 04 05 06 07 08", CustomDataConversion.ByteArrayToStringHighSpeed(new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 }));
 }
Ejemplo n.º 11
0
 public void _4002_SUInt32ToStringHighSpeed()
 {
     Assert.AreEqual("00000000", CustomDataConversion.UInt32ToStringHighSpeed(0));
     Assert.AreEqual("12345678", CustomDataConversion.UInt32ToStringHighSpeed(0x12345678));
     Assert.AreEqual("00000801", CustomDataConversion.UInt32ToStringHighSpeed(0x00000801));
 }