Esempio n. 1
0
        public void Load()
        {
            BinaryReader reader = new BinaryReader(File.Open(Name, FileMode.Open));

            while (reader.BaseStream.Length != reader.BaseStream.Position)
            {
                RecordDescription description = RecordDescription.LoadRecordFromType(reader);
                if (description == null)
                {
                    break;
                }
                description.Load(reader);
                AddDescription(description);
            }
            // read the records
            int count = Description.Count;

            if (count <= 0)
            {
                reader.Close();
                throw new Exception("Database corrupted");
            }
            while (reader.BaseStream.Length != reader.BaseStream.Position)
            {
                Record record = new Record(count);
                for (int i = 0; i < Description.Count; i++)
                {
                    Value val = Description[i].PresetValue.Clone();
                    val.Load(reader);
                    record.SetValue(val, i);
                }
                AddRecord(record);
            }
            reader.Close();
        }
Esempio n. 2
0
        private void Create(object sender, RoutedEventArgs e)
        {
            RecordsManager manager    = new RecordsManager();
            TreeViewItem   attributes = FindName("databaseName") as TreeViewItem;

            foreach (TreeAttribute att in attributes.Items)
            {
                FieldInterface attInterface = att.AttributeContent as FieldInterface;
                if ((attInterface as FieldGeneric) != null)
                {
                    //TODO say all invalid nodes that his has
                    MessageBox.Show("Some input is invalid. Node ( " + att.Header + " )", "Invalid Entry", MessageBoxButton.OK);
                    return;                                                   // do nothing
                }
                RecordDescription desc = attInterface.GetRecordDescription(); // TODO remove this and add binding
                desc.Name = att.Header.ToString();
                manager.AddDescription(desc);
            }
            manager.ChangeName(attributes.Header as String);
            OnInfo("Saving database");
            manager.Save();
            Results w = new Results(manager);

            OnInfo("Database saved");
            OnResult(w);
        }
Esempio n. 3
0
        } // GetRecordDuration

        public static RecordDescription GetRecordDescription(EpgProgram epgProgram, RecordChannel channel)
        {
            if (epgProgram == null)
            {
                throw new ArgumentNullException(nameof(epgProgram));
            }

            var description = RecordDescription.CreateWithDefaultValues();

            description.Name = RecordDescription.CreateTaskName(channel, epgProgram.LocalStartTime);

            /* var extended = program as EpgProgramExtended;
             * if (extended != null)
             * {
             *
             * }
             * else */
            {
                var buffer = new StringBuilder();
                buffer.AppendLine(epgProgram.Title);
                buffer.Append(epgProgram.ParentalRating.Description);
                description.Description = buffer.ToString();
            } // if-else

            return(description);
        } // GetRecordDescription
Esempio n. 4
0
        /* common methods */
        /* save whole database */
        public void Save()
        {
            String       tempName = Name + Misc.Common.saveInProgressAppendix;
            BinaryWriter writer   = new BinaryWriter(File.Open(tempName, FileMode.Create));

            // patterns are delimited by blank line
            foreach (RecordDescription a in Description)
            {
                RecordDescription.SaveRecordType(writer, a);
                a.Save(writer);
            }
            writer.Write(-1); //deliminer
            int count = Description.Count;

            foreach (Record a in _records)
            {
                for (int i = 0; i < count; i++)
                {
                    a.GetValue(i).Save(writer);
                }
            }
            writer.Close();
            File.Delete(Name);
            File.Move(tempName, Name);
            onUpdate();
        }
Esempio n. 5
0
        private void Clear_Click(object sender, RoutedEventArgs e)
        {
            Conditions.Clear();
            ListBox           names = FindName("AttributeName") as ListBox;
            RecordDescription des   = names.SelectedItem as RecordDescription;

            des.VControl.SetValue(des.PresetValue);
            UpdateLastCondition();
        }
Esempio n. 6
0
        }     // textTaskName_Validating

        private void UpdateTaskName()
        {
            if (IsTaskNameUserProvided)
            {
                return;
            }

            var taskName = RecordDescription.CreateTaskName(Task.Channel, CurrentStartDateTime);

            textTaskName.SetText(taskName, false);
        } // UpdateTaskName
Esempio n. 7
0
        bool parseParam(byte[] data, RecordDescription rd, ref float value)
        {
            /*энергия записана в 6ти кодебайтах в hex-dec*/
            byte[] energyBytes = new byte[rd.size];
            Array.Copy(data, rd.index, energyBytes, 0, rd.size);
            Array.Reverse(energyBytes, rd.cmd_size, energyBytes.Length - rd.cmd_size);

            string hex_str = BitConverter.ToString(energyBytes, rd.cmd_size).Replace("-", string.Empty);

            float temp_val = (float)Convert.ToDouble(hex_str) * rd.coeff;

            value = temp_val;
            return(true);
        }
Esempio n. 8
0
        private void UpdateLastCondition()
        {
            // add permanently and create new
            ListBox listbox            = FindName("Operations") as ListBox;
            SimpleExpressionHolder h   = listbox.SelectedItem as SimpleExpressionHolder;
            ListBox           names    = FindName("AttributeName") as ListBox;
            int               desindex = names.SelectedIndex;
            RecordDescription des      = names.SelectedItem as RecordDescription;

            if (des == null)
            {
                return;
            }
            string         sDes = string.Format("{0} {1} {2}", des.Name, h.Operation, des.VControl.GetStringValue());
            IConditionRule rule = h.Create(desindex, des.VControl.ConvertToValue());

            Conditions.Add(rule, sDes);
        }
Esempio n. 9
0
        public RD_ERROR UpdateRecordInfo(RecordDescription apDesc)
        {
            if (openingRecordID != apDesc.recordID)
            {
                return(RD_ERROR.RDE_COMMAND_OBSOLETE);
            }

            System.Diagnostics.Debug.Assert(currentRecord == null);

            RecordDescription recordDescription = GetRecordDescription(apDesc.recordID);

            if (recordDescription != null)
            {
                recordDescription.Set(apDesc);

                currentRecord             = new RecordDocument();
                currentRecord.Description = recordDescription;
                return(OpenRecordImpl(currentRecord));
            }
            return(RD_ERROR.RDE_COMMAND_OBSOLETE);
        }
Esempio n. 10
0
        public void キャンセルするテスト()
        {
            var description = new RecordDescription()
            {
                CreatedDateTime = DateTime.Now,
                TimeSpan        = 17460,
                NamingName      = "localhost:2809/ConsoleIn0.rtc",
                ComponentType   = "ConsoleIn",
                PortName        = "ConsoleIn0.out",
                DataType        = "IDL:RTC/TimedLong:1.0",
                SumSize         = 228,
                Count           = 19,
                IsLittleEndian  = 1,
                IndexFileName   = "TestData002.index",
                DataFileName    = "TestData002.data",
            };

            var player = new Player(description, "127.0.0.1:2809/SampleIn0.rtc", "SampleIn0.in");

            player.IsNotNull();

            player.IsAlive.Is(true);

            player.Start();

            player.IsAlive.Is(true);
            player.IsPlaying.Is(true);

            _observer.Take(3)
            .Do(x => Console.WriteLine(x[8]))
            .Timeout(TimeSpan.FromSeconds(30))
            .ToEnumerable().ToList();

            player.Stop();

            player.IsAlive.Is(true);
            player.IsPlaying.Is(false);
        }
Esempio n. 11
0
        public void ファイルを再生するテスト()
        {
            var description = new RecordDescription()
            {
                CreatedDateTime = DateTime.Now,
                TimeSpan        = 1661,
                NamingName      = "127.0.0.1:2809/ConsoleOut0.rtc",
                ComponentType   = "SampleOut",
                PortName        = "SampleOut0.out",
                DataType        = "IDL:RTC/TimedLong:1.0",
                SumSize         = 1200,
                Count           = 100,
                IsLittleEndian  = 1,
                IndexFileName   = "TestData001.index",
                DataFileName    = "TestData001.data",
            };

            var player = new Player(description, "127.0.0.1:2809/SampleIn0.rtc", "SampleIn0.in");

            player.IsNotNull();

            player.IsAlive.Is(true);

            player.Start();

            player.IsAlive.Is(true);

            // 100回putされるまで待つ。10秒以内に完了しなかったらTimeoutException
            var data = _observer.Take(100)
                       .Timeout(TimeSpan.FromSeconds(10))
                       .ToEnumerable().ToList();

            data.Count().Is(100);

            player.Stop();

            player.IsAlive.Is(true);
        }
Esempio n. 12
0
        public void 初期化のテスト()
        {
            var description = new RecordDescription()
            {
                CreatedDateTime = DateTime.Now,
                TimeSpan        = 1661,
                NamingName      = "127.0.0.1:2809/ConsoleOut0.rtc",
                ComponentType   = "SampleOut",
                PortName        = "SampleOut0.out",
                DataType        = "IDL:RTC/TimedLong:1.0",
                SumSize         = 1200,
                Count           = 100,
                IsLittleEndian  = 1,
                IndexFileName   = "TestData001.index",
                DataFileName    = "TestData001.data",
            };

            var player = new Player(description, "127.0.0.1:2809/SampleIn0.rtc", "SampleIn0.in");

            player.IsNotNull();

            player.IsAlive.Is(true);
        }
Esempio n. 13
0
        public void キャストのチェック()
        {
            // SQLiteを1.0.76.0にアップデートしたら、IsLittleEndianをlongからboolにキャストしようとしてエラーになった。
            // SQLiteではboolは使えない。

            dynamic descs = DbExecutor.SelectDynamic(
                new SQLiteConnection("Data Source=../../TestData/RecordDescriptions.db"),
                @"select * from RecordDescriptions ").First();

            var data = new RecordDescription();

            data.ComponentType   = descs.ComponentType;
            data.Count           = descs.Count;
            data.CreatedDateTime = descs.CreatedDateTime;
            data.DataFileName    = descs.DataFileName;
            data.DataType        = descs.DataType;
            data.IndexFileName   = descs.IndexFileName;
            data.IsLittleEndian  = descs.IsLittleEndian;
            data.NamingName      = descs.NamingName;
            data.PortName        = descs.PortName;
            data.SumSize         = descs.SumSize;
            data.TimeSpan        = descs.TimeSpan;
            data.Title           = descs.Title;
        }
Esempio n. 14
0
        bool parseParam(RecordDescription rd, ref float value)
        {
            byte[] data = null;
            if (SendREQ_UD2(ref data))
            {
                /*энергия записана в 6ти кодебайтах в hex-dec*/
                byte[] energyBytes = new byte[rd.size];
                Array.Copy(data, rd.index, energyBytes, 0, rd.size);
                Array.Reverse(energyBytes, rd.cmd_size, energyBytes.Length - rd.cmd_size);

                string hex_str = BitConverter.ToString(energyBytes, rd.cmd_size).Replace("-", string.Empty);

                float temp_val = (float)Convert.ToDouble(hex_str) * rd.coeff;

                value = temp_val;
                return true;
            }
            else
            {
                return false;
            }
        }
Esempio n. 15
0
 public void AddDescription(RecordDescription rec)
 {
     Description.Add(rec);
 }
 public void NotifyAdopt(RecordDescription description) // 検索結果が選択されたら通知される
 {
     _notifier(description);
     Messenger.Raise(new WindowActionMessage("CloseWindow", WindowAction.Close));
 }
Esempio n. 17
0
        bool parseParam(byte[] data, RecordDescription rd, ref float value)
        {
            List<byte> dataBytesList = new List<byte>();
            if (rd.index + rd.size >= data.Length)
            {
                WriteToLog("rd.index + rd.size >= data.Length");
                return false;
            }


            for (int i = rd.index + rd.cmd_size; i < rd.index + rd.size; i++)
            {
                dataBytesList.Add(data[i]);
            }

            int dif = 4 - dataBytesList.Count;
           if (dif > 0 ) {
               for (int i = 0; i < dif; i++){
                   dataBytesList.Add(0x0);
               }
           }

           dataBytesList.Reverse();

           string hex_str = "";
           float temp_val = -1f;
           try
           {
               hex_str = BitConverter.ToString(dataBytesList.ToArray(), 0).Replace("-", string.Empty);
               temp_val = (float)Convert.ToSingle(hex_str) * rd.coeff;
           }
           catch (Exception ex)
           {
               WriteToLog(ex.Message + " conversion problems");
               return false;
           }

           // string hstr = BitConverter.ToString(energyBytes, rd.cmd_size);
           value = temp_val;
           if (temp_val > 30000)
           {
               value = 0f;
           }
            return true;
        }
Esempio n. 18
0
 public void NotifyAdopt(RecordDescription description)
 {
     _players.Add(new Player(description, SelectedPort.NamingName, SelectedPort.Name));
 }
Esempio n. 19
0
        public void NotifyAdopt(RecordDescription description)
        {
            Analyzer = new Analyzer(description);

            UpdateCommand.Execute(null);
        }
Esempio n. 20
0
 public SearchResultViewModel(RecordDescription description, Action <RecordDescription> notifier)
 {
     _recordDescription = description;
     _notifier          = notifier;
 }