コード例 #1
0
#pragma warning disable 1998
        public override async Task <Response> ExecuteAsync(SocketConnection connection)
#pragma warning restore 1998
        {
            var topics       = ListTopicsCommand.FromBytes(RawData);
            var topicService =
                ActivatorUtilities.GetServiceOrCreateInstance <ITopicService>(Dependencies.Configuration.Services);

            var responseHeader = new Header.Header
            {
                Command    = CommandType.ModifyTopic,
                Type       = HeaderType.Response,
                DataLength = 0
            };

            var res = new Response {
                Data = new byte[] { }, Header = responseHeader
            };

            if (topics.Count != 2)
            {
                res.Data = false.ToBytes();
                res.Header.DataLength = res.Data.Length;
                return(res);
            }

            var oldTopc = topics[0];
            var newTopc = topics[1];
            var result  = topicService.Update(oldTopc, newTopc).ToBytes();

            res.Data = result;
            res.Header.DataLength = result.Length;

            return(res);
        }
コード例 #2
0
        public PKDetectorEventCounter(Header.Header hdr, IValidate v)
        {
            this.header = hdr;
            this.validate = v;

            InitializeComponent();

            foreach (string str in hdr.Events.Keys)
                if (str.Substring(0, 7) == "**PKDet") EventSelection.Items.Add(str.Substring(7)); //Add to Event selection list
            EventSelection.SelectedIndex = 0;
            Comp1.Items.Add("<");
            Comp1.Items.Add(">");
            Comp1.SelectedIndex = 0;
            Comp2.Items.Add(">");
            Comp2.Items.Add("<");
            Comp2.SelectedIndex = 0;
        }
コード例 #3
0
        public static AbstractCommand CreateCommand(Header.Header header, byte[] data)
        {
            switch (header.Command)
            {
            case CommandType.NewTopic:
                return(new AddTopicCommand(header, data));

            case CommandType.RemoveTopic:
                return(new RemoveTopicCommand(header, data));

            case CommandType.ModifyTopic:
                return(new ModifyTopicCommand(header, data));

            case CommandType.NewPost:
                return(new NewPostCommand(header, data));

            case CommandType.ListTopics:
                return(new ListTopicsCommand(header, data));

            case CommandType.ListPosts:
                return(new ListPostsCommand(header, data));

            case CommandType.UploadPostFile:
                return(new UploadPostFileCommand(header, data));

            case CommandType.AssociatePostWithTopic:
                return(new AssociatePostWithTopicCommand(header, data));

            case CommandType.ListPostsByTopic:
                return(new ListPostsByTopicCommand(header, data));

            case CommandType.RemovePostAndTopicAssociation:
                return(new RemovePostAndTopicAssociationCommand(header, data));

            case CommandType.ModifyPost:
                return(new ModifyPostCommand(header, data));

            case CommandType.RemovePost:
                return(new RemovePostCommand(header, data));

            case CommandType.Exit:
                break;
            }

            return(null);
        }
コード例 #4
0
        public Window2()
        {
            Log.writeToLog("Starting FileConverter " + Utilities.getVersionNumber());

            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.Title = "Open Header file for conversion...";
            dlg.DefaultExt = ".hdr"; // Default file extension
            dlg.Filter = "HDR Files (.hdr)|*.hdr"; // Filter files by extension
            Nullable<bool> result = dlg.ShowDialog();
            if (result == null || result == false) { this.Close(); Environment.Exit(0); }

            directory = System.IO.Path.GetDirectoryName(dlg.FileName);

            head = (new HeaderFileReader(dlg.OpenFile())).read();
            ED = head.Events;

            bdf = new BDFEDFFileReader(
                new FileStream(System.IO.Path.Combine(directory, head.BDFFile),
                    FileMode.Open, FileAccess.Read));
            oldSR = bdf.NSamp / bdf.RecordDurationDouble;
            oldNP = bdf.NSamp;
            oldNS = bdf.RecordDurationDouble;

            InitializeComponent();

            this.MinHeight = SystemInformation.WorkingArea.Height - 240;
            this.Title = "Convert " + System.IO.Path.GetFileNameWithoutExtension(dlg.FileName);
            this.TitleLine.Text = head.Title + " - " + head.Date + " " + head.Time + " S=" + head.Subject.ToString("0000");

            _EDEList = ED.Values.ToList<EventDictionaryEntry>();
            listView1.SelectedItem = 0;
            listView1.Focus();
            listView1.ItemsSource = EDEList;

            System.Windows.Data.Binding GVBinding = new System.Windows.Data.Binding();
            GVBinding.Source = this;
            GVBinding.NotifyOnSourceUpdated = true;
            GVBinding.Path = new PropertyPath("GVList");
            GVBinding.Mode = BindingMode.OneWay;
            listView2.SetBinding(System.Windows.Controls.ListView.ItemsSourceProperty, GVBinding);
            GVList = EDEList[0].GroupVars;
        }
コード例 #5
0
        public override async Task <Response> ExecuteAsync(SocketConnection connection)

        {
            var topicToAdd   = FromBytes(RawData);
            var topicService =
                ActivatorUtilities.GetServiceOrCreateInstance <ITopicService>(Dependencies.Configuration.Services);
            var success = await topicService.AddTopicAsync(topicToAdd) > -1;

            var responseData   = success.ToBytes();
            var responseHeader = new Header.Header
            {
                Command    = CommandType.NewTopic,
                Type       = HeaderType.Response,
                DataLength = 0,
            };

            return(new Response {
                Data = new byte[] { }, Header = responseHeader
            });
        }
コード例 #6
0
        public override async Task <Response> ExecuteAsync(SocketConnection connection)

        {
            var topicToDelete = FromBytes(RawData);

            var topicService =
                ActivatorUtilities.GetServiceOrCreateInstance <ITopicService>(Dependencies.Configuration.Services);
            var result = (await topicService.RemoveAsync(topicToDelete.Id))?.ToBytes();

            var responseHeader = new Header.Header
            {
                Command    = CommandType.RemoveTopic,
                Type       = HeaderType.Response,
                DataLength = result?.Length ?? 0
            };

            return(new Response {
                Data = result, Header = responseHeader
            });
        }
コード例 #7
0
#pragma warning disable 1998
        public override async Task <Response> ExecuteAsync(SocketConnection connection)
#pragma warning restore 1998
        {
            var topicService =
                ActivatorUtilities
                .GetServiceOrCreateInstance <ITopicService>(Dependencies.Configuration.Services);
            var topics         = topicService.GetAll();
            var data           = FromList(topics);
            var responseHeader = new Header.Header
            {
                Command    = CommandType.ListTopics,
                Type       = HeaderType.Response,
                DataLength = data.Length
            };

            return(new Response
            {
                Data = data.Length > 0 ? data : new byte[] { },
                Header = responseHeader
            });
        }
コード例 #8
0
        public EpisodeDescriptionEntry(Header.Header head, IValidate v)
        {
            this.hdr = head;
            this.validate = v;

            InitializeComponent();

            EventDictionary.EventDictionary events = hdr.Events;
            Event1.Items.Add("Any Event");
            Event1.Items.Add("Beginning of file");
            Event2.Items.Add("Same Event");
            Event2.Items.Add("Next Event (any)");
            Event2.Items.Add("Next Event (covered)");
            Event3.Items.Add("None");
            Event4.Items.Add("Same Event");
            foreach (EventDictionary.EventDictionaryEntry ev in events.Values){
                Event1.Items.Add(ev);
                Event2.Items.Add(ev);
                Event3.Items.Add(ev);
                Event4.Items.Add(ev);
            }
            Event1.SelectedIndex = 0;
            Event2.SelectedIndex = 0;
            Event3.SelectedIndex = 0;
            Event4.SelectedIndex = 0;
            Event4.IsEnabled = false;
            Comp1.Items.Add("=");
            Comp1.Items.Add("!=");
            Comp2.Items.Add("=");
            Comp2.Items.Add("!=");

            _GVspec = ++EDcount;
            GVSpec.Text = _GVspec.ToString("0");

            bool test = false;
            foreach (string ev in hdr.Events.Keys)
                if (ev.Substring(0, 7) == "**PKDet") { test = true; break; } //make sure there are PK detector Events present
            if (!test) AddCounterEvent.IsEnabled = false;
        }
コード例 #9
0
#pragma warning disable 1998
        public override async Task <Response> ExecuteAsync(SocketConnection connection)
#pragma warning restore 1998
        {
            var postService =
                ActivatorUtilities
                .GetServiceOrCreateInstance <IPostService>(Dependencies.Configuration.Services);

            var posts = postService.GetAll();

            var payload        = FromList(posts);
            var responseHeader = new Header.Header
            {
                Command    = CommandType.ListPosts,
                Type       = HeaderType.Response,
                DataLength = payload.Length
            };

            return(new Response
            {
                Data = payload,
                Header = responseHeader
            });
        }
 public AssociatePostWithTopicCommand(Header.Header header, byte[] data) : base(header, data)
 {
 }
コード例 #11
0
 public NewPostCommand(Header.Header header, byte[] data)
     : base(header, data)
 {
 }
コード例 #12
0
 public ModifyTopicCommand(Header.Header header, byte[] data) : base(header, data)
 {
 }
コード例 #13
0
 public RemovePostCommand(Header.Header header, byte[] data) : base(header, data)
 {
 }
コード例 #14
0
 public ListTopicsCommand(Header.Header header, byte[] data) : base(header, data)
 {
 }
コード例 #15
0
 public ListPostsByTopicCommand(Header.Header header, byte[] data) : base(header, data)
 {
 }
コード例 #16
0
 public UploadPostFileCommand(Header.Header header, byte[] data) : base(header, data)
 {
 }
コード例 #17
0
ファイル: Event.cs プロジェクト: DOPS-CCI/CCI_project
 /// <summary>
 /// Links all input Events to a particular dataset in order to make the timing of InputEvents relative
 /// to the BDF file
 /// </summary>
 /// <param name="Head">HDR file reader for the dataset</param>
 /// <param name="BDF">BDF file reader for the dataset</param>
 public static void LinkEventsToDataset(Header.Header Head, BDFEDFFileReader BDF)
 {
     head = Head;
     bdf = BDF;
 }
コード例 #18
0
 public AddTopicCommand(Header.Header header, byte[] data)
     : base(header, data)
 {
 }
コード例 #19
0
        public Window2()
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Title = "Open Header file ...";
            dlg.DefaultExt = ".hdr"; // Default file extension
            dlg.Filter = "HDR Files (.hdr)|*.hdr"; // Filter files by extension
            dlg.InitialDirectory = Properties.Settings.Default.LastDataset;
            bool result = dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK;
            if (!result) Environment.Exit(0);

            headerFileName = System.IO.Path.GetFileNameWithoutExtension(dlg.FileName);
            directory = System.IO.Path.GetDirectoryName(dlg.FileName);
            Properties.Settings.Default.LastDataset = directory;

            CCIUtilities.Log.writeToLog("Starting ASCtoFMConverter " + CCIUtilities.Utilities.getVersionNumber());

            head = (new HeaderFileReader(dlg.OpenFile())).read();
            ED = head.Events;

            bdf = new BDFEDFFileReader(
                new FileStream(System.IO.Path.Combine(directory, head.BDFFile),
                    FileMode.Open, FileAccess.Read));
            samplingRate = (int)((double)bdf.NSamp / bdf.RecordDurationDouble);

            OpenPCommand.InputGestures.Add(
                new KeyGesture(Key.O, ModifierKeys.Control | ModifierKeys.Shift, "Ctrl+Shift+O"));
            SavePCommand.InputGestures.Add(
                new KeyGesture(Key.S, ModifierKeys.Control, "Crtl+S"));
            ProcessCommand.InputGestures.Add(
                new KeyGesture(Key.P, ModifierKeys.Control, "Crtl+P"));
            ExitCommand.InputGestures.Add(new KeyGesture(Key.Q, ModifierKeys.Control, "Crtl+Q"));

            InitializeComponent();

            //***** Set up menu commands and short cuts

            CommandBinding cbOpenP = new CommandBinding(OpenPCommand, cbOpen_Execute, cbOpen_CanExecute);
            this.CommandBindings.Add(cbOpenP);

            CommandBinding cbSaveP = new CommandBinding(SavePCommand, cbSave_Execute, validParams_CanExecute);
            this.CommandBindings.Add(cbSaveP);

            CommandBinding cbProcess = new CommandBinding(ProcessCommand, ConvertFM_Click, validParams_CanExecute);
            this.CommandBindings.Add(cbProcess);

            CommandBinding cbExit = new CommandBinding(ExitCommand, Done_Click, cbExit_CanExecute);
            this.CommandBindings.Add(cbExit);

            this.MinHeight = SystemInformation.WorkingArea.Height - 240;
            this.EpisodeEntries.Items.Add(new EpisodeDescriptionEntry(head, this)); //include initial episode description

            this.Title = "Convert " + headerFileName;
            this.TitleLine.Text = head.Title + " - " + head.Date + " " + head.Time + " S=" + head.Subject.ToString("0000");

            if (head.GroupVars != null)
            {
                System.Windows.Data.Binding GVBinding = new System.Windows.Data.Binding();
                GVBinding.Source = this;
                GVBinding.NotifyOnSourceUpdated = true;
                GVBinding.Path = new PropertyPath("GVList");
                GVBinding.Mode = BindingMode.OneWay;
                listView2.SetBinding(System.Windows.Controls.ListView.ItemsSourceProperty, GVBinding);
                GVList = head.GroupVars.Values.ToList<GVEntry>();
            }
            else
                GVList = new List<GVEntry>(0);

            this.Activate();
        }
コード例 #20
0
ファイル: Window1.xaml.cs プロジェクト: DOPS-CCI/CCI_project
        private void CreateBDF_Click(object sender, RoutedEventArgs e)
        {
            bw = new BackgroundWorker();
            bw.WorkerReportsProgress = true;
            bw.WorkerSupportsCancellation = true;
            bw.DoWork+=Utilities.BuildFile;
            bw.ProgressChanged += bw_ProgressChanged;
            bw.RunWorkerCompleted += bw_RunWorkerCompleted;
            StringBuilder sb = new StringBuilder("Signal = ");
            bool plus = false;
            foreach (TabItem ti in TermsPanel.Items)
            {
                if (plus) sb.Append("+");
                Type t = ti.GetType();
                if (t == typeof(SineTab)) { sb.Append("Sine"); plus = true; }
                else if (t == typeof(ConstTab)) { sb.Append("Const"); plus = true; }
                else if (t == typeof(NoiseTab)) { sb.Append("Noise"); plus = true; }
                else if (t == typeof(AMTab)) { sb.Append("AM"); plus = true; }
                else if (t == typeof(FMTab)) { sb.Append("FM"); plus = true; }
                else if (t == typeof(SqrTab)) { sb.Append("Sqr"); plus = true; }
                else sb.Append("Error!");

            }
            foreach (EventTab ti in EventsPanel.Items)
            {
                if (!(bool)ti.SNone.IsChecked)
                {
                    if (plus) sb.Append("+");
                    if ((bool)ti.SImpulse.IsChecked) { sb.Append("Event(Impulse)"); plus = true; }
                    else if ((bool)ti.SDampedSine.IsChecked) { sb.Append("Event(DampedSine)"); plus = true; }
                    else sb.Append("Error!");
                }
            }
            if (!plus) sb.Append("None");
            parameters.LocalSubjectId = sb.ToString();
            parameters.window = this;
            parameters.directoryPath = baseDirectory.Text + folderName.Text;
            parameters.fileName = folderName.Text;

            // ***** Set up header and internal events ****** //

            Header.Header head = new Header.Header();
            parameters.head = head;
            head.SoftwareVersion = "CreateBDFFile " + Assembly.GetExecutingAssembly().GetName().Version.ToString(4);
            DateTime dt = DateTime.Now;
            head.Title = "BDF/Event/Electrode files created on " + dt.ToLongDateString();
            head.LongDescription = parameters.window.longDesc.Text;
            head.Experimenter = new List<string>(2);
            head.Experimenter.Add("James E. Lenz");
            head.Experimenter.Add(Environment.UserName);
            head.Status = parameters.nBits;
            head.Date = dt.ToString("dd.MM.yy");
            head.Time = dt.ToString("HH.mm.ss");
            head.Subject = 0;
            head.Agent = 0;
            head.Technician = new List<string>(1);
            head.Technician.Add(Environment.UserName);
            head.OtherSessionInfo = head.OtherExperimentInfo = null;
            head.BDFFile = parameters.fileName + ".bdf";
            head.EventFile = parameters.fileName + ".evt";
            head.ElectrodeFile = parameters.fileName + ".etr";
            head.GroupVars = new GroupVarDictionary.GroupVarDictionary();
            head.Events = new EventDictionary.EventDictionary(Convert.ToInt32(nBitsTB.Text));
            parameters.eventList = new List<Event>();
            foreach (EventTab ev in EventsPanel.Items)
            {
                EventDictionary.EventDictionaryEntry ede = new EventDictionary.EventDictionaryEntry();
                ede.ancillarySize = 0;
                ede.Description = ev.name.Text + ": " + ((bool)ev.PeriodicRB.IsChecked ? "periodic" :
                    (((bool)ev.UniformRB.IsChecked) ? "uniform" : "Gaussian") + " random");
                ede.GroupVars = new List<GroupVarDictionary.GVEntry>();
                foreach (GVEntry gv in ev.GVPanel.Items)
                {
                    GroupVarDictionary.GVEntry gve = new GroupVarDictionary.GVEntry();
                    gve.Description = gv.name.Text + ((bool)gv.Cyclic.IsChecked ? ": cyclic" : ": random") +
                        " with " + gv.N.Text + " values";
                    gve.GVValueDictionary = null;
                    head.GroupVars.Add(gv.name.Text, gve);
                    ede.GroupVars.Add(gve);
                }
                head.Events.Add(ev.name.Text, ede);
                Event newEvent = ev.createEventEntry(parameters);
                newEvent.EDEntry = ede;
                parameters.eventList.Add(newEvent);
            }

            Create.Visibility = Visibility.Collapsed;
            Cancel.Visibility = Visibility.Visible;
            Progress.Text = "Starting BDF file creation";
            Progress.Visibility = Visibility.Visible;
            Page1.IsEnabled = false;
            Page2.IsEnabled = false;
            Page2Button.IsEnabled = false;
            bw.RunWorkerAsync(parameters);
        }
 public RemovePostAndTopicAssociationCommand(Header.Header header, byte[] data) : base(header, data)
 {
 }
コード例 #22
0
        public MainWindow()
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Title = "Open Header file ...";
            dlg.DefaultExt = ".hdr"; // Default file extension
            dlg.Filter = "HDR Files (.hdr)|*.hdr"; // Filter files by extension
            dlg.InitialDirectory = Properties.Settings.Default.LastDataset;
            DialogResult result = dlg.ShowDialog();
            if (result != System.Windows.Forms.DialogResult.OK) Environment.Exit(0);

            directory = System.IO.Path.GetDirectoryName(dlg.FileName);
            Properties.Settings.Default.LastDataset = directory;
            headerFileName = System.IO.Path.GetFileNameWithoutExtension(dlg.FileName);

            CCIUtilities.Log.writeToLog("Starting PKDetectorAnalyzer " + CCIUtilities.Utilities.getVersionNumber() +
                " on " + headerFileName);

            head = (new HeaderFileReader(dlg.OpenFile())).read();

            bdf = new BDFEDFFileReader(
                new FileStream(System.IO.Path.Combine(directory, head.BDFFile),
                    FileMode.Open, FileAccess.Read));
            for (int i = 0; i < bdf.NumberOfChannels; i++) //first see if this file has standard transducer labels
                if (bdf.transducer(i) == "Analog Input Box")
                    channels.Add(new channelOptions(i, bdf.channelLabel(i))); //if it does, use them as channel choices
            if (channels.Count == 0) //if it does not, then show all channels
                for (int i = 0; i < bdf.NumberOfChannels; i++)
                    channels.Add(new channelOptions(i, bdf.channelLabel(i)));
            AnalogChannelCount = channels.Count;

            OpenPCommand.InputGestures.Add(
                new KeyGesture(Key.O, ModifierKeys.Control | ModifierKeys.Shift, "Ctrl+Shift+O"));
            SavePCommand.InputGestures.Add(
                new KeyGesture(Key.S, ModifierKeys.Control, "Crtl+S"));
            ProcessCommand.InputGestures.Add(
                new KeyGesture(Key.P, ModifierKeys.Control, "Crtl+P"));
            ExitCommand.InputGestures.Add(new KeyGesture(Key.Q, ModifierKeys.Control, "Crtl+Q"));

            InitializeComponent();

            //***** Set up menu commands and short cuts

            CommandBinding cbOpenP = new CommandBinding(OpenPCommand, cbOpen_Execute, cbOpen_CanExecute);
            this.CommandBindings.Add(cbOpenP);

            CommandBinding cbSaveP = new CommandBinding(SavePCommand, cbSave_Execute, validParams_CanExecute);
            this.CommandBindings.Add(cbSaveP);

            CommandBinding cbProcess = new CommandBinding(ProcessCommand, ProcessChannels_Click, validParams_CanExecute);
            this.CommandBindings.Add(cbProcess);

            CommandBinding cbExit = new CommandBinding(ExitCommand, Quit_Click, cbExit_CanExecute);
            this.CommandBindings.Add(cbExit);

            //***** Set up defaults and other housekeeping

            Title = headerFileName;
            TitleLine.Text = directory + System.IO.Path.DirectorySeparatorChar + headerFileName;
            FNExtension.Text = "PKDetection";
            DataContext = this;

            ChannelItem ci = new ChannelItem(this);
            ChannelEntries.Items.Add(ci);
            ci.Channel.SelectedIndex = 0;
            Process.IsEnabled = true; //have to reenable here -- like checkError(); values are guarenteed valid however

            this.Activate();
        }