public RegistrationReader(string path, List<int> aIndexes, List<int> dIndexes, int indexOfFile, int regPointerAnalog, int regPointerDiscrete, long startTime, long stopTime, AnalogSignalsBase aBase, DiscreteSignalBase dBase)
 {
     _path = path;
     _analogSignalsIndexes = aIndexes;
     _discreteSignalsIndexes = dIndexes;
     _indexOfRegistrationFile = indexOfFile;
     _registrationPointerAnalog = regPointerAnalog;
     _registrationPointerDiscrete = regPointerDiscrete;
     _startTimeInSeconds = startTime;
     _stopTimeInSeconds = stopTime;
     _analogSignalBase = aBase;
     _discreteSignalBase = dBase;
     DateTime dateOfCreation = _baseTime.AddSeconds(_startTimeInSeconds);
     _dateOfFragmentCreation = "_" + dateOfCreation.Year.ToString() + "." + dateOfCreation.Month.ToString() + "." + dateOfCreation.Day.ToString() + "." +
         dateOfCreation.Hour.ToString() + "." + dateOfCreation.Minute.ToString() + "." + dateOfCreation.Second.ToString();
 }
Ejemplo n.º 2
0
        private DiscreteSignalBase DiscreteDbfData(string path)
        {
            DBFTable wDBF = new DBFTable();

            var dataTable = wDBF.GetAll(path);

            DiscreteSignalBase signaBase = new DiscreteSignalBase(dataTable.Rows.Count, new List<string>());

            foreach(DataRow row in dataTable.Rows)
            {
                signaBase.SignalCodes.Add(row[5].ToString());
            }

            return signaBase;
        }
Ejemplo n.º 3
0
        private void FileOpenProjectButton_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog openProject = new FolderBrowserDialog();

            if (openProject.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    if (File.Exists(openProject.SelectedPath + projectRegFilePath) &&
                        File.Exists(openProject.SelectedPath + registrationPath + "pointer.dat") &&
                        File.Exists(openProject.SelectedPath + projectDRegFilePath))
                    {
                        projectPath = openProject.SelectedPath;

                        byte[] pointerArray = ReadPointerFile(openProject.SelectedPath + registrationPath + "pointer.dat");
                        byte[] dPointerArray = ReadPointerFile(openProject.SelectedPath + registrationPath + "dpointer.dat");

                        _pointerFileData = new PointerFileData(BitConverter.ToInt16(pointerArray, 0), new List<short>(), new List<long>(), new List<int>());
                        _dPointerFileData = new PointerFileData(BitConverter.ToInt16(pointerArray, 0), new List<short>(), new List<long>(), new List<int>());

                        File.Copy(openProject.SelectedPath + projectRegFilePath, openProject.SelectedPath + "\\REG1.DBF");
                        _aSignalBase = AnalogDbfData(openProject.SelectedPath + "\\REG1.DBF");
                        File.Delete(openProject.SelectedPath + "\\REG1.DBF");

                        File.Copy(openProject.SelectedPath + projectDRegFilePath, openProject.SelectedPath + "\\DREG1.DBF");
                        _dSignalBase = DiscreteDbfData(openProject.SelectedPath + "\\DREG1.DBF");
                        File.Delete(openProject.SelectedPath + "\\DREG1.DBF");

                        AnalogSignalListBox.Items.AddRange(_aSignalBase.SignalCodes.ToArray());
                        DiscreteSignalListBox.Items.AddRange(_dSignalBase.SignalCodes.ToArray());

                        string[] registrationFileNames = Directory.GetFiles(openProject.SelectedPath + registrationPath, "*.reg");

                        foreach (string regFileName in registrationFileNames)
                        {
                            string replacedName = regFileName.Replace(openProject.SelectedPath + registrationPath, "");
                            string pattern = @"\d+";
                            Regex r = new Regex(pattern);
                            Match m = r.Match(replacedName);

                            while (m.Success)
                            {
                                _registrationIndecies.Add(Convert.ToInt32(m.Value));
                                break;
                            }

                        }

                        _registrationIndecies.Sort();

                        for (int i = 0; i < _registrationIndecies.Count; i++)
                        {
                            _pointerFileData.RegistrationFragmentFrequency.Add(BitConverter.ToInt16(pointerArray, 2 + _registrationIndecies[i] * 10));
                            _pointerFileData.TimeOfRegistrationStop.Add(BitConverter.ToInt32(pointerArray, 4 + _registrationIndecies[i] * 10));
                            _pointerFileData.PointerToOverWrittenOffset.Add(BitConverter.ToInt32(pointerArray, 8 + _registrationIndecies[i] * 10));

                            _dPointerFileData.RegistrationFragmentFrequency.Add(BitConverter.ToInt16(dPointerArray, 2 + _registrationIndecies[i] * 10));
                            _dPointerFileData.TimeOfRegistrationStop.Add(BitConverter.ToInt32(dPointerArray, 4 + _registrationIndecies[i] * 10));
                            _dPointerFileData.PointerToOverWrittenOffset.Add(BitConverter.ToInt32(dPointerArray, 8 + _registrationIndecies[i] * 10));

                            RegFragments.Items.Add(_registrationIndecies[i] + ". (" + _pointerFileData.RegistrationFragmentFrequency[i] + ") " + _baseTime.AddSeconds(_pointerFileData.TimeOfRegistrationStop[i]) + " (" + _pointerFileData.PointerToOverWrittenOffset[i] + ")" + " (" + _dPointerFileData.PointerToOverWrittenOffset[i] + ")");
                        }

                        UnpackStart.Enabled = true;

                        pointerArray = null;

                    }
                    else
                        throw new Exception();
                }
                catch
                {
                    MessageBox.Show("Something is missing in your path!");
                }
            }
        }