示例#1
0
 public Noisetag(System.IO.TextReader stimFile, UtopiaController utopiaController, GSM stimulusSequenceStack)
 {
     // global flicker stimulus sequence
     this.noisecode = StimSeq.FromString(stimFile);
     //Console.WriteLine(this.noisecode);
     //this.noisecode.convertstimSeq2int();
     //this.noisecode.setStimRate(2);
     // get the stimSeq (as int) from the noisecode
     this.stimSeq = this.convertstimSeq2int(this.noisecode);
     // utopiaController
     this.utopiaController = utopiaController;
     if (this.utopiaController == null)
     {
         // TODO [] : make a singlention for the utopia controller?
         this.utopiaController = new UtopiaController();
     }
     // stimulus state-machine stack
     // Individual stimulus-state-machines track progress in a single
     // stimulus state playback function.
     // Stack allows sequencing of sets of playback functions in loops
     if (stimulusStateMachineStack == null)
     {
         stimulusStateMachineStack = new GSM();
     }
     this.laststate    = new StimulusState(null, null, -1, false);
     this.lastrawstate = new StimulusState(null, null, -1, false);
     this.objIDs       = null;
 }
示例#2
0
        public virtual void setActiveObjIDs(int [] objIDs)
        {
            int nold = this.objIDs == null ? 0 : this.objIDs.Length;

            this.objIDs = objIDs;
            // make use last-state holder to reflect the new set active
            if (nold != this.objIDs.Length)
            {
                this.laststate = new StimulusState(null, this.objIDs, -1, false);
            }
        }
示例#3
0
        // stimulus sequence methods via the stimulus state machine stack
        public virtual bool updateStimulusState(int t = -1)
        {
            bool hasNext = this.stimulusStateMachineStack.next(t);

            if (hasNext)
            {
                this.lastrawstate = this.stimulusStateMachineStack.get();
            }
            else
            {
                this.lastrawstate = null;
                // Fire a noise-tag complete event?
            }
            return(hasNext);
        }
示例#4
0
 public void init_ss(int [][] stimSeq)
 {
     this.stimSeq = stimSeq;
     int [] objIDs = null;
     // BODGE: assume objIDs start from 1?
     if (this.stimSeq != null)
     {
         objIDs = new int[this.stimSeq[0].Length];
         for (int i = 0; i < objIDs.Length; i++)
         {
             objIDs[i] = i + 1;
         }
     }
     this.ss = new StimulusState(null, objIDs, tgtidx, sendEvents);
 }
示例#5
0
        // stimulus sequence methods via the stimulus state machine stack
        public virtual bool updateStimulusState(int t = -1)
        {
            nframe = nframe + 1;
            // only move to the next codebook entry every FramesPerCodeBit calls..
            //if (nframe % Math.Max(FRAMESPERCODEBIT,1) != 0) return true;

            bool hasNext = this.stimulusStateMachineStack.next(t);

            if (hasNext)
            {
                this.lastrawstate = this.stimulusStateMachineStack.get();
            }
            else
            {
                this.lastrawstate = null;
                // Fire a noise-tag complete event?
            }
            return(hasNext);
        }
示例#6
0
        public static void Main(string[] argv)
        {
            Noisetag nt = new Noisetag();

            if (!nt.connect())
            {
                Console.WriteLine("Error couldn't connect to hub!");
            }
            Console.WriteLine("Connected to " + nt.getHostPort());
            nt.setnumActiveObjIDs(10);
            // debug message handler : prints all new messages
            nt.addMessageHandler(newMessageHandler);
            nt.startExpt(1, 10, .1f);
            float isi       = 1.0f / 60f;
            int   nframe    = 0;
            bool  isRunning = true;

            while (isRunning)
            {
                nframe++;
                isRunning = nt.updateStimulusState(nframe);
                if (!isRunning)
                {
                    break;
                }
                StimulusState ss = nt.getStimulusState();
                if (ss.targetState >= 0)
                {
                    Console.Write(ss.targetState > 0?"*":".");
                }
                else
                {
                    Console.Write(String.Format("{0:d} ", nframe));
                }
                nt.sendStimulusState();
                int sleeptime = (int)(isi * 1000.0f);
                System.Threading.Thread.Sleep((int)(isi * 1000.0f));
            }
        }