[WARNING] WARNING: DO NOT EDIT THIS FILE DIRECTLY! Use only E-Studio to edit this file. Editing of this file from any other means is not supported and may corrupt the experiment design specification. Technical support will not be able to address any issue in regards to this file format. [Experiment] VersionMajor=1 VersionMinor=0 VersionInternal=20 VersionBuild=2 _VersionPersist=6 Root="SessionProc" Author="PST" Abstract="This experiment illustrates serial port communications. Two E-Prime\r\nmachines are connected via the serial port using a null modem \r\ncable/adaptor. At run-time, the user is asked to designate whether\r\neach machine is acting as sender or receiver (the receiving machine\r\nshould be launched first).\r\n\r\nThe sending machine sends a line of text terminated by {ENTER}. \r\nUpon receipt of a line of text, the receiving machine echos the \r\nstring to the display accompanied by a line number.\r\n\r\nBoth processes terminate upon the entering of \"end\" from the \r\nsending machine." Notes="" Creation=1008780511 [Device0] _VersionPersist=1 OpenDevice=1 Width=640 Height=480 Bpp=16 Name="Display" Class="Display" [Device1] _VersionPersist=1 OpenDevice=1 CollectionMode=1 EmulateDeviceName="" CapsLock=0 NumLock=0 Name="Keyboard" Class="Keyboard" [Device2] _VersionPersist=1 OpenDevice=1 CollectionMode=1 EmulateDeviceName="" OpenMode=0 ShowCursor=0 Name="Mouse" Class="Mouse" [Device3] _VersionPersist=1 OpenDevice=0 Channels=2 Samples=22050 Bps=16 Name="Sound" Class="Sound" [Device4] _VersionPersist=1 OpenDevice=1 Port=1 BaudRate=9600 DataBits=8 Parity=0 StopBits=0 Name="Serial" Class="Serial" [DataFile] WarnBeforeOverwrite=1 WarnIfConvertFailed=1 RemoveERecoveryFile=0 ReceiveFeedbackDuringDataFileConversion=1 LogLevel(2).Name="Block" LogLevel(3).Name="Trial" LogLevel(4).Name="SubTrial" LogLevel(5).Name="LogLevel5" LogLevel(6).Name="LogLevel6" LogLevel(7).Name="LogLevel7" LogLevel(8).Name="LogLevel8" LogLevel(9).Name="LogLevel9" LogLevel(10).Name="LogLevel10" [StartupInfo] DisplaySummary=0 UseDefaults=1 [StartupInfo1] Name="Subject" Prompt="Please enter the Subject Number (1-32767, 0=No Data Logging):" DataType=0 Enabled=1 PromptEnabled=1 Default="1" Min=0 Max=32767 PrivateFlags=268435477 PrivateInfo=1 [StartupInfo2] Name="Session" Prompt="Please enter the Session Number (0-32767):" DataType=0 Enabled=1 PromptEnabled=1 Default="1" Min=0 Max=32767 PrivateFlags=268435477 PrivateInfo=1 [StartupInfo3] Name="Group" Prompt="Please enter Subject's Group (0-32767):" DataType=0 Enabled=0 PromptEnabled=0 Default="1" Min=0 Max=32767 [StartupInfo4] Name="Name" Prompt="Please enter Subject's Name:" DataType=1 Enabled=0 PromptEnabled=0 Default="" MaxLength=255 [StartupInfo5] Name="Age" Prompt="Please enter Subject's Age (0-150):" DataType=0 Enabled=0 PromptEnabled=0 Default="0" Min=0 Max=150 [StartupInfo6] Name="Sex" Prompt="Please enter Subject's Sex:" DataType=2 Enabled=0 PromptEnabled=0 Default="male" Choice(1).Value="male" Choice(2).Value="female" [StartupInfo7] Name="Handedness" Prompt="Enter Subject's Handedness:" DataType=2 Enabled=0 PromptEnabled=0 Default="left" Choice(1).Value="left" Choice(2).Value="right" [StartupInfo8] Name="ResearcherID" Prompt="Please enter Researcher's ID:" DataType=0 Enabled=0 PromptEnabled=0 Default="1" Min=0 Max=32767 [Object0] _Version=65536 _ExtentX=2646 _ExtentY=1323 _StockProps=0 VersionMajor=1 VersionMinor=0 VersionInternal=20 VersionBuild=2 _ItemList="Intro;SendOrReceive;BlockList" _VersionPersist=1 FlowLines(0).Count=3 FlowLines(0).FlowItem(0).Name="Intro" FlowLines(0).FlowItem(1).Name="SendOrReceive" FlowLines(0).FlowItem(2).Name="BlockList" LogData=1 Name="SessionProc" TypeName="Procedure" Tag="" Notes="" [Object1] _Version=65536 _ExtentX=2646 _ExtentY=1323 _StockProps=0 VersionMajor=1 VersionMinor=0 VersionInternal=20 VersionBuild=2 Logging("OnsetDelay").Log=0 Logging("OnsetTime").Log=0 Logging("DurationError").Log=0 Logging("PreRelease").Log=0 Logging("Duration").Log=0 Logging("StartTime").Log=0 Logging("OffsetTime").Log=0 Logging("FinishTime").Log=0 Logging("TimingMode").Log=0 Logging("CustomOnsetTime").Log=0 Logging("CustomOffsetTime").Log=0 Logging("ActionDelay").Log=0 Logging("ActionTime").Log=0 Logging("TargetOffsetTime").Log=0 Logging("TargetOnsetTime").Log=0 Logging("OffsetDelay").Log=0 Logging("RTTime").Log=0 Logging("ACC").Log=0 Logging("RT").Log=0 Logging("RESP").Log=0 Logging("CRESP").Log=0 Logging("Tag").Log=0 Input(0)=!Data0 _VersionPersist=1 VersionMajor=1 VersionMinor=0 VersionInternal=20 VersionBuild=2 Text="This demonstrates implementing basic serial communications in E-Prime.\n\nYou should connect two machines via the serial port and you MUST use a NULL MODEM cable/adaptor for this example.\n\nWhich do you want this application to be sender or receiver?\n\nType 1=sender or 2=receiver." ForeColor="black" BackColor="white" BackStyle="opaque" BorderColor="black" BorderWidth="0" X="center" Y="center" Width="100%" Height="100%" XAlign="center" YAlign="center" AlignHorizontal="center" AlignVertical="center" FontName="Courier New" FontSize="18" FontBold="Yes" FontItalic="No" FontUnderline="No" FontStrikeout="No" WordWrap=1 ClearAfter="No" Duration="-1" JumpLabel="" TimingMode=0 PreRelease="0" OnsetSync=1 OffsetSync=0 Name="Intro" TypeName="TextDisplay" Tag="" Notes="" [Data0] DeviceName="Keyboard" DeviceClass="Keyboard" AllowableInput="12" CorrectInput="" TimeLimit="" MaxCount="1" InputAction=1 SyncOwnerDuration=1 Enabled=1 FlushInputBuffer="Yes" TerminationInput="" UserTag="" ResponseMode="All" ProcessBackspace="Yes" [Object2] _Version=131072 _ExtentX=2646 _ExtentY=1323 _StockProps=0 VersionMajor=1 VersionMinor=0 VersionInternal=20 VersionBuild=2 _VersionPersist=1 Code="' Pick a line of the BlockList based on the response.\n' This determines the Procedure to be run (Sender or Receiver)\nSet BlockList.Deletion = PickOne( Intro.RESP )\nBlockList.Reset\n" Name="SendOrReceive" TypeName="InLine" Tag="" Notes="" [Object3] _Version=65536 _ExtentX=2646 _ExtentY=1323 _StockProps=0 VersionMajor=1 VersionMinor=0 VersionInternal=20 VersionBuild=2 Logging("Tag").Log=0 _ItemList="SenderTrialProc;ReceiverTrialProc" _VersionPersist=1 VersionMajor=1 VersionMinor=0 VersionInternal=20 VersionBuild=2 Order=3 OrderBy=3 ResetEveryRun=0 HideLevelsWithZeroWeight=0 CycleDef=0 CycleValueSamples=0 CycleValueCondition="" ExitDef=0 ExitValueCycles=1 ExitValueSamples=1 ExitValueSeconds=0 ExitValueCondition="" LoadMethod=0 Filename="" UserAttributes=0 Attributes("Weight").DefaultValue="1" Attributes("Weight").Visible=1 Attributes("Weight").Width=75 Attributes("Weight").OrderIndex=0 Attributes("Nested").DefaultValue="" Attributes("Nested").Visible=1 Attributes("Nested").Width=75 Attributes("Nested").OrderIndex=1 Attributes("Procedure").DefaultValue="" Attributes("Procedure").Visible=1 Attributes("Procedure").Width=121 Attributes("Procedure").OrderIndex=2 Levels=2 Levels(1).ValueString="1\t\tSenderTrialProc\t" Levels(2).ValueString="1\t\tReceiverTrialProc\t" Name="BlockList" TypeName="List" Tag="" Notes="" [Object4] _Version=65536 _ExtentX=2646 _ExtentY=1323 _StockProps=0 VersionMajor=1 VersionMinor=0 VersionInternal=20 VersionBuild=2 _ItemList="Label1;Sender;SendText" _VersionPersist=1 FlowLines(0).Count=3 FlowLines(0).FlowItem(0).Name="Label1" FlowLines(0).FlowItem(1).Name="Sender" FlowLines(0).FlowItem(2).Name="SendText" LogData=1 Name="SenderTrialProc" TypeName="Procedure" Tag="" Notes="" [Object5] _Version=131072 _ExtentX=2646 _ExtentY=1323 _StockProps=0 VersionMajor=1 VersionMinor=0 VersionInternal=20 VersionBuild=2 _VersionPersist=1 Code="Dim strLine As String\nstrLine = \"\"\n\n\nstrLine = Sender.RESP\nIf Len(strLine) = 0 Then\n\tGoto Label1\nElse\n\t'Format input string to remove spaces.\n\tSerial.WriteString strLine\nEnd If\n\n\n' If we are not ending then allow another line.\n' must strip off {ENTER} from the end\nIf (Left$(strLine, Len(strLine)-Len(\"{ENTER}\")) <> \"end\") Then Goto Label1\n\n\n' Allow time for receiver to close.\nSleep 500\n" Name="SendText" TypeName="InLine" Tag="" Notes="" [Object6] _Version=65536 _ExtentX=2646 _ExtentY=1323 _StockProps=0 VersionMajor=1 VersionMinor=0 VersionInternal=20 VersionBuild=2 _ItemList="ReceiveText" _VersionPersist=1 FlowLines(0).Count=1 FlowLines(0).FlowItem(0).Name="ReceiveText" LogData=1 Name="ReceiverTrialProc" TypeName="Procedure" Tag="" Notes="" [Object7] _Version=65536 _ExtentX=2646 _ExtentY=1323 _StockProps=0 VersionMajor=1 VersionMinor=0 VersionInternal=20 VersionBuild=2 Logging("OnsetDelay").Log=0 Logging("OnsetTime").Log=0 Logging("DurationError").Log=0 Logging("PreRelease").Log=0 Logging("Duration").Log=0 Logging("StartTime").Log=0 Logging("OffsetTime").Log=0 Logging("FinishTime").Log=0 Logging("TimingMode").Log=0 Logging("CustomOnsetTime").Log=0 Logging("CustomOffsetTime").Log=0 Logging("ActionDelay").Log=0 Logging("ActionTime").Log=0 Logging("TargetOffsetTime").Log=0 Logging("TargetOnsetTime").Log=0 Logging("OffsetDelay").Log=0 Logging("RTTime").Log=0 Logging("ACC").Log=0 Logging("RT").Log=0 Logging("RESP").Log=0 Logging("CRESP").Log=0 Logging("Tag").Log=0 Input(0)=!Data1 _VersionPersist=1 VersionMajor=1 VersionMinor=0 VersionInternal=20 VersionBuild=2 Text="Please type and ENTER a line of text to send. \n\nType 'end' to instruct both apps to close.\n\n\n" ForeColor="black" BackColor="white" BackStyle="opaque" BorderColor="black" BorderWidth="0" X="center" Y="center" Width="100%" Height="100%" XAlign="center" YAlign="center" AlignHorizontal="left" AlignVertical="top" FontName="Courier New" FontSize="18" FontBold="Yes" FontItalic="No" FontUnderline="No" FontStrikeout="No" WordWrap=1 ClearAfter="No" Duration="-1" JumpLabel="" TimingMode=0 PreRelease="0" OnsetSync=1 OffsetSync=0 Name="Sender" TypeName="TextDisplay" Tag="" Notes="" [Data1] DeviceName="Keyboard" DeviceClass="Keyboard" AllowableInput="{ANY}" CorrectInput="" TimeLimit="" MaxCount="1000" InputAction=1 SyncOwnerDuration=1 Enabled=1 FlushInputBuffer="Yes" TerminationInput="{ENTER}" UserTag="" EchoClient(0)=!Data2 ResponseMode="All" ProcessBackspace="Yes" [Data2] DeviceInstance="Display" EchoDevice="Display" EchoDeviceName="Display" X="0" Y="50%" Width="100%" Height="50%" ForeColor="white" BackColor="black" BackStyle="opaque" BorderColor="black" BorderWidth="1" FontName="Courier New" FontSize="10" FontBold="No" FontItalic="No" FontUnderline="No" FontStrikeout="No" WordWrap=1 ShowPositionMarker="Yes" ClearAfter="Yes" [Object8] _Version=65536 _ExtentX=2646 _ExtentY=1323 _StockProps=0 VersionMajor=1 VersionMinor=0 VersionInternal=20 VersionBuild=2 _VersionPersist=1 Name="Label1" TypeName="Label" Tag="" Notes="" [Object9] _Version=131072 _ExtentX=2646 _ExtentY=1323 _StockProps=0 VersionMajor=1 VersionMinor=0 VersionInternal=20 VersionBuild=2 _VersionPersist=1 Code="Dim i As Long\nDim h As Long\nDim n As Long\nDim strIn As String\nDim strLine As String\nDim dc As Canvas\nDim bFullLine As Boolean\nDim bEndTrial As Boolean\n\nstrLine = \"\"\nbFullLine = False\nbEndTrial = False\ni = 1\nh = 15\t' text height\nSet dc = Display.Canvas\ndc.Clear\ndc.Text 0, 0, \"Receiving...\"\n\nDo\n\tDo\n\n\t\t' Wait for data\n\t\tDo\n\t\tLoop While Serial.InputCount = 0\n\n\t\t' Data is now available.\n\t\tn = Serial.ReadString( strIn )\n\n\t\t' concatenate the line\n\t\tstrLine = strLine & strIn\n\n\t\t' See if we have a full line yet\n\t\tIf Right$( strLine, Len(\"{ENTER}\") ) = \"{ENTER}\" Then\n\n\t\t\t' Strip off {ENTER}\n\t\t\tstrLine = Left$( strLine, Len(strLine)-Len(\"{ENTER}\"))\n\t\t\t\n\t\t\t'Replace {SPACE} with \" \"\n\t\t\tstrLine = ReplaceString (strLine, \"{SPACE}\", \" \")\n\n\t\t\t'Remove {SHIFT}\n\t\t\tstrLine = ReplaceString (strLine, \"{SHIFT}\", \"\")\n\n\t\t\t' Display the line\n\t\t\tdc.Text 0, i*h, CStr(i) & \":\" & strLine\n\n\t\t\t' Set flag to terminate app when \"end\" is entered\n\t\t\tIf strLine = \"end\" Then bEndTrial = True\n\t\t\tstrLine = \"\"\n\n\t\t\tbFullLine = True\n\t\t\ti = i + 1\n\t\t\t'Clear screen after 30 lines (30th line displayed for 1 second)\n\t\t\tIf (i > 30) Then\n\t\t\t\tSleep 1000\n\t\t\t\tdc.Clear\n\t\t\t\tdc.Text 0, 0, \"Receiving...\"\n\t\t\t\ti = 1\n\t\t\tEnd If\n\t\tEnd If\n\tLoop Until bFullLine\n\tbFullLine = False\n\nLoop While bEndTrial = False\n\n'Allow time before closing\nSleep 500" Name="ReceiveText" TypeName="InLine" Tag="" Notes="" [UserScript] Function ReplaceString(strSource As String, strFind As String, strReplace As String) As String Dim strFinal As String Dim nPosNew As Integer Dim nPos As Integer nPos = 1 Do nPosNew = InStr(nPos, strSource, strFind) If nPosNew > 0 Then 'Append up to where we found strFinal = strFinal & Mid(strSource, nPos, nPosNew - nPos) 'Append the replaced string strFinal = strFinal & strReplace 'Move past the item to find nPos = nPosNew + Len(strFind) Else 'Append the remainder of the string strFinal = strFinal & Right(strSource, Len(strSource) - (nPos - 1)) 'No more need to search nPos = 0 End If Loop Until nPos < 1 ReplaceString = strFinal End Function