示例#1
0
        public bool ImportDirectory(string Dir)
        {
            ACQReader TempACQ = new ACQReader();
            FileType F = new FileType();
            //Open the ACQ file
            string[] FName = Directory.GetFiles(Dir, "*.acq");
            if (FName.Length > 0)
            {
                TempACQ.openACQ(FName[0]);
                string Fn = FName[0].Substring(FName[0].LastIndexOf('\\') + 1);
                F.Start = ConvertFileToDT(Fn);
                F.Chans = TempACQ.Chans;
                F.AnimalIDs = TempACQ.ID;
                F.Duration = TimeSpan.FromSeconds(TempACQ.FileTime);
                TempACQ.closeACQ();
                FileType Fs = Files.Find(delegate(FileType Ft) { return ((DateTime.Compare(Ft.Start, F.Start) == 0) && (string.Compare(F.AnimalIDs[0], Ft.AnimalIDs[0])== 0)); });
                //Determine if duplicate file - compare animal name and file start
                if (Fs != null)
                {
                    //Boot us out of the function
                    return false;
                }
                Files.Add(F);
                //Open the Feeder file
                string[] FLogName = Directory.GetFiles(Dir, "*Feeder.log");
                if (FLogName.Length != 0)
                {
                    DateTime d;
                    string Type;
                    int PC;
                    string Line;
                    int CurrentAnimal;
                    int Feeder;
                    StreamReader FLog = new StreamReader(FLogName[0]);

                    while (!FLog.EndOfStream)
                    {
                        //5/1/2012 3:00:04 AM  Feeder: 1  Pellets: 8 Medicated
                        Line = FLog.ReadLine();
                        DateTime.TryParse(Line.Substring(0, Line.IndexOf("Feeder") - 1), out d);
                        int.TryParse(Line.Substring(Line.IndexOf("Pellets: ") + 9, 2), out PC);
                        int.TryParse(Line.Substring(Line.IndexOf("Feeder: ") + 8, 2), out Feeder);
                        CurrentAnimal = FindAnimal(F.AnimalIDs[Feeder / 2]);
                        if (Feeder%2 == 1) //Figure out type
                        {
                            Type = "M";
                        }
                        else
                        {
                            Type = "U";
                        }
                        MealType M = new MealType(d.ToString(), Type, PC.ToString());
                        Animals[CurrentAnimal].Meals.Add(M);
                    }
                    FLog.Close();
                }
                if (Directory.Exists(Dir + "\\Seizure"))
                {
                    string[] SZFile = Directory.GetFiles(Dir + "\\Seizure", "*.txt");
                    if (SZFile[0] != null)
                    {
                        ImportSzFile(SZFile[0]);
                    }
                }
            }
            return true;
        }
示例#2
0
        public CManage()
        {
            InitializeComponent();
            this.WindowState = FormWindowState.Maximized;
            ACQ = new ACQReader(); //Class to read from ACQ file
            graph = new Mygraph(); //Small Class for containing EEG area.
            DSF = new DetectedSeizureFileType();
            VideoOffset = new float[16];
            string[] args = new string[] { "" };
            instance = new VlcInstance(args);
            INI = new IniFile(Directory.GetCurrentDirectory() + "\\SeizurePlayback.ini");
            ACQ.initDisplay(10, 10);
            g = this.CreateGraphics(); //Graphics object for main form
            OffsetBox.Text = VideoOffset[0].ToString();
            //Create Instances
            CurrentAVI = ""; //No default AVI loaded
            SeizureCount = new int[16]; //Create Array for Seizure Counts;

            //Graphics area of the form to display the EEG. It would be better if these were dynamically resized.
            //I don't have time for that shit.

            ChanPos = new int[16];
            VisChecks = new CheckBox[16];
            VisChecks[0] = VisChan1;
            VisChecks[1] = VisChan2;
            VisChecks[2] = VisChan3;
            VisChecks[3] = VisChan4;
            VisChecks[4] = VisChan5;
            VisChecks[5] = VisChan6;
            VisChecks[6] = VisChan7;
            VisChecks[7] = VisChan8;
            VisChecks[8] = VisChan9;
            VisChecks[9] = VisChan10;
            VisChecks[10] = VisChan11;
            VisChecks[11] = VisChan12;
            VisChecks[12] = VisChan13;
            VisChecks[13] = VisChan14;
            VisChecks[14] = VisChan15;
            VisChecks[15] = VisChan16;

            INIload();
            TimeBox.SelectedIndex = 1; //Default Time Scale
            Step = MaxDispSize; //Setting Step to max display size makes sure the image refreshes.

            //Add Mouse Handlers
            this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.MyMouseUp);
            this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.MouseDownHandler);
            this.KeyPreview = true;
            this.KeyPress += new KeyPressEventHandler(Form1_KeyPress);
            ResizeBool = true;
            //Start up the display thread.
            this.Resize += new System.EventHandler(this.MainForm_Resize);
            ThreadDisplay = new Thread(new ThreadStart(DisplayThread));
            ThreadDisplay.Start();
            OffsetBox.Enabled = false;
            graph.X1 = 5;
            graph.X2 = this.Size.Width - 10;
            graph.Y1 = 6;
            graph.Y2 = VideoPanel.Location.Y - 11; //this.Size.Height - VideoPanel.Location.Y;
            Console.WriteLine(this.Size.Height);
            Console.WriteLine(VideoPanel.Location.Y - 11);
            ACQ.initDisplay(graph.X2 - graph.X1, graph.Y2 - graph.Y1);    //Create the graphics box to display EEG.
        }