void Update()
    {
        //increment elapsedTime for Timeout
        elapsedTime += Time.deltaTime;

        //save position data
        if (gameController.fs != null)
        {
            if (trigger)
            {
                // send parallel port
                if (GameController.instance.parallelPortAddr != -1)
                {
                    ParallelPort.Out32(GameController.instance.parallelPortAddr, triggerValue);
                    ParallelPort.Out32(GameController.instance.parallelPortAddr, 0);
                }
                gameController.fs.WriteLine("{0} {1:F8} {2:F2} {3:F2} {4:F2}",
                                            triggerValue,
                                            Time.deltaTime,
                                            robot.transform.position.x,
                                            robot.transform.position.z,
                                            robot.transform.eulerAngles.y);
                trigger = false;
            }
            else
            {
                gameController.fs.WriteLine("     {0:F8} {1:F2} {2:F2} {3:F2}",
                                            Time.deltaTime,
                                            robot.transform.position.x,
                                            robot.transform.position.z,
                                            robot.transform.eulerAngles.y);
            }
        }
    }
Example #2
0
        /// <summary>
        /// Init with custom experiment design parameters
        /// </summary>
        /// <param name="extype"></param>
        /// <param name="expara"></param>
        /// <param name="cond"></param>
        /// <param name="block"></param>
        /// <param name="trial"></param>
        /// <param name="stimuli"></param>
        /// <param name="brestT"></param>
        /// <param name="trestT"></param>
        /// <param name="srestT"></param>
        /// <param name="preT"></param>
        /// <param name="durT"></param>
        /// <param name="posT"></param>
        /// <param name="bgcolor"></param>
        /// <param name="length"></param>
        public SLExperiment(ExType[] extype, ExPara[] expara, SLInterpolation[] cond, int block, int trial, int[] stimuli, float brestT, float trestT, float srestT, float preT, float durT, float posT, Color bgcolor, int length)
        {
            Extype = new List <KeyValuePair <string, int> >();
            Cond   = new List <SLKeyValuePair <string, int, SLInterpolation> >();

            Exdesign = new ExDesign(extype, expara, cond, block, trial, stimuli, brestT, trestT, srestT, preT, durT, posT, bgcolor);
            Flow     = new FlowControl();
            PPort    = new ParallelPort();
            Rand     = new SLRandom(length);
        }
Example #3
0
 private void numericUpDown1_ValueChanged_1(object sender, EventArgs e)
 {
     value = System.Convert.ToDouble(numericUpDown1.Value);
     if (PCon == true)
     {
         ParallelPort.Output(0x378, System.Convert.ToInt16(value / System.Convert.ToDouble(PCMaxPsi.Value) * 256 * 2));
         //ParallelPort.Output(0x378, System.Convert.ToInt16(value/12.5*256));
         cur.Text    = System.Convert.ToString(value);
         pBar1.Value = System.Convert.ToInt16(value * 4);
     }
 }
Example #4
0
        public static int WriteData(int portaddress, int A, int RW, int port, int reg, double percentage)
        {
            int  clock = 0, outvalue = 0;
            long value = 0;
            int  port2 = portnumconv(port);
            int  data2 = voltageconv(percentage);

            ParallelPort.Output(portaddress, 2); //sets SYNC to HIGH, clears previous data

            System.Threading.Thread.Sleep(1);

            ParallelPort.Output(portaddress, 0); //sets SYNC to LOW (falling edge starts input sequence)

            value += A;

            value  = value << 1;
            value += RW;

            value  = value << 6;
            value += port2;

            value  = value << 2;
            value += reg;

            value  = value << 14;
            value += data2;

            for (int i = 0; i < 24; i++)
            {
                outvalue = (int)(value & (1 << (24 - i)));
                outvalue = outvalue >> (24 - i);
                outvalue = outvalue << 2;

                clock     = 1;
                outvalue += clock;                          //xor them to write the clock in the string bit
                ParallelPort.Output(portaddress, outvalue); //put the value on the port


                System.Threading.Thread.Sleep(1);

                outvalue -= clock;
                ParallelPort.Output(portaddress, outvalue);     //falling edge of the clock
            }

            ParallelPort.Output(portaddress, 2); //sets SYNC to HIGH, clears previous data

            return(0);
        }
Example #5
0
    void Update()
    {
        //increment elapsedTime for Timeout
        elapsedTime += Time.deltaTime;

        //determine if trail complete
        float angle = Vector3.Angle(robot.transform.forward, startWaypoint.forward);

        angle = Mathf.Abs(angle);

        if ((angle > 70) && inTrial)
        {
            inTrial = false;
            CompleteTrial();
        }

        //save position data
        if (gameController.fs != null)
        {
            if (trigger)
            {
                // send parallel port
                Debug.Log(triggerValue);
                if (GameController.instance.parallelPortAddr != -1)
                {
                    ParallelPort.TryOut32(GameController.instance.parallelPortAddr, triggerValue);
                    ParallelPort.TryOut32(GameController.instance.parallelPortAddr, 0);
                }
                gameController.fs.WriteLine("{0} {1:F8} {2:F2} {3:F2} {4:F2} {5:F2} {6:F2}",
                                            triggerValue,
                                            Time.deltaTime,
                                            robot.transform.position.x,
                                            robot.transform.position.z,
                                            robot.transform.eulerAngles.y);
                trigger = false;
            }
            else
            {
                gameController.fs.WriteLine("     {0:F8} {1:F2} {2:F2} {3:F2} {4:F2} {5:F2} ",
                                            Time.deltaTime,
                                            robot.transform.position.x,
                                            robot.transform.position.z,
                                            robot.transform.eulerAngles.y);
            }
        }
    }
Example #6
0
    public void OnParallelTestClick()
    {
        try{
            int addr = int.Parse(parallelPortField.text, System.Globalization.NumberStyles.HexNumber);

            if (parallelflip)
            {
                ParallelPort.TryOut32(addr, 255);
            }
            else
            {
                ParallelPort.TryOut32(addr, 0);
            }
            parallelflip = !parallelflip;
            parallelPortField.image.color = Color.green;
        } catch (System.Exception e) {
            experimentStatus = e.ToString();
            parallelPortField.image.color = Color.red;
        }
    }
Example #7
0
 private void btnOnOff_Click(object sender, EventArgs e)
 {
     if (PCon == false)
     {
         ParallelPort.Output(0x378, System.Convert.ToInt16(value / System.Convert.ToDouble(PCMaxPsi.Value) * 256 * 2));
         btnOnOff.BackColor = Color.Transparent;
         btnOnOff.Text      = "Turn Off";
         pBar1.Value        = System.Convert.ToInt16(value * 4);
         cur.Text           = System.Convert.ToString(value);
         PCon = true;
     }
     else
     {
         ParallelPort.Output(0x378, 0);
         btnOnOff.BackColor = Color.Red;
         btnOnOff.Text      = "Turn On";
         pBar1.Value        = 0;
         cur.Text           = "0";
         PCon = false;
     }
 }
Example #8
0
 private void btnExit_Click(object sender, EventArgs e)
 {
     ParallelPort.Output(0x378, 0);
     Application.Exit();
 }
Example #9
0
 private void Form1_FormClosing()
 {
     ParallelPort.Output(0x378, 0);
 }
Example #10
0
 private void Form1_Load(object sender, EventArgs e)
 {
     ParallelPort.Output(0x378, 0);
 }
Example #11
0
 /// <summary>
 /// Encode Common Grating Parameters in MarkerHeader
 /// </summary>
 /// <param name="PPort"></param>
 public void Encode(ParallelPort PPort)
 {
     PPort.MarkerEncode((int)Math.Floor(tf * 100.0));
     PPort.MarkerEncode((int)Math.Floor(sf * 100.0));
     PPort.MarkerEncode((int)Math.Floor(sphase * 100.0));
     PPort.MarkerEncode((int)Math.Floor(BasePara.orientation * 100.0));
     PPort.MarkerEncode((int)Math.Floor(BasePara.direction * 100.0));
     PPort.MarkerEncode((int)Math.Floor(luminance * 100.0));
     PPort.MarkerEncode((int)Math.Floor(contrast * 100.0));
     PPort.MarkerEncode((int)Math.Floor((BasePara.center.X + 60.0f) * 100.0));
     PPort.MarkerEncode((int)Math.Floor((BasePara.center.Y + 60.0f) * 100.0));
     PPort.MarkerEncode((int)Math.Floor(BasePara.diameter * 100.0));
 }
Example #12
0
 protected override void OnStart()
 {
     gpio     = new ParallelPort(dataaddress: Config.ParallelPort0);
     recorder = new RippleRecorder();
 }
Example #13
0
        /* Methode zum Auflisten der parallelen Ports des Systems */
        public static ParallelPorts EnumParallelPorts()
        {
            // ParallelPorts-Instanz für die Rückgabe erzeugen
            ParallelPorts ports = new ParallelPorts();

            // WMI-Auflistung der Objekte der Win32_ParallelPort-Klasse erzeugen
            ManagementClass            mc  = new ManagementClass("Win32_ParallelPort");
            ManagementObjectCollection moc = mc.GetInstances();

            // Die einzelnen Objekte durchgehen
            foreach (ManagementBaseObject mbo in moc)
            {
                // ParallelPort-Instanz erzeugen und initialisieren
                ParallelPort port = new ParallelPort();
                try{ port.DeviceId = (string)mbo["DeviceId"]; }
                catch {}
                try{ port.DMASupport = (bool)mbo["DMASupport"]; }
                catch {}
                try
                { port.StatusInfo = (ParallelPortStatusInfo)mbo["StatusInfo"]; }
                catch {}

                // Fähigkeiten aus dem Capabilities-Array auslesen
                try
                {
                    uint[] caps = (uint[])mbo["Capabilities"];
                    for (int i = 0; i < caps.Length; i++)
                    {
                        switch (caps[i])
                        {
                        case 2:                                  // Other
                            port.Capabilities.Other = true;
                            break;

                        case 3:                                  // XT/AT Compatible
                            port.Capabilities.XTATCompatible = true;
                            break;

                        case 4:                                  //  PS/2 Compatible
                            port.Capabilities.PS2Compatible = true;
                            break;

                        case 5:                                  //  ECP
                            port.Capabilities.ECP = true;
                            break;

                        case 6:                                  //  EPP
                            port.Capabilities.EPP = true;
                            break;

                        case 7:                                  //  PC-98
                            port.Capabilities.PC98 = true;
                            break;

                        case 8:                                  //  PC-98-Hireso
                            port.Capabilities.PC98Hireso = true;
                            break;

                        case 9:                                  //  PC-H98
                            port.Capabilities.PCH98 = true;
                            break;
                        }
                    }
                }
                catch {}

                // ParallelPort-Instanz an die Auflistung anfügen
                ports.Add(port);
            }

            // Speicher der WMI-Objekte freigeben um den Arbeitsspeicher möglichst
            // schnell zu entlasten
            moc.Dispose();
            mc.Dispose();

            // Ergebnis zurückgeben
            return(ports);
        }
Example #14
0
 /* Implementierung der Add-Methode */
 public void Add(ParallelPort port)
 {
     base.InnerList.Add(port);
 }
    void Update()
    {
        //increment elapsedTime for Timeout
        elapsedTime += Time.deltaTime;

        //save position data
        if (gameController.fs != null)
        {
            string timeNow = DateTime.Now.ToString("hhmmss.FFF");
            if (trigger)
            {
                int EL = TryGetEyelinkConnectedStatus();
                Debug.Log("EL:" + EL);

                if (EL == 2)
                {
                    if (triggerValue < 20)
                    {
                        TryEyemsg_Printf("Start Trial " + triggerValue);
                        //Debug.Log(current_time());
                    }
                    else if (triggerValue > 20 && triggerValue < 30)
                    {
                        TryEyemsg_Printf("Cue Offset " + triggerValue);
                    }
                    else if (triggerValue > 30 && triggerValue < 40)
                    {
                        TryEyemsg_Printf("End Trial " + triggerValue);
                        //close_eyelink_connection();
                    }
                    else if (triggerValue > 40 && triggerValue < 50)
                    {
                        TryEyemsg_Printf("Timeout " + triggerValue);
                        //close_eyelink_connection();
                    }
                    else if (triggerValue > 80)
                    {
                        TryEyemsg_Printf("Trigger Version " + triggerValue);
                        //close_eyelink_connection();
                    }
                }

                ParallelPort.TryOut32(GameController.instance.parallelPortAddr, triggerValue); // uncomment lines (124 and 139) to send triggers to Ripple

                // send parallel port
                //if (GameController.instance.parallelPortAddr != -1) {
                //	ParallelPort.Out32 (GameController.instance.parallelPortAddr, triggerValue);
                //	ParallelPort.Out32 (GameController.instance.parallelPortAddr, 0);
                //}

                gameController.fs.WriteLine(" {0} {1:F8} {2:F4} {3:F4} {4:F4}",
                                            triggerValue,
                                            Time.deltaTime,
                                            robot.transform.position.x,
                                            robot.transform.position.z,
                                            robot.transform.eulerAngles.y);
                trigger = false;
                ParallelPort.TryOut32(GameController.instance.parallelPortAddr, 0); // clear parallel port
            }
            else
            {
                gameController.fs.WriteLine(" {0} {1:F8} {2:F4} {3:F4} {4:F4}",
                                            0,
                                            Time.deltaTime,
                                            robot.transform.position.x,
                                            robot.transform.position.z,
                                            robot.transform.eulerAngles.y);
            }
        }

        if (showcue1)
        {
            var clone = Instantiate(cues[thisTarget], robot.transform.position + robot.transform.forward * 0.5f + robot.transform.up * 1.2f, robot.transform.rotation); // present cue (indicate location in space)
            clone.transform.localScale = new Vector3(0.5f, 0.3f, 0.005f);                                                                                               // size of central cue
            Destroy(clone, 0.02f);                                                                                                                                      // remove cue at update rate so that cue appears to follow camera
        }

        if (showcue2)
        {
            var clone = Instantiate(cues[thisTarget], robot.transform.position + robot.transform.forward * 0.5f + robot.transform.up * 1.46f, robot.transform.rotation); // present cue (indicate location in space)
            clone.transform.localScale = new Vector3(0.1f, 0.06f, 0.005f);                                                                                               // size of peripheral cue
            Destroy(clone, 0.02f);                                                                                                                                       // remove cue at update rate so that cue appears to follow camera
        }
    }
Example #16
0
        /// <summary>
        /// Init with custom experiment design parameters
        /// </summary>
        /// <param name="extype"></param>
        /// <param name="expara"></param>
        /// <param name="cond"></param>
        /// <param name="block"></param>
        /// <param name="trial"></param>
        /// <param name="stimuli"></param>
        /// <param name="brestT"></param>
        /// <param name="trestT"></param>
        /// <param name="srestT"></param>
        /// <param name="preT"></param>
        /// <param name="durT"></param>
        /// <param name="posT"></param>
        /// <param name="bgcolor"></param>
        /// <param name="length"></param>
        public SLExperiment(ExType[] extype, ExPara[] expara, SLInterpolation[] cond, int block, int trial, int[] stimuli, float brestT, float trestT, float srestT, float preT, float durT, float posT, Color bgcolor, int length)
        {
            Extype = new List<KeyValuePair<string, int>>();
            Cond = new List<SLKeyValuePair<string, int, SLInterpolation>>();

            Exdesign = new ExDesign(extype, expara, cond, block, trial, stimuli, brestT, trestT, srestT, preT, durT, posT, bgcolor);
            Flow = new FlowControl();
            PPort = new ParallelPort();
            Rand = new SLRandom(length);
        }
Example #17
0
 /// <summary>
 /// Encode Common Bar Parameters in MarkerHeader
 /// </summary>
 /// <param name="PPort"></param>
 public void Encode(ParallelPort PPort)
 {
     PPort.MarkerEncode((int)Math.Floor(height * 100.0));
     PPort.MarkerEncode((int)Math.Floor(width * 100.0));
     PPort.MarkerEncode((int)Math.Floor(BasePara.orientation * 100.0));
     PPort.MarkerEncode((int)Math.Floor(BasePara.direction * 100.0));
     PPort.MarkerEncode((int)Math.Floor(BasePara.speed * 100.0));
     PPort.MarkerEncode((int)Math.Floor((BasePara.center.X + 60.0f) * 100.0));
     PPort.MarkerEncode((int)Math.Floor((BasePara.center.Y + 60.0f) * 100.0));
 }
Example #18
0
            private void InitLCD(LCDConfiguration lcdConfig)
            {
                pp = new ParallelPort(lcdConfig.dataPins, lcdConfig.writePin, lcdConfig.readPin);
                lcdReset = new OutputPort(lcdConfig.reset, true);
                lcdCS = new OutputPort(lcdConfig.chipSelect, true);
                lcdRS = new OutputPort(lcdConfig.RS, true);
                backLight = new OutputCompare(lcdConfig.backLight, true, 2);

                lcdReset.Write(true);
                Thread.Sleep(5);
                lcdReset.Write(false);
                Thread.Sleep(5);
                lcdReset.Write(true);
                Thread.Sleep(5);

                lcdCS.Write(false);

                //************* Start Initial Sequence **********//
                WriteRegister(0x0001, 0x0100); // set SS and SM bit
                WriteRegister(0x0002, 0x0200); // set 1 line inversion
                WriteRegister(0x0003, 0x0030); // set GRAM write direction and BGR=0.
                WriteRegister(0x0004, 0x0000); // Resize register
                WriteRegister(0x0008, 0x0207); // set the back porch and front porch
                WriteRegister(0x0009, 0x0000); // set non-display area refresh cycle ISC[3:0]
                WriteRegister(0x000A, 0x0000); // FMARK function
                WriteRegister(0x000C, 0x0000); // RGB interface setting
                WriteRegister(0x000D, 0x0000); // Frame marker Position
                WriteRegister(0x000F, 0x0000); // RGB interface polarity
                //*************Power On sequence ****************//
                WriteRegister(0x0010, 0x0000); // SAP, BT[3:0], AP, DSTB, SLP, STB
                WriteRegister(0x0011, 0x0007); // DC1[2:0], DC0[2:0], VC[2:0]
                WriteRegister(0x0012, 0x0000); // VREG1OUT voltage
                WriteRegister(0x0013, 0x0000); // VDV[4:0] for VCOM amplitude
                WriteRegister(0x0007, 0x0001);
                Thread.Sleep(200); // Dis-charge capacitor power voltage
                WriteRegister(0x0010, 0x1690); // SAP, BT[3:0], AP, DSTB, SLP, STB
                WriteRegister(0x0011, 0x0227); // Set DC1[2:0], DC0[2:0], VC[2:0]
                Thread.Sleep(50); // Delay 50ms
                WriteRegister(0x0012, 0x000D); // 0012
                Thread.Sleep(50); // Delay 50ms
                WriteRegister(0x0013, 0x1200); // VDV[4:0] for VCOM amplitude
                WriteRegister(0x0029, 0x000A); // 04  VCM[5:0] for VCOMH
                WriteRegister(0x002B, 0x000D); // Set Frame Rate
                Thread.Sleep(50); // Delay 50ms
                WriteRegister(0x0020, 0x0000); // GRAM horizontal Address
                WriteRegister(0x0021, 0x0000); // GRAM Vertical Address
                // ----------- Adjust the Gamma Curve ----------//
                WriteRegister(0x0030, 0x0000);
                WriteRegister(0x0031, 0x0404);
                WriteRegister(0x0032, 0x0003);
                WriteRegister(0x0035, 0x0405);
                WriteRegister(0x0036, 0x0808);
                WriteRegister(0x0037, 0x0407);
                WriteRegister(0x0038, 0x0303);
                WriteRegister(0x0039, 0x0707);
                WriteRegister(0x003C, 0x0504);
                WriteRegister(0x003D, 0x0808);
                //------------------ Set GRAM area ---------------//
                WriteRegister(0x0050, 0x0000); // Horizontal GRAM Start Address
                WriteRegister(0x0051, 0x00EF); // Horizontal GRAM End Address
                WriteRegister(0x0052, 0x0000); // Vertical GRAM Start Address
                WriteRegister(0x0053, 0x013F); // Vertical GRAM Start Address
                WriteRegister(0x0060, 0xA700); // Gate Scan Line
                WriteRegister(0x0061, 0x0001); // NDL,VLE, REV

                WriteRegister(0x006A, 0x0000); // set scrolling line
                //-------------- Partial Display Control ---------//
                WriteRegister(0x0080, 0x0000);
                WriteRegister(0x0081, 0x0000);
                WriteRegister(0x0082, 0x0000);
                WriteRegister(0x0083, 0x0000);
                WriteRegister(0x0084, 0x0000);
                WriteRegister(0x0085, 0x0000);
                //-------------- Panel Control -------------------//
                WriteRegister(0x0090, 0x0010);
                WriteRegister(0x0092, 0x0000);
                WriteRegister(0x0007, 0x0133); // 262K color and display ON

                lcdCS.Write(true);
            }