commit a675a50cbaff14f76f4372a67cb5a559f42edcfe Author: TomSuch Date: Sun Sep 25 20:27:23 2011 +0200 FirstCommit - some correction needed diff --git a/.directory b/.directory new file mode 100644 index 0000000..06dab1c --- /dev/null +++ b/.directory @@ -0,0 +1,2 @@ +[Desktop Entry] +Icon=./.icon.png diff --git a/.icon.png b/.icon.png new file mode 100644 index 0000000..f66c374 Binary files /dev/null and b/.icon.png differ diff --git a/.project b/.project new file mode 100644 index 0000000..1489fea --- /dev/null +++ b/.project @@ -0,0 +1,9 @@ +# Gambas Project File 2.0 +# Compiled with Gambas 2.21.0 +Title=RatBox +Startup=FMain +Version=0.0.1 +Library=gb.gui +Library=gb.form +Library=gb.net +TabSize=2 diff --git a/.settings b/.settings new file mode 100644 index 0000000..56ba46e --- /dev/null +++ b/.settings @@ -0,0 +1,27 @@ +[Breakpoints] +Count=0 + +[DebugWindow] +Count=0 + +[DebugWindow/SerialPort1] +Geometry=[0,0,301,301] + +[FFind] +SearchIn="Module" +CaseSensitive=False +SearchWord=False +SearchComment=False +SearchString=True + +[OpenFile] +File[1]="FMain.form" +File[2]="FMain.class:281.0" +File[3]="Form1.form" +Active=3 +File[4]="Form1.class:8.0" +Count=4 + +[Watches] +Count=0 + diff --git a/FMain.class b/FMain.class new file mode 100644 index 0000000..b5bcea1 --- /dev/null +++ b/FMain.class @@ -0,0 +1,733 @@ +' Gambas class file +PUBLIC SysLogFile AS File +PUBLIC SysWDT AS Integer + +PUBLIC PrePocetCiklu AS Integer +PUBLIC PreCasPauza AS Integer +PUBLIC PreCasPiti AS Integer + +PUBLIC PreEaventZ1 AS Boolean +PUBLIC PreEaventZ2 AS Boolean +PUBLIC PreEaventZ3 AS Boolean +PUBLIC PreEaventZ4 AS Boolean +PUBLIC PreEaventZ5 AS Boolean +PUBLIC PreEaventZ6 AS Boolean + +PUBLIC PreEaventPotkan AS Boolean + +PUBLIC PreStop AS Boolean + +PUBLIC PreP1E AS Boolean +PUBLIC PreP2E AS Boolean +PUBLIC PreP3E AS Boolean +PUBLIC PreP4E AS Boolean +PUBLIC PreP5E AS Boolean +PUBLIC PreP6E AS Boolean + +PUBLIC PrePNE AS Boolean +PUBLIC PrePOD AS Boolean + +PUBLIC PreCnt AS Boolean +PUBLIC PreCntTmp AS Integer + + +PUBLIC VisStimIdx AS Integer +PUBLIC ExpTime0 AS Integer +PUBLIC ExpTime1 AS Integer +PUBLIC ExpTime2 AS Integer +PUBLIC ExpTime3 AS Integer +PUBLIC ExpZ AS Integer +PUBLIC ExpTimeout AS Integer +PUBLIC ExpTimeoutBuff AS Integer +PUBLIC PotkanAkceBuff AS Integer + +PUBLIC ExpLastStim AS Integer +PUBLIC ExpGenerujStimul AS Boolean +PUBLIC ExpTemp AS Integer + + +PUBLIC SUB _new() + +END + +PUBLIC SUB Form_Open() + PreStop = FALSE + SysLogFile = OPEN "/home/tomsuch/Projekty/Gambas2/RatBox/RatBox.log" FOR APPEND + SysLogWrite("Start_Systemu") + PreCasPauza = 10 + PreCasPiti = 10 + PrePocetCiklu = 10 + VisStimIdx = 1 + SysLogWrite("Pre_Pocet_Ciklu: " & PrePocetCiklu) + SysLogWrite("Pre_Cas_Piti: " & PreCasPiti) + SysLogWrite("Pre_Cas_Pauza: " & PreCasPauza) +END + +PUBLIC SUB BtnKonec_Click() + SysLogWrite("Dotaz_Ukonceni_Aplikace") + IF Message.Warning("Opravdu chcete ukoncit aplikaci ?", "NE", "ANO") = 2 THEN + SysLogWrite("Ukonceni_Behu_Aplikace") + FMain.Close + ELSE + SysLogWrite("Navrat_Do_Aplikace") + ENDIF +END + +PUBLIC SUB TimerSystime_Timer() + TxtSysTime.Text = Format$(Now, "dd.mm.yy") & " " & Format$(Now, "hh:nn:ss") + SysWDT = SysWDT + 1 + IF SysWDT = 11 THEN + WDTLooP + SysWDT = 0 + ENDIF + TxtWDT.Text = SysWDT + TxtTimeout.Text = ExpTimeoutBuff + IF SerialPort1.Status = 0 THEN TxtCommPort.BackColor = Color.Red + IF SerialPort1.Status = 1 THEN TxtCommPort.BackColor = Color.Green + IF PotkanAkceBuff = 1 THEN + CheckBox2.BackColor = Color.Green + ELSE + CheckBox2.BackColor = Color.Red + ENDIF + IF PotkanAkceBuff = 2 THEN + CheckBox3.BackColor = Color.Green + ELSE + CheckBox3.BackColor = Color.Red + ENDIF + IF PotkanAkceBuff = 4 THEN + CheckBox4.BackColor = Color.Green + ELSE + CheckBox4.BackColor = Color.Red + ENDIF + + IF PotkanAkceBuff = 8 THEN + CheckBox5.BackColor = Color.Green + ELSE + CheckBox5.BackColor = Color.Red + ENDIF + IF PotkanAkceBuff = 16 THEN + CheckBox6.BackColor = Color.Green + ELSE + CheckBox6.BackColor = Color.Red + ENDIF + IF PotkanAkceBuff = 32 THEN + CheckBox7.BackColor = Color.Green + ELSE + CheckBox7.BackColor = Color.Red + ENDIF + + + +END + +PUBLIC SUB SysLogWrite(Udalost AS String) + TxtSysLog.Text = Format$(Now, "yyyy_mm_dd") & "_" & Format$(Now, "hh:nn:ss") & "_" & udalost & Chr(13) & TxtSysLog.Text + PRINT #SysLogFile, Format$(Now, "yyyy_mm_dd") & "_" & Format$(Now, "hh:nn:ss") & "_" & udalost +END + +PUBLIC SUB WDTLooP() + IF TxtWDT.Background = Color.Green THEN + TxtWDT.Background = Color.Background + ELSE + TxtWDT.Background = Color.Green + ENDIF + IF PreCnt = TRUE THEN + PreCntTmp = PreCntTmp + 1 + ENDIF +END + +PUBLIC SUB BtnPrePocetCikluNastav_Click() + PrePocetCiklu = TxtPrePocetCiklu.Text + SysLogWrite("Pre_Pocet_Ciklu: " & PrePocetCiklu) +END + +PUBLIC SUB BtnPreNastavCasPiti_Click() + PreCasPiti = TxtPreTmrPiti.Text + SysLogWrite("Pre_Cas_Piti: " & PreCasPiti) +END + +PUBLIC SUB BtnPreNastavCasPauza_Click() + PreCasPauza = TxtPreTmrPauza.Text + SysLogWrite("Pre_Cas_Pauza: " & PreCasPauza) +END + +PUBLIC SUB BtnPreNastavNastaveniPitek_Click() +DIM StrTmp AS String + PreP1E = CheckBoxPrePE.Value + PreP2E = CheckBoxPrePE2.Value + PreP3E = CheckBoxPrePE3.Value + PreP4E = CheckBoxPrePE4.Value + PreP5E = CheckBoxPrePE5.Value + PreP6E = CheckBoxPrePE6.Value + PrePNE = CheckBoxPrePP.Value + PrePOD = CheckBoxPrePP2.Value + IF PreP1E = TRUE THEN StrTmp = StrTmp & "1" + IF PreP1E = FALSE THEN StrTmp = StrTmp & "0" + IF PreP2E = TRUE THEN StrTmp = StrTmp & "1" + IF PreP2E = FALSE THEN StrTmp = StrTmp & "0" + IF PreP3E = TRUE THEN StrTmp = StrTmp & "1" + IF PreP3E = FALSE THEN StrTmp = StrTmp & "0" + IF PreP4E = TRUE THEN StrTmp = StrTmp & "1" + IF PreP4E = FALSE THEN StrTmp = StrTmp & "0" + IF PreP5E = TRUE THEN StrTmp = StrTmp & "1" + IF PreP5E = FALSE THEN StrTmp = StrTmp & "0" + IF PreP6E = TRUE THEN StrTmp = StrTmp & "1" + IF PreP6E = FALSE THEN StrTmp = StrTmp & "0" + StrTmp = StrTmp & "_" + IF PrePOD = TRUE THEN StrTmp = StrTmp & "1" + IF PrePOD = FALSE THEN StrTmp = StrTmp & "0" + IF PrePNE = TRUE THEN StrTmp = StrTmp & "1" + IF PrePNE = FALSE THEN StrTmp = StrTmp & "0" + SysLogWrite("Pre_N_Pitka: " & StrTmp) +END + +PUBLIC SUB BtnSZ_Click() + PreEaventPotkan = TRUE + PreEaventZ1 = TRUE +END + +PUBLIC SUB BtnSZ2_Click() + PreEaventPotkan = TRUE + PreEaventZ2 = TRUE +END + +PUBLIC SUB BtnSZ3_Click() + PreEaventPotkan = TRUE + PreEaventZ3 = TRUE +END + +PUBLIC SUB BtnSZ4_Click() + PreEaventPotkan = TRUE + PreEaventZ4 = TRUE +END + +PUBLIC SUB BtnSZ5_Click() + PreEaventPotkan = TRUE + PreEaventZ5 = TRUE +END + +PUBLIC SUB BtnSZ6_Click() + PreEaventPotkan = TRUE + PreEaventZ6 = TRUE +END + +PUBLIC SUB BtnPreStart_Click() +DIM PotkanAkceTMP AS Integer +DIM PocetCiklu AS Integer + PocetCiklu = 0 + IF CheckBoxExpVisEn.Value = TRUE THEN + SysLogWrite("Experiment_START") + VisStimIdx = 0 + ExpLastStim = 1 + SysLogWrite("Experiment_RESET_APARATURY") + IF SerialPort1.Status = 1 THEN + SysLogWrite("Experiment_SYSTEM_BOX_OK") + WRITE #SerialPort1, "S0" + WRITE #SerialPort1, "s0" + WRITE #SerialPort1, "d" + ELSE + SysLogWrite("Experiment_SYSTEM_BOX_CHYBA") + ENDIF + BtnExperimentNastavTime0_Click + ExperimentBtnNastavTime1_Click + ExperimentBtnTimeout_Click + ExperimentBtnTime3_Click + ExperimentNastavBtnTime2_Click + WHILE ((PocetCiklu < PrePocetCiklu) AND (PreStop = FALSE)) + EXPSTART: + IF (ExpChkNahoda.Value = FALSE) AND (ExpChkNeopakovat.Value = FALSE) THEN + NextVisStim: + IF VisStimIdx = 6 THEN VisStimIdx = 0 + VisStimIdx = VisStimIdx + 1 + IF (VisStimIdx = 1) AND (ExpChkSTime.Value = FALSE) THEN GOTO NextVisStim + IF (VisStimIdx = 2) AND (ExpChkSTime2.Value = FALSE) THEN GOTO NextVisStim + IF (VisStimIdx = 3) AND (ExpChkSTime3.Value = FALSE) THEN GOTO NextVisStim + IF (VisStimIdx = 4) AND (ExpChkSTime4.Value = FALSE) THEN GOTO NextVisStim + IF (VisStimIdx = 5) AND (ExpChkSTime5.Value = FALSE) THEN GOTO NextVisStim + IF (VisStimIdx = 6) AND (ExpChkSTime6.Value = FALSE) THEN GOTO NextVisStim + ENDIF + IF ExpChkNahoda.Value = TRUE THEN + IF ExpChkNeopakovat.Value = TRUE THEN + WHILE ExpLastStim = VisStimIdx + RNDNOOPAK: + SysLogWrite("Experiment_Vybirani_nahodneho_stimulu") + VisStimIdx = Round(Rnd(1, 6), 0) + SysLogWrite("Experiment_Vybran_Stimul: " & VisStimIdx) + IF (VisStimIdx = 1) AND (ExpChkSTime.Value = FALSE) THEN GOTO RNDNOOPAK + IF (VisStimIdx = 2) AND (ExpChkSTime2.Value = FALSE) THEN GOTO RNDNOOPAK + IF (VisStimIdx = 3) AND (ExpChkSTime3.Value = FALSE) THEN GOTO RNDNOOPAK + IF (VisStimIdx = 4) AND (ExpChkSTime4.Value = FALSE) THEN GOTO RNDNOOPAK + IF (VisStimIdx = 5) AND (ExpChkSTime5.Value = FALSE) THEN GOTO RNDNOOPAK + IF (VisStimIdx = 6) AND (ExpChkSTime6.Value = FALSE) THEN GOTO RNDNOOPAK + WEND + ExpLastStim = VisStimIdx + ELSE + RNDOPAK: + SysLogWrite("Experiment_Vybirani_nahodneho_stimulu") + VisStimIdx = Round(Rnd(1, 6), 0) + SysLogWrite("Experiment_Vybran_Stimul: " & VisStimIdx) + IF (VisStimIdx = 1) AND (ExpChkSTime.Value = FALSE) THEN GOTO RNDOPAK + IF (VisStimIdx = 2) AND (ExpChkSTime2.Value = FALSE) THEN GOTO RNDOPAK + IF (VisStimIdx = 3) AND (ExpChkSTime3.Value = FALSE) THEN GOTO RNDOPAK + IF (VisStimIdx = 4) AND (ExpChkSTime4.Value = FALSE) THEN GOTO RNDOPAK + IF (VisStimIdx = 5) AND (ExpChkSTime5.Value = FALSE) THEN GOTO RNDOPAK + IF (VisStimIdx = 6) AND (ExpChkSTime6.Value = FALSE) THEN GOTO RNDOPAK + ENDIF + ENDIF + WAIT + 'ExperimentPicture.Picture = Picture.Load(Str(VisStimIdx) & ".bmp") + SysLogWrite("Experiment_ZOBR_STIMUL: " & VisStimIdx) + IF (VisStimIdx < 1) OR (VisStimIdx > 6) THEN GOTO EXPSTART + ExperimentPicture.Picture = Picture.Load("/home/tomsuch/" & Str(VisStimIdx) & ".bmp") + PictureBox1.Picture = Picture.Load("/home/tomsuch/" & Str(VisStimIdx) & ".bmp")) + Label23.Text = VisStimIdx + SysLogWrite("Experiment_PAUZA_1") + IF ExpChkEnableTiming.Value = FALSE THEN + ExperimentTxtTime0.BackColor = Color.Green + PreCntTmp = 0 + PreCnt = TRUE + WHILE PreCntTmp < ExpTime0 + WAIT + TxtPreWDTTmr.Text = PreCntTmp + WAIT + WEND + ExperimentTxtTime0.BackColor = Color.White + ELSE + IF VisStimIdx = 1 THEN ExpTemp = Val(ExpTxtS1Time.Text) + IF VisStimIdx = 2 THEN ExpTemp = Val(ExpTxtS2Time.Text) + IF VisStimIdx = 3 THEN ExpTemp = Val(ExpTxtS3Time.Text) + IF VisStimIdx = 4 THEN ExpTemp = Val(ExpTxtS4Time.Text) + IF VisStimIdx = 5 THEN ExpTemp = Val(ExpTxtS5Time.Text) + IF VisStimIdx = 6 THEN ExpTemp = Val(ExpTxtS6Time.Text) + IF VisStimIdx = 1 THEN ExpTxtS1Time.BackColor = Color.Green + IF VisStimIdx = 2 THEN ExpTxtS2Time.BackColor = Color.Green + IF VisStimIdx = 3 THEN ExpTxtS3Time.BackColor = Color.Green + IF VisStimIdx = 4 THEN ExpTxtS4Time.BackColor = Color.Green + IF VisStimIdx = 5 THEN ExpTxtS5Time.BackColor = Color.Green + IF VisStimIdx = 6 THEN ExpTxtS6Time.BackColor = Color.Green + PreCntTmp = 0 + PreCnt = TRUE + WHILE PreCntTmp < ExpTemp + WAIT + TxtPreWDTTmr.Text = PreCntTmp + WAIT + WEND + IF VisStimIdx = 1 THEN ExpTxtS1Time.BackColor = Color.White + IF VisStimIdx = 2 THEN ExpTxtS2Time.BackColor = Color.White + IF VisStimIdx = 3 THEN ExpTxtS3Time.BackColor = Color.White + IF VisStimIdx = 4 THEN ExpTxtS4Time.BackColor = Color.White + IF VisStimIdx = 5 THEN ExpTxtS5Time.BackColor = Color.White + IF VisStimIdx = 6 THEN ExpTxtS6Time.BackColor = Color.White + ENDIF + TxtPreWDTTmr.Text = 0 + IF ExperimentCheckZhasniStimul.Value = TRUE THEN + SysLogWrite("Experiment_ZHAS_STIMUL") + ExperimentPicture.Picture = Picture.Load("/home/tomsuch/clear.bmp") + Form1.PictureBox1.Picture = Picture.Load("/home/tomsuch/clear.bmp") + WAIT + ENDIF + WAIT + IF CheckBox1.Value = TRUE THEN + ExperimentTxtTime1.BackColor = Color.Green + SysLogWrite("Experiment_PAUZA_2") + PreCntTmp = 0 + PreCnt = TRUE + WHILE PreCntTmp < ExpTime1 + WAIT + TxtPreWDTTmr.Text = PreCntTmp + WAIT + WEND + TxtPreWDTTmr.Text = 0 + ExperimentTxtTime1.BackColor = Color.White + ENDIF + LabelPre6.BackColor = Color.Green + SysLogWrite("Experiment_DVERE_OTEVIRANI") + IF SerialPort1.Status = 1 THEN + SysLogWrite("Experiment_SYSTEM_BOX_OK") + WRITE #SerialPort1, "D" + ELSE + SysLogWrite("Experiment_SYSTEM_BOX_CHYBA") + ENDIF + PreCntTmp = 0 + PreCnt = TRUE + WHILE PreCntTmp < 3 + WAIT + TxtPreWDTTmr.Text = PreCntTmp + WAIT + WEND + TxtPreWDTTmr.Text = 0 + SysLogWrite("Experiment_DVERE_OTEVRENY") + LabelPre6.BackColor = Color.Background + ExperimentTxtTimeout.BackColor = Color.Green + LabelPre7.BackColor = Color.Green + ExpZ = 0 + ExpTmrTimeout.Enabled = FALSE + ExpTimeoutBuff = 0 + ExpTmrTimeout.Enabled = TRUE + SysLogWrite("Experiment_START_TIMEOUT_COUNTER") + SysLogWrite("Experiment_POTKAN_CEKANI") + WHILE (ExpZ < 1) AND (ExpTimeoutBuff < ExpTimeout) + IF PotkanAkceBuff = 1 THEN ExpZ = 1 + IF PotkanAkceBuff = 2 THEN ExpZ = 2 + IF PotkanAkceBuff = 4 THEN ExpZ = 3 + IF PotkanAkceBuff = 8 THEN ExpZ = 4 + IF PotkanAkceBuff = 16 THEN ExpZ = 5 + IF PotkanAkceBuff = 32 THEN ExpZ = 6 + WAIT + WEND + IF ExpTimeoutBuff >= ExpTimeout THEN SysLogWrite("Experiment_POTKAN_TIMEOUT") + IF (expz > 0) AND (ExpZ < 7) THEN SysLogWrite("Experiment_POTKAN_AKCE") + ExpTmrTimeout.Enabled = FALSE + LabelPre7.BackColor = Color.Background + ExperimentTxtTimeout.BackColor = Color.White + IF VisStimIdx = ExpZ THEN + Label17.BackColor = Color.Green + LabelPre8.BackColor = Color.Green + SysLogWrite("Experiment_POTKAN_OK_" & VisStimIdx) + IF SerialPort1.Status = 1 THEN + SysLogWrite("Experiment_SYSTEM_BOX_OK") + IF VisStimIdx = 1 THEN WRITE #SerialPort1, "s1" + IF VisStimIdx = 2 THEN WRITE #SerialPort1, "s2" + IF VisStimIdx = 3 THEN WRITE #SerialPort1, "s3" + IF VisStimIdx = 4 THEN WRITE #SerialPort1, "S1" + IF VisStimIdx = 5 THEN WRITE #SerialPort1, "S2" + IF VisStimIdx = 6 THEN WRITE #SerialPort1, "S3" + ELSE + SysLogWrite("Experiment_SYSTEM_BOX_CHYBA") + ENDIF + PreCntTmp = 0 + PreCnt = TRUE + WHILE PreCntTmp < 2 + WAIT + TxtPreWDTTmr.Text = PreCntTmp + WAIT + WEND + TxtPreWDTTmr.Text = 0 + Label17.BackColor = Color.Background + LabelPre8.BackColor = Color.Background + ExperimentTxtTime3.BackColor = Color.Green + SysLogWrite("Experiment_PAUZA_3") + PreCntTmp = 0 + PreCnt = TRUE + WHILE PreCntTmp < ExpTime3 + WAIT + TxtPreWDTTmr.Text = PreCntTmp + WAIT + WEND + TxtPreWDTTmr.Text = 0 + ExperimentTxtTime3.BackColor = Color.White + ELSE + IF exptimeoutbuff < ExpTimeout THEN SysLogWrite("Experiment_POTKAN_KO_" & ExpZ) + ENDIF + Label20.BackColor = Color.Green + SysLogWrite("Experiment_RESET_APARATURY") + IF SerialPort1.status = 1 THEN + SysLogWrite("Experiment_SYSTEM_BOX_OK") + WRITE #SerialPort1, "S0" + WRITE #SerialPort1, "s0" + WRITE #SerialPort1, "d" + ELSE + SysLogWrite("Experiment_SYSTEM_BOX_CHYBA") + ENDIF + PreCntTmp = 0 + PreCnt = TRUE + WHILE PreCntTmp < 3 + WAIT + TxtPreWDTTmr.Text = PreCntTmp + WAIT + WEND + TxtPreWDTTmr.Text = 0 + Label20.BackColor = Color.Background + IF ExperimentChkPausa2.Value = TRUE THEN + ExperimentTxtTime2.BackColor = Color.Green + SysLogWrite("Experiment_PAUZA_4") + PreCntTmp = 0 + PreCnt = TRUE + WHILE PreCntTmp < 3 + WAIT + TxtPreWDTTmr.Text = PreCntTmp + WAIT + WEND + TxtPreWDTTmr.Text = 0 + ExperimentTxtTime2.BackColor = Color.White + ENDIF + + IF VisStimIdx > 6 THEN VisStimIdx = 1 + WAIT + PocetCiklu = PocetCiklu + 1 + WEND + SysLogWrite("Experiment_KONEC") + ExperimentPicture.Picture = Picture.Load("/home/tomsuch/clear.bmp") + +ELSE + + PrePocetCiklu = TxtPrePocetCiklu.Text + SysLogWrite("Pre_Pocet_Ciklu: " & PrePocetCiklu) + PreCasPiti = TxtPreTmrPiti.Text + SysLogWrite("Pre_Cas_Piti: " & PreCasPiti) + PreCasPauza = TxtPreTmrPauza.Text + SysLogWrite("Pre_Cas_Pauza: " & PreCasPauza) +BtnPreNastavNastaveniPitek_Click + + + SysLogWrite("Pre_START") + + + +WHILE ((PocetCiklu < PrePocetCiklu) AND (PreStop = FALSE)) + +PocetCiklu = PocetCiklu + 1 + + + + SysLogWrite("Pre_Ciklus:" & PocetCiklu) + SysLogWrite("Pre_Otevreni_Dvirek") + + LabelPre.Background = Color.Green + + PreCntTmp = 0 + PreCnt = TRUE + + WHILE PreCntTmp < 3 + WAIT + TxtPreWDTTmr.Text = PreCntTmp + WAIT + WEND + TxtPreWDTTmr.Text = 0 + + + + LabelPre.Background = Color.Background + + SysLogWrite("Pre_CEKANI_POTKAN") + + LabelPre2.Background = Color.Green + + WHILE PreEaventPotkan = FALSE + WAIT + WEND + + + + PreEaventPotkan = FALSE + LabelPre2.Background = Color.Background + +PotkanAkceTMP = AkcePotkan() + +SysLogWrite("Pre_Potkan_Akce:" & PotkanAkceTMP) + +SysLogWrite("Pre_Nastavuji_Pitko:" & PotkanAkceTMP) + +LabelPre3.Background = Color.Green + + PreCntTmp = 0 + PreCnt = TRUE + + + WHILE PreCntTmp < 3 + WAIT + TxtPreWDTTmr.Text = PreCntTmp + WAIT + WEND + TxtPreWDTTmr.Text = 0 + +LabelPre3.Background = Color.Background + +SysLogWrite("Pre_Piti") + +TxtPreTmrPiti.Background = Color.Green + + PreCntTmp = 0 + PreCnt = TRUE + WHILE PreCntTmp < PreCasPiti + WAIT + TxtPreWDTTmr.Text = PreCntTmp + WAIT + WEND + TxtPreWDTTmr.Text = 0 + +TxtPreTmrPiti.Background = Color.White + +LabelPre5.Background = Color.Green + +SysLogWrite("Pre_Zavreni_Dveri") + + PreCntTmp = 0 + PreCnt = TRUE + WHILE PreCntTmp < 3 + WAIT + TxtPreWDTTmr.Text = PreCntTmp + WAIT + WEND + TxtPreWDTTmr.Text = 0 + +LabelPre5.Background = Color.Background + +LabelPre4.Background = Color.Green +SysLogWrite("Pre_Parkuji_Pitka") + PreCntTmp = 0 + PreCnt = TRUE + WHILE PreCntTmp < 3 + WAIT + TxtPreWDTTmr.Text = PreCntTmp + WAIT + WEND + TxtPreWDTTmr.Text = 0 + +LabelPre4.Background = Color.Background + +SysLogWrite("Pre_Pauza") + +TxtPreTmrPauza.Background = Color.Green + + PreCntTmp = 0 + PreCnt = TRUE + WHILE PreCntTmp < PreCasPauza + WAIT + TxtPreWDTTmr.Text = PreCntTmp + WAIT + WEND + TxtPreWDTTmr.Text = 0 + +TxtPreTmrPauza.Background = Color.White + +WEND + +IF PreStop = TRUE THEN PreStop = FALSE + +SysLogWrite("Pre_KONEC") + + +ENDIF + +END + +FUNCTION AkcePotkan() AS Integer + IF PreEaventZ1 = TRUE THEN + RETURN 1 + PreEaventZ1 = FALSE + ENDIF + IF PreEaventZ2 = TRUE THEN + RETURN 2 + PreEaventZ2 = FALSE + ENDIF + IF PreEaventZ3 = TRUE THEN + RETURN 3 + PreEaventZ3 = FALSE + ENDIF + IF PreEaventZ4 = TRUE THEN + RETURN 4 + PreEaventZ4 = FALSE + ENDIF + IF PreEaventZ5 = TRUE THEN + RETURN 5 + PreEaventZ5 = FALSE + ENDIF + IF PreEaventZ6 = TRUE THEN + RETURN 6 + PreEaventZ6 = FALSE + ENDIF +END + +PUBLIC SUB BtnPreStop_Click() + PreStop = TRUE + SysLogWrite("Pre_Uzivatlske_Ukonceni") +END + +PUBLIC SUB BtnExperimentNastavTime0_Click() + ExpTime0 = Val(ExperimentTxtTime0.Text) + SysLogWrite("Exp_Cas_Krok_0: " & ExpTime0) +END + +PUBLIC SUB ExperimentBtnNastavTime1_Click() + ExpTime1 = Val(ExperimentTxtTime1.Text) + SysLogWrite("Exp_Cas_Krok_1: " & ExpTime1) +END + +PUBLIC SUB BtnSZ12_Click() + ExpZ = 1 +END + +PUBLIC SUB BtnSZ7_Click() + ExpZ = 2 +END + +PUBLIC SUB BtnSZ8_Click() + ExpZ = 3 +END + +PUBLIC SUB BtnSZ11_Click() + ExpZ = 4 +END + +PUBLIC SUB BtnSZ9_Click() + ExpZ = 5 +END + +PUBLIC SUB BtnSZ10_Click() + ExpZ = 6 +END + +PUBLIC SUB ExperimentBtnTime3_Click() + ExpTime3 = Val(ExperimentTxtTime3.Text) + SysLogWrite("Exp_Cas_Krok_OK: " & ExpTime3) +END + +PUBLIC SUB ExperimentNastavBtnTime2_Click() + ExpTime2 = Val(ExperimentTxtTime2.Text) + SysLogWrite("Exp_Cas_Krok_POSLEDNI: " & ExpTime2) +END + +PUBLIC SUB ExperimentBtnTimeout_Click() + ExpTimeout = Val(ExperimentTxtTimeout.Text) + SysLogWrite("Exp_Cas_Timeout: " & ExpTimeout) +END + +PUBLIC SUB ExpTmrTimeout_Timer() + WAIT + ExpTimeoutBuff = ExpTimeoutBuff + 1 +END + +PUBLIC SUB BtnPripoj_Click() + IF SerialPort1.status = 0 THEN + SerialPort1.PortName = TxtCommPort.Text + SerialPort1.Speed = 9600 + SerialPort1.DataBits = 8 + SerialPort1.StopBits = 1 + SerialPort1.FlowControl = FALSE + SerialPort1.Open + FINALLY + CATCH + Message("CHYBA BOXU / PORTU") + ELSE + SerialPort1.Close + ENDIF +END + +PUBLIC SUB SerialPort1_Read() +DIM InByte AS Byte +DIM i AS Integer +DIM x AS String +DIM s AS String + READ #SerialPort1, InByte + WAIT + PotkanAkceBuff = inByte + WAIT +END + +PUBLIC SUB Cekej(InTime AS Integer) + +END + +PUBLIC SUB FMain_KeyPress() +SELECT Key.Code +CASE Key.F1 +Message("TEST") +END SELECT +END + +PUBLIC SUB Button1_Click() + + Form1.Visible = TRUE + +END diff --git a/FMain.form b/FMain.form new file mode 100644 index 0000000..9ce43f1 --- /dev/null +++ b/FMain.form @@ -0,0 +1,674 @@ +# Gambas Form File 2.0 + +{ Form Form + Move(0,0,1246,770) + #(Scaled) = False + Text = ("") + Border = Window.None + FullScreen = True + { BtnKonec Button + Move(1162,7,70,21) + Text = ("KONEC") + } + { TxtSysTime TextBox + Move(1015,7,140,21) + Text = ("") + Alignment = Align.Center + } + { TimerSystime #Timer + #X = 973 + #Y = 7 + Enabled = True + Delay = 100 + } + { TxtSysLog TextArea + Move(714,49,518,301) + Text = ("") + ReadOnly = True + Wrap = True + ScrollBar = Scroll.Vertical + } + { TxtWDT TextBox + Move(630,7,49,21) + Enabled = False + Text = ("WDT") + Alignment = Align.Center + } + { LabelPre Label + Move(14,161,77,35) + ToolTip = ("Otevreni dvirek") + Text = ("OTEVRENI\nDVERI") + Alignment = Align.Center + } + { LabelPre2 Label + Move(175,154,63,63) + ToolTip = ("Ceka se az potkan zacumakuje") + Text = ("CEKANI\nAKCE\nPOTKAN") + Alignment = Align.Center + } + { LabelPreFrm2 Label + Move(245,175,70,14) + Text = ("------------>") + Alignment = Align.Center + } + { LabelPre3 Label + Move(322,154,84,63) + ToolTip = ("Pitko se nastavi do pozice zacumakovani") + Text = ("NASTAVENI\nPITKA") + Alignment = Align.Center + } + { LabelPreFrm3 Label + Move(574,238,28,21) + Text = (" |\n") + Alignment = Align.Center + } + { TxtPreTmrPiti TextBox + Move(553,168,70,28) + Text = ("10") + Alignment = Align.Center + } + { Label1 Label + Move(490,168,56,28) + Text = ("Cas piti") + } + { Label2 Label + Move(637,168,28,28) + Text = ("sec") + } + { BtnPreNastavCasPiti Button + Move(553,203,70,7) + Text = ("NASTAV") + } + { Label3 Label + Move(217,294,77,28) + Text = ("Cas pauzy") + } + { Label4 Label + Move(385,294,28,28) + Text = ("sec") + } + { TxtPreTmrPauza TextBox + Move(301,294,70,28) + Text = ("10") + Alignment = Align.Center + } + { BtnPreNastavCasPauza Button + Move(301,329,70,7) + Text = ("NASTAV") + } + { LabelPreFrm5 Label + Move(441,301,91,14) + Text = ("<--------------------\n") + Alignment = Align.Center + } + { CheckBoxPrePP CheckBox + Move(315,63,105,42) + ToolTip = ("Vypropaguje nastaveni pitek do ciklu") + Text = ("NASTAVENI\nPITEK") + } + { LabelPreFrm1 Label + Move(98,175,70,14) + Text = ("------------>") + Alignment = Align.Center + } + { LabelPreFrm7 Label + Move(413,175,70,14) + Text = ("------------>") + Alignment = Align.Center + } + { LabelPre4 Label + Move(560,273,63,35) + ToolTip = ("Zavreni dveri") + Text = ("ZAVRI\nDVERE") + Alignment = Align.Center + } + { LabelPre5 Label + Move(560,315,63,35) + ToolTip = ("Nastaveni pitek do vychozich pozic") + Text = ("NAVRAT\nPITEK") + Alignment = Align.Center + } + { LabelPreFrm4 Label + Move(133,301,70,14) + Text = ("<------------") + Alignment = Align.Center + } + { LabelPreFrm6 Label + Move(42,203,28,42) + Text = ("|\n|\n") + Alignment = Align.Center + } + { LabelPreFrm8 Label + Move(350,105,28,42) + Text = (" |\n |\n") + Alignment = Align.Center + } + { CheckBoxPrePE CheckBox + Move(21,56,42,21) + ToolTip = ("Povoli pouziti pitka") + Text = ("P1") + } + { CheckBoxPrePE2 CheckBox + Move(21,84,42,21) + ToolTip = ("Povoli pouziti pitka") + Text = ("P2") + } + { CheckBoxPrePE3 CheckBox + Move(21,112,42,21) + ToolTip = ("Povoli pouziti pitka") + Text = ("P3") + } + { CheckBoxPrePE4 CheckBox + Move(77,56,42,21) + ToolTip = ("Povoli pouziti pitka") + Text = ("P4") + } + { CheckBoxPrePE5 CheckBox + Move(77,84,42,21) + ToolTip = ("Povoli pouziti pitka") + Text = ("P5") + } + { CheckBoxPrePE6 CheckBox + Move(77,112,42,21) + ToolTip = ("Povoli pouziti pitka") + Text = ("P6") + } + { CheckBoxPrePP2 CheckBox + Move(154,63,119,28) + ToolTip = ("Zakaze opakovani stejnych pitek 2x po sobe") + Text = ("NEPOAKOVAT") + } + { LabelPreFrm9 Label + Move(119,70,35,14) + Text = ("---") + Alignment = Align.Center + } + { LabelPreFrm10 Label + Move(280,70,35,14) + Text = ("---") + Alignment = Align.Center + } + { BtnPreStart Button + Move(560,70,84,28) + Text = ("START") + } + { BtnPreStop Button + Move(560,105,84,28) + Text = ("STOP") + } + { BtnSZ Button + Move(147,224,35,21) + ToolTip = ("Simuluje zacumakovani potkana") + Text = ("Z1") + } + { BtnSZ2 Button + Move(189,224,35,21) + ToolTip = ("Simuluje zacumakovani potkana") + Text = ("Z2") + } + { BtnSZ3 Button + Move(231,224,35,21) + ToolTip = ("Simuluje zacumakovani potkana") + Text = ("Z3") + } + { BtnSZ4 Button + Move(147,252,35,21) + ToolTip = ("Simuluje zacumakovani potkana") + Text = ("Z4") + } + { BtnSZ5 Button + Move(189,252,35,21) + ToolTip = ("Simuluje zacumakovani potkana") + Text = ("Z5") + } + { BtnSZ6 Button + Move(231,252,35,21) + ToolTip = ("Simuluje zacumakovani potkana") + Text = ("Z6") + } + { TxtPrePocetCiklu TextBox + Move(462,84,84,21) + Text = ("10") + Alignment = Align.Center + } + { BtnPrePocetCikluNastav Button + Move(462,112,84,21) + Text = ("NASTAV") + } + { Label5 Label + Move(462,63,84,14) + Text = ("Pocet ciklu:") + Alignment = Align.Center + } + { BtnPreNastavNastaveniPitek Button + Move(133,105,210,21) + Text = ("NASTAV NASTAVENI PITEK") + } + { TxtPreWDTTmr TextBox + Move(399,7,70,21) + Text = ("0") + Alignment = Align.Center + ReadOnly = True + } + { Label6 Label + Move(322,14,70,14) + Text = ("Casovac") + Alignment = Align.Center + } + { CheckBoxExpVisEn CheckBox + Move(14,378,147,21) + ToolTip = ("Zapne zapojeni\nvisualni stimulace do\nexperimentu") + Text = ("VISUALNI STIMUL") + } + { TxtExpPauza TextBox + Move(28,280,84,21) + Text = ("10") + Alignment = Align.Center + } + { CheckBoxExpPauzaEn CheckBox + Move(14,252,105,21) + ToolTip = ("Zapne pauzu mezi visualni stimulaci\na experimentem.\nZa jakou dobu se zacne smicka\nod zobrazeni stimulacniho obrazce") + Text = ("Pauza:") + } + { BtnExpNastavPauzu Button + Move(28,308,84,21) + Text = ("NASTAV") + } + { Label7 Label + Move(119,280,35,21) + Text = ("sec") + } + { ExperimentPicture PictureBox + Move(14,434,161,126) + Background = &H0000FF& + Stretch = True + Alignment = Align.Center + } + { ExperimentTxtTime0 TextBox + Move(224,448,84,21) + Text = ("10") + Alignment = Align.Center + } + { BtnExperimentNastavTime0 Button + Move(224,476,84,21) + Text = ("NASTAV") + } + { Label8 Label + Move(182,441,35,28) + Text = ("--->") + Alignment = Align.Center + } + { ExperimentCheckZhasniStimul CheckBox + Move(357,434,70,42) + Text = ("Vypni\nstimul") + } + { Label9 Label + Move(315,448,35,14) + Text = ("--->") + Alignment = Align.Center + } + { ExperimentTxtTime1 TextBox + Move(476,448,84,21) + Text = ("10") + Alignment = Align.Center + } + { Label10 Label + Move(434,441,28,28) + Text = ("--->") + } + { ExperimentBtnNastavTime1 Button + Move(476,476,84,14) + Text = ("NASTAV") + } + { CheckBox1 CheckBox + Move(469,427,98,14) + Text = ("ZAPNUTO") + } + { Label12 Label + Move(203,504,112,56) + Text = ("CAS\nZOBRAZENI\nSTIMULU") + Alignment = Align.Center + } + { Label13 Label + Move(476,504,84,56) + Text = ("CAS\nBEZ\nSTIMULU") + Alignment = Align.Center + } + { LabelPre6 Label + Move(609,406,77,35) + ToolTip = ("Otevreni dvirek") + Text = ("OTEVRENI\nDVERI") + Alignment = Align.Center + } + { Label11 Label + Move(574,441,28,28) + Text = ("--->") + } + { ExperimentTxtTimeout TextBox + Move(609,448,77,21) + Text = ("30") + Alignment = Align.Center + } + { ExperimentBtnTimeout Button + Move(609,476,77,21) + Text = ("NASTAV") + } + { Label14 Label + Move(602,504,91,49) + Text = ("CAS\nNA\nREAKCI") + Alignment = Align.Center + } + { LabelPre7 Label + Move(742,427,63,63) + ToolTip = ("Ceka se az potkan zacumakuje") + Text = ("CEKANI\nAKCE\nPOTKAN") + Alignment = Align.Center + } + { Label15 Label + Move(700,441,28,28) + Text = ("--->") + } + { BtnSZ7 Button + Move(728,525,35,21) + ToolTip = ("Simuluje zacumakovani potkana") + Text = ("S2") + } + { BtnSZ8 Button + Move(728,553,35,21) + ToolTip = ("Simuluje zacumakovani potkana") + Text = ("S3") + } + { BtnSZ9 Button + Move(777,525,35,21) + ToolTip = ("Simuluje zacumakovani potkana") + Text = ("S5") + } + { BtnSZ10 Button + Move(777,553,35,21) + ToolTip = ("Simuluje zacumakovani potkana") + Text = ("S6") + } + { BtnSZ11 Button + Move(777,497,35,21) + ToolTip = ("Simuluje zacumakovani potkana") + Text = ("S4") + } + { BtnSZ12 Button + Move(728,497,35,21) + ToolTip = ("Simuluje zacumakovani potkana") + Text = ("S1") + } + { Label16 Label + Move(819,448,196,21) + Text = ("-----------------------------------------------") + } + { LabelPreFrm11 Label + Move(994,469,28,21) + Text = (" |\n") + Alignment = Align.Center + } + { LabelPreFrm12 Label + Move(875,469,28,21) + Text = (" |\n") + Alignment = Align.Center + } + { LabelPreFrm13 Label + Move(938,469,28,21) + Text = (" |\n") + Alignment = Align.Center + } + { Label17 Label + Move(868,497,42,21) + Text = ("OK") + Alignment = Align.Center + } + { Label18 Label + Move(938,497,35,21) + Text = ("KO") + Alignment = Align.Center + } + { Label19 Label + Move(973,497,70,21) + Text = ("TIMEOUT") + Alignment = Align.Center + } + { Label20 Label + Move(609,651,70,21) + Text = ("RESET") + Alignment = Align.Center + } + { LabelPreFrm14 Label + Move(994,525,28,140) + Text = ("|\n|\n|\n|\n|\n|\n|\n|\n") + Alignment = Align.Center + } + { Label21 Label + Move(679,651,329,14) + Text = ("--------------------------------------------------------------------------------") + Alignment = Align.Center + } + { LabelPreFrm15 Label + Move(945,518,28,140) + Text = ("|\n|\n|\n|\n|\n|\n|") + Alignment = Align.Center + } + { Label22 Label + Move(91,651,511,21) + Text = ("-----------------------------------------------------------------------------------------------------------------------------") + Alignment = Align.Center + } + { ExperimentChkPausa2 CheckBox + Move(49,567,98,14) + Text = ("ZAPNUTO") + } + { ExperimentTxtTime2 TextBox + Move(49,588,98,21) + Text = ("10") + Alignment = Align.Center + } + { LabelPreFrm16 Label + Move(98,644,14,21) + Text = (" |\n") + Alignment = Align.Center + } + { ExperimentNastavBtnTime2 Button + Move(49,616,98,14) + Text = ("NASTAV") + } + { LabelPre8 Label + Move(847,553,84,35) + ToolTip = ("Pitko se nastavi do pozice zacumakovani") + Text = ("NASTAVENI\nPITKA") + Alignment = Align.Center + } + { LabelPreFrm17 Label + Move(875,525,28,21) + Text = (" |\n") + Alignment = Align.Center + } + { ExperimentTxtTime3 TextBox + Move(840,595,91,21) + Text = ("10") + Alignment = Align.Center + } + { ExperimentBtnTime3 Button + Move(840,623,91,7) + Text = ("NASTAV") + } + { Label23 Label + Move(175,371,35,28) + Font = Font["Bold"] + Text = ("0") + Alignment = Align.Center + } + { ExpTmrTimeout #Timer + #X = 924 + #Y = 7 + } + { TxtTimeout TextBox + Move(553,7,70,21) + Text = ("0") + Alignment = Align.Center + } + { Label24 Label + Move(483,14,56,14) + Text = ("Timeout") + } + { TxtCommPort TextBox + Move(14,7,140,21) + Text = ("/dev/ttyUSB0") + } + { BtnPripoj Button + Move(161,7,140,21) + Text = ("Pripoj BOX") + } + { SerialPort1 #SerialPort + #X = 875 + #Y = 7 + } + { Separator1 Separator + Move(14,35,1218,7) + Foreground = &H000000& + } + { Separator2 Separator + Move(14,357,1218,21) + } + { Separator3 Separator + Move(700,49,7,301) + } + { CheckBox2 CheckBox + Move(700,7,21,21) + Text = ("CheckBox2") + } + { CheckBox3 CheckBox + Move(728,7,21,21) + Text = ("CheckBox3") + } + { CheckBox4 CheckBox + Move(756,7,21,21) + Text = ("CheckBox4") + } + { CheckBox5 CheckBox + Move(784,7,21,21) + Text = ("CheckBox5") + } + { CheckBox6 CheckBox + Move(812,7,21,21) + Text = ("CheckBox6") + } + { CheckBox7 CheckBox + Move(840,7,21,21) + Text = ("CheckBox7") + } + { Label25 Label + Move(161,588,105,56) + Text = ("PAUZA\nMEZI\nZOBRAZENIMI") + Alignment = Align.Center + } + { Label26 Label + Move(1057,434,35,35) + Text = ("1") + Alignment = Align.Center + } + { Label27 Label + Move(1057,476,35,35) + Text = ("3") + Alignment = Align.Center + } + { Label28 Label + Move(1057,518,35,35) + Text = ("3") + Alignment = Align.Center + } + { Label29 Label + Move(1057,560,35,35) + Text = ("4") + Alignment = Align.Center + } + { Label30 Label + Move(1057,602,35,35) + Text = ("5") + Alignment = Align.Center + } + { Label31 Label + Move(1057,644,35,35) + Text = ("6") + Alignment = Align.Center + } + { ExpTxtS1Time TextBox + Move(1099,434,70,28) + Text = ("10") + Alignment = Align.Center + } + { ExpTxtS2Time TextBox + Move(1099,476,70,28) + Text = ("10") + Alignment = Align.Center + } + { ExpTxtS3Time TextBox + Move(1099,518,70,28) + Text = ("10") + Alignment = Align.Center + } + { ExpTxtS4Time TextBox + Move(1099,560,70,28) + Text = ("10") + Alignment = Align.Center + } + { ExpTxtS5Time TextBox + Move(1099,602,70,28) + Text = ("10") + Alignment = Align.Center + } + { ExpTxtS6Time TextBox + Move(1099,644,70,28) + Text = ("10") + Alignment = Align.Center + } + { ExpChkSTime CheckBox + Move(1176,434,56,28) + Text = ("ZAP") + Value = CheckBox.True + } + { ExpChkEnableTiming CheckBox + Move(1064,399,154,28) + Text = ("Zapnout Casovani") + } + { ExpChkSTime2 CheckBox + Move(1176,476,56,28) + Text = ("ZAP") + Value = CheckBox.True + } + { ExpChkSTime3 CheckBox + Move(1176,518,56,28) + Text = ("ZAP") + Value = CheckBox.True + } + { ExpChkSTime4 CheckBox + Move(1176,560,56,28) + Text = ("ZAP") + Value = CheckBox.True + } + { ExpChkSTime5 CheckBox + Move(1176,602,56,28) + Text = ("ZAP") + Value = CheckBox.True + } + { ExpChkSTime6 CheckBox + Move(1176,644,56,28) + Text = ("ZAP") + Value = CheckBox.True + } + { ExpChkNahoda CheckBox + Move(14,406,98,21) + Text = ("NAHODA") + } + { ExpChkNeopakovat CheckBox + Move(119,406,119,21) + Text = ("NEOPAKOVAT") + } + { Button1 Button + Move(721,385,119,28) + Text = ("Button1") + } +} diff --git a/Form1.class b/Form1.class new file mode 100644 index 0000000..3a1d8b4 --- /dev/null +++ b/Form1.class @@ -0,0 +1,14 @@ +' Gambas class file + + +PUBLIC SUB PictureBox1_DblClick() + + + +END + +PUBLIC SUB PictureBox1_MouseDown() + + + +END