public void enviarDatos(int Tiempo) { for (int i = 0; i < 12; i++) { //limpiar el puerto PortAccess.Output(ADRESS, 0); PortAccess.Output(ADRESS, 1); //MessageBox.Show("DATO " + 1); PortAccess.Output(ADRESS, 3); //MessageBox.Show("RELOJ " + 3); //Console.Write("1\t"); Thread.Sleep(Tiempo); for (int j = 0; j < 12; j++) { PortAccess.Output(ADRESS, tablero[i, j]); //MessageBox.Show("DATO " + tablero[i, j]); PortAccess.Output(ADRESS, tablero[i, j] + 2); //MessageBox.Show("RELOJ " + tablero[i, j] + 2); //Console.Write(tablero[i, j] + "\t"); Thread.Sleep(Tiempo); } PortAccess.Output(ADRESS, 0); //MessageBox.Show("DATO " + 0); PortAccess.Output(ADRESS, 2); Thread.Sleep(Tiempo); //MessageBox.Show("RELOJ " + 2); //MessageBox.Show("FILA " + i); //Console.WriteLine("0"); //Console.WriteLine(""); } }
public void Output() { PortAccess.Output(PORT888, D0 + D1 * 2 + D2 * 4 + D3 * 8 + D4 * 16 + D5 * 32 + D6 * 64 + D7 * 128); PortAccess.Output(PORT890, STROBE + AUTOFEED * 2 + INIT * 4 + SELECT_IN * 8); }
private void Start() { if (Options.recordEEG) { PortAccess.Output(Port.port[0], Trig.startRecording); Debug.Log("sending ready signal to amplifiers..."); } if (!socket.isConnected()) { socket.connect(host, port); Debug.Log("Connecting to " + host + ":" + port); } if (socket.isConnected()) { Debug.Log("Connected."); hdr = socket.getHeader(); bufferConnected = true; } FRAME = 0; TRIAL = 0; BLOCK = 0; trial = 0; state = State.BlockRest; }
static void Main() { Console.WriteLine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); PortAccess access = new PortAccess(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); }
private void Reset_DS() // Makes all the data pins low so the LED's turned off { using (StreamWriter sw = new StreamWriter(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "report.log"), true, Encoding.UTF8)) { sw.WriteLine("RST IN: " + DateTime.Now.Ticks.ToString()); sw.Close(); } PortAccess.Output(adress, 0); Thread.Sleep(1000); }
/////////////////////////////////////////////////////// MISC. METHODS // ___ _ ___ _ ___ _ ___ _ ___ _ //[(_)] |=| [(_)] |=| [(_)] |=| [(_)] |=| [(_)] |=| // '-` |_| '-` |_| '-` |_| '-` |_| '-` |_| ///mmm/ / /mmm/ / /mmm/ / /mmm/ / /mmm/ / // |____________|____________|____________|____________| // | | | // ___ \_ ___ \_ ___ \_ // [(_)] |=| [(_)] |=| [(_)] |=| // '-` |_| '-` |_| '-` |_| // /mmm/ /mmm/ /mmm/ private void SendParallel(int FRAME, int TRIGGER, int ADDRESS) { if (FRAME <= Frames.trigger) { PortAccess.Output(ADDRESS, TRIGGER); } else { PortAccess.Output(ADDRESS, 0); } }
private void RunTrialRest() { if (timeElapsed < Seconds.trigger) { PortAccess.Output(Port.port[0], Trig.restTrial); } if (timeElapsed > Seconds.trialRest) { state = State.Trial; startTime = Time.time; } }
private void updateSerialState() { string win = PortAccess.Open_Serial("COM1"); if (win == PortAccess.OPENED) { this.state.Text = "Connecté"; } else { this.state.Text = win; } }
void count_binary(object o1, EventArgs e1) //Makes the leds counting in binary form { if (i < 256) { PortAccess.Output(adress, i); i += 1; } else { ((System.Windows.Forms.Timer)o1).Stop(); ((System.Windows.Forms.Timer)o1).Tick -= new EventHandler(count_binary); } }
void dance_LEDs(object o2, EventArgs e2) //Gives a motion to the LEDs { if (j < 9) { switch (j) { case 0: PortAccess.Output(888, 24); break; case 1: PortAccess.Output(888, 36); break; case 2: PortAccess.Output(888, 66); break; case 3: PortAccess.Output(888, 129); break; case 4: PortAccess.Output(888, 0); break; case 5: PortAccess.Output(888, 129); break; case 6: PortAccess.Output(888, 195); break; case 7: PortAccess.Output(888, 231); break; case 8: PortAccess.Output(888, 255); break; } } else { ((System.Windows.Forms.Timer)o2).Stop(); ((System.Windows.Forms.Timer)o2).Tick -= new EventHandler(dance_LEDs); } j += 1; }
private void OnEnable() { // Reset position PortAccess.Output(Port.port[1], 0); transform.position = Vector3.zero; // Test if (manager.TRIAL >= N.trialsBlock) { cursor.sprite = manager.CursorCol[manager.taskType]; compass.SetActive(true); } hit = 0; xMov = zMov = 0; evaluated = false; }
private void RunTrial() { if (timeElapsed < Seconds.trigger) { PortAccess.Output(Port.port[0], trialTrig); } if (TRIAL < N.trialsBlock) { if (timeElapsed > Seconds.training) { trainingCue.SetActive(false); EndTrial(); PortAccess.Output(Port.port[0], Trig.stopAnalysis); } } else { if (All(evaluated)) { for (int i = 0; i < N.players; i++) { evaluated[i] = false; } target.SetActive(false); state = State.Feedback; startTime = Time.time; PortAccess.Output(Port.port[0], Trig.stopAnalysis); } else if (socket != null && bufferConnected) { hdr = socket.getHeader(); nSample = hdr.nSamples; if (lastSample < 0) { lastSample = nSample; } if (lastSample != nSample) { movement = socket.getFloatData(nSample - 2, nSample - 1); lastSample = nSample; } } } }
private void QuitGame() { PortAccess.Output(Port.port[0], Trig.initAnalysis); if (bufferConnected) { socket.disconnect(); bufferConnected = false; } #if UNITY_EDITOR // Application.Quit() does not work in the editor so // UnityEditor.EditorApplication.isPlaying need to be set to false to end the game UnityEditor.EditorApplication.isPlaying = false; #else Application.Quit(); #endif }
static void Forward(int t, int layers) { for (int i = 0; i < layers; i++) { for (int j = 0; j < _LayerStep; j++) { PortAccess.Output(888, 2); // 1 decimal = 0001 binary. This will set D0 to high System.Threading.Thread.Sleep(t); // delay PortAccess.Output(888, 3); // 2 decimal = 0010 binary. This will set D1 to high System.Threading.Thread.Sleep(t); // delay PortAccess.Output(888, 1); // 4 decimal = 0100 binary. This will set D2 to high System.Threading.Thread.Sleep(t); // delay PortAccess.Output(888, 0); // 8 decimal = 1000 binary. This will set D3 to high System.Threading.Thread.Sleep(t); // delay } } _MovedLayers = _MovedLayers - layers; }
public System.Collections.IEnumerator QuitGame() { Debug.Log("quitting"); if (isStopRecording) { PortAccess.Output(Port.port[0], Trig.stopRecording); } // write frameData float[,] dataToPut = new float[frameData.TRIAL.Count, 9]; // messes with frame rate - so put outside main frame loop for (int i = 0; i < frameData.TRIAL.Count; i++) { dataToPut[i, 0] = frameData.TRIAL[i]; dataToPut[i, 1] = frameData.FRAME[i]; dataToPut[i, 2] = frameData.trigger[i]; dataToPut[i, 3] = frameData.deltaTime[i]; dataToPut[i, 4] = frameData.lum[i]; dataToPut[i, 5] = frameData.cmFrames[i]; dataToPut[i, 6] = frameData.cmStimulus[i]; dataToPut[i, 7] = frameData.cmTrigger[i]; dataToPut[i, 8] = frameData.letterClassified[i]; } Write2D(dataToPut, outFileFD, ""); #if UNITY_EDITOR // Application.Quit() does not work in the editor so // UnityEditor.EditorApplication.isPlaying need to be set to false to end the game UnityEditor.EditorApplication.isPlaying = false; #else Application.Quit(); #endif yield return(new WaitForSeconds(0.1f)); // to ensure trigger is sent, probably not necessary }
private void button1_Click_1(object sender, EventArgs e) { int contador = 0; int datoX = 0; int datoY = 0; for (int i = 0; i < 8; i++) { for (int j = 0; j < 16; j++) { if (matrizBotones[i, j].getEstado()) { datoX = matrizBotones[i, j].getCx(); datoY = matrizBotones[i, j].getCy(); //Console.WriteLine("x: " + matrizBotones[i, j].getCx() + " y: " + matrizBotones[i, j].getCy()); MessageBox.Show("x: " + datoX + " y: " + datoY); switch (contador) { case 0: PortAccess.Output(888, datoX); Thread.Sleep(100); contador = 1; break; case 1: PortAccess.Output(888, datoY); Thread.Sleep(1000); contador = 0; break; } } else { } } } }
private void Apply() { model.Id++; PortAccess.write_serial(model.GenerateFGLModel(companyName.Text, model.Id)); }
private void Input() { int i = 0; i = PortAccess.Input(PORT888); if (i == 128) { D7 = 1; } else { D7 = 0; } if (i == 64) { D6 = 1; } else { D6 = 0; } if (i == 32) { D5 = 1; } else { D5 = 0; } if (i == 16) { D4 = 1; } else { D4 = 0; } if (i == 8) { D3 = 1; } else { D3 = 0; } if (i == 4) { D2 = 1; } else { D2 = 0; } if (i == 2) { D1 = 1; } else { D1 = 0; } if (i == 1) { D0 = 1; } else { D0 = 0; } i = PortAccess.Input(PORT898); if (i == 128) { BUSY = 0; } else { BUSY = 1; } if (i == 64) { ACK = 0; } else { ACK = 1; } if (i == 32) { PE = 0; } else { PE = 1; } if (i == 16) { SLCT = 0; } else { SLCT = 1; } if (i == 8) { ERROR = 0; } else { ERROR = 1; } i = PortAccess.Input(PORT890); if (i == 8) { SELECT_IN = 1; } else { SELECT_IN = 0; } if (i == 4) { INIT = 1; } else { INIT = 0; } if (i == 2) { AUTOFEED = 1; } else { AUTOFEED = 0; } if (i == 1) { STROBE = 1; } else { STROBE = 0; } }
private void ControlLoop() { if (TRIAL == -1) { InitialiseTrial(); return; } switch (isViewingChat) { case false: if (FRAME == Frames.trial & !isPaused) { InitialiseTrial(); } if (FRAME < Frames.trial) { switch (CM.stimulus[FRAME]) { case 1: // CUE if (isVirtualPhotodiode) { SendParallel(CM.frames[FRAME], target[TRIAL] + 1, Port.port[0]); // works if frame rate locked } else if (!isVirtualPhotodiode) { if (isTestingNow) { SendParallel(CM.frames[FRAME], 29, Port.port[0]); // works if frame rate locked } else if (!isTestingNow) { SendParallel(CM.frames[FRAME], target[TRIAL] + 1, Port.port[0]); // works if frame rate locked } } DisplayCue(); /////////////////////////////////////////////// BCI if (isTestingNow) { RealtimeFeedback(); } break; case 2: // FLICKER if (isVirtualPhotodiode) { SendParallel(CM.frames[FRAME], target[TRIAL] + 101, Port.port[0]); // works if frame rate locked } else if (!isVirtualPhotodiode) { if (isTestingNow) { SendParallel(CM.frames[FRAME], 129, Port.port[0]); // works if frame rate locked } else if (!isTestingNow) { SendParallel(CM.frames[FRAME], target[TRIAL] + 101, Port.port[0]); // works if frame rate locked } } DisplayFlicker(); break; } // frameData frameData.TRIAL.Add((float)TRIAL); // try multi-threading the save in future frameData.FRAME.Add(FRAME); frameData.trigger.Add(PortAccess.Input(Port.port[0])); frameData.deltaTime.Add(Time.deltaTime); frameData.lum.Add(LUM); frameData.cmFrames.Add((float)CM.frames[FRAME]); frameData.cmStimulus.Add((float)CM.stimulus[FRAME]); frameData.cmTrigger.Add((float)CM.trigger[FRAME]); frameData.letterClassified.Add(letterClassified); // frameData.flipTimeStart, frameData.flipTimeStop FRAME++; if (isTrain & TRIAL < nTrialsTrain & FRAME == 72) // 0.5 s completed, skip ahead to flicker, assumes 144 Hz { FRAME = 108; } } break; case true: DisplayChat(); break; } }
float chatDefaultTime = 2; // for virtualPhotodiode to exit screen private void DisplayChat() { PortAccess.Output(Port.port[0], Trig.viewingChat); // send trigger for viewing chat // CheckMessages MessagingInterfaceIDX(); // P2 STATUS switch ((int)statusR) { case CODE.spelling: chatIcon.SetActive(true); break; case CODE.viewingChat: chatIcon.SetActive(false); break; default: chatIcon.SetActive(false); break; } // end chat if (isFakeSwitch) // for testing - set automatically to true if isVirtualPhotodiode { if (Time.time - chatStartTime > chatDefaultTime) { isViewingChat = false; } } else if (!isVirtualPhotodiode) { GetClassifiedLetter(); if (letterClassified == CODE.enterKey) // enter artifact key { isViewingChat = false; } } // clean up if (isViewingChat == false) { Debug.Log("sw " + sw.ElapsedMilliseconds); PortAccess.Output(Port.port[0], 0); // try to reset port if (isPhotoDiode == true) { PHOTODIODE.enabled = true; } // GameObjects if (isVirtualPhotodiode) { CUE.SetActive(true); } BUBBLES.SetActive(false); PH.SetActive(true); LETTER.SetActive(true); STATUS.SetActive(true); outputText.enabled = true; outputWindow.SetActive(true); chatIcon.SetActive(false); letterClassified = float.NaN; // reset nSamples to avoid picking up noise trigger on the way out, and getting things out of alignment SendStatus(CODE.spelling); FRAME = Frames.trial; // advance to next trial - 28/10/2018 9:59 PM } }
private void Update() { // Write Frame Data frameData = new float[1, 16]; FRAME++; frameData[0, (int)FrameData.trial] = TRIAL + 1; frameData[0, (int)FrameData.block] = BLOCK + 1; frameData[0, (int)FrameData.frame] = FRAME; if (TRIAL == N.trialsTotal) { QuitGame(); } trigger = PortAccess.Input(Port.port[0]); timeElapsed = Time.time - startTime; switch (state) { case State.Inactive: if (!Options.recordEEG) { StartNewTrial(); } else if (trigger == 0) { StartNewTrial(); } break; case State.BlockRest: if (!UIEnd.activeSelf) { if (BLOCK != 0) { foreach (Text tt in EndText) { tt.text = "Please sit still and wait for the next block."; } } else { foreach (Text tt in EndText) { tt.text = "Please sit still and wait for the start of the experiment."; } } UIEnd.SetActive(true); startTime = Time.time; } if (BLOCK == 0 || timeElapsed > Seconds.blockRest) { if (BLOCK != 0) { foreach (Text tt in EndText) { tt.text = "BLOCK " + BLOCK.ToString() + " of " + (N.blocks - 1).ToString() + " blocks"; } } if (Input.GetKeyUp(KeyCode.Space)) { UIEnd.SetActive(false); state = State.Inactive; PortAccess.Output(Port.port[0], Trig.initAnalysis); } } break; case State.TrialRest: RunTrialRest(); break; case State.Trial: RunTrial(); break; case State.Feedback: if (timeElapsed > Seconds.feedback) { EndTrial(); } break; } frameData[0, (int)FrameData.time] = Time.time; frameData[0, (int)FrameData.trigger] = PortAccess.Input(Port.port[0]); frameData[0, (int)FrameData.state] = (int)state; for (int i = 0; i < N.players; i++) { frameData[0, i * 5 + 6] = movement[0, i]; frameData[0, i * 5 + 7] = movement[1, i]; frameData[0, i * 5 + 8] = players[i].transform.position.x; frameData[0, i * 5 + 9] = players[i].transform.position.z; frameData[0, i * 5 + 10] = players[i].hit; } Write2D(frameData, Str.frameMatrixTXT); }
public PortAccess() { PortAccess.boca_com = this; }
private void PortNumCalc() { int value = 0; if (checkBoxD0.Checked) { value += (int)Math.Pow(2, 0); LoadPict(true, pictureBoxD0); } else { LoadPict(false, pictureBoxD0); } value += 0; if (checkBoxD1.Checked) { value += (int)Math.Pow(2, 1); LoadPict(true, pictureBoxD1); } else { LoadPict(false, pictureBoxD1); } value += 0; if (checkBoxD2.Checked) { value += (int)Math.Pow(2, 2); LoadPict(true, pictureBoxD2); } else { LoadPict(false, pictureBoxD2); } value += 0; if (checkBoxD3.Checked) { value += (int)Math.Pow(2, 3); LoadPict(true, pictureBoxD3); } else { LoadPict(false, pictureBoxD3); } value += 0; if (checkBoxD4.Checked) { value += (int)Math.Pow(2, 4); LoadPict(true, pictureBoxD4); } else { LoadPict(false, pictureBoxD4); } value += 0; if (checkBoxD5.Checked) { value += (int)Math.Pow(2, 5); LoadPict(true, pictureBoxD5); } else { LoadPict(false, pictureBoxD5); } value += 0; if (checkBoxD6.Checked) { value += (int)Math.Pow(2, 6); LoadPict(true, pictureBoxD6); } else { LoadPict(false, pictureBoxD6); } value += 0; if (checkBoxD7.Checked) { value += (int)Math.Pow(2, 7); LoadPict(true, pictureBoxD7); } else { LoadPict(false, pictureBoxD7); } value += 0; PortAccess.Output(adress, value); }
void onCheckBoxClick(object sender, EventArgs e) //For checkboxes and the imageboxes you can also use a loop here { int value = 0; if (checkBox_Pin1.Checked) { value += (int)Math.Pow(2, 0); LoadNewPict_D0(); } else { LoadOldPict_D0(); } value += 0; if (checkBox_Pin2.Checked) { value += (int)Math.Pow(2, 1); LoadNewPict_D1(); } else { LoadOldPict_D1(); } value += 0; if (checkBox_Pin3.Checked) { value += (int)Math.Pow(2, 2); LoadNewPict_D2(); } else { LoadOldPict_D2(); } value += 0; if (checkBox_Pin4.Checked) { value += (int)Math.Pow(2, 3); LoadNewPict_D3(); } else { LoadOldPict_D3(); } value += 0; if (checkBox_Pin5.Checked) { value += (int)Math.Pow(2, 4); LoadNewPict_D4(); } else { LoadOldPict_D4(); } value += 0; if (checkBox_Pin6.Checked) { value += (int)Math.Pow(2, 5); LoadNewPict_D5(); } else { LoadOldPict_D5(); } value += 0; if (checkBox_Pin7.Checked) { value += (int)Math.Pow(2, 6); LoadNewPict_D6(); } else { LoadOldPict_D6(); } value += 0; if (checkBox_Pin8.Checked) { value += (int)Math.Pow(2, 7); LoadNewPict_D7(); } else { LoadOldPict_D7(); } value += 0; PortAccess.Output(adress, value); }
private void button_Send_Bits_Click(object sender, System.EventArgs e) // Sends decimal to data pins { PortAccess.Output(adress, Int32.Parse(this.textBox_byte.Text)); }
public PortAttribute(int address, PortAccess access) { Address = address; Access = access; }
private void Reset_LEDs() // Makes all the data pins low so the LED's turned off { PortAccess.Output(adress, 0); }