compass Winspec2{ モード プログラム サイズ設定 700, 650 表示位置 右下 # 記録フォーム表示 右下 } 変数 $input 変数 $ret 変数 $cursor exe vb.exeのコンパイルをする{ ファイル一部読み込み ($input), "compass.txt", "***vb_program1***", "******" ファイル書き出し $input, "vb.txt" 実行待機して結果を取得 ($ret), _ "C:\Windows\Microsoft.NET\Framework\v4.0.30319\vbc.exe", _ "vb.txt" メッセージ $ret file.消去 "vb.txt" } exe exe サーバを起動する{ 実行 "vb.exe" } exe exe ■OVERWRITEモードでFOCUS測定開始{ コマンド送信 "localhost", 9000, "STOP" 待機 100 コマンド送信 "localhost", 9000, "EXP_EXPOSURE 1.0" 待機 100 コマンド送信 "localhost", 9000, "CLOSE_FILE" 待機 100 コマンド送信 "localhost", 9000, "SET_OVERWRITE" 待機 100 コマンド送信 "localhost", 9000, "SET_FILENAME AAA.spe" 待機 100 コマンド送信 "localhost", 9000, "START_FOCUS" } exe focusを停止{ コマンド送信 "localhost", 9000, "STOP" } exe exe ■APPENDモードでACQUISITION開始{ コマンド送信 "localhost", 9000, "STOP" 待機 100 コマンド送信 "localhost", 9000, "EXP_EXPOSURE 5.0" 待機 100 コマンド送信 "localhost", 9000, "CLOSE_FILE" 待機 100 コマンド送信 "localhost", 9000, "SET_APPEND" 待機 100 コマンド送信 "localhost", 9000, "SET_FILENAME BBB.spe" 待機 100 コマンド送信 "localhost", 9000, "START" } exe exe カーソル位置を取得する{ コマンド送信 "localhost", 9000, "CURSOR" 待機 100 コマンド受信 ($cursor), "localhost", 9001 ステータスバーに表示 $cursor } exe exe サーバを閉じる{ コマンド送信 "localhost", 9000, "QUIT" } /# ***vb_program1*** Imports System.Net Imports System.Net.Sockets Module vb_program1 Dim docs As Object Dim doc As Object Dim expset As Object Dim wins As Object Dim calib As Object Dim frame As Object Dim ex As Object Dim dx As Object Sub Main() Dim server1 As TcpListener = New TcpListener(IPAddress.Any, 9000) Dim server2 As TcpListener = New TcpListener(IPAddress.Any, 9001) server1.Start() server2.Start() Console.WriteLine("waiting command ...") Dim exit_flag as Boolean = false docs = CreateObject("WINX32.DocFiles") doc = CreateObject("WINX32.DocFile") expset = CreateObject("WINX32.ExpSetup") wins = CreateObject("WINX32.DocWindows") Do while exit_flag = false Dim client1 As TcpClient = server1.AcceptTcpClient() Dim stream1 As NetworkStream = client1.GetStream() Dim data(100) As Byte Dim len As Integer = stream1.Read(data, 0, data.Length) Dim txt As String = System.Text.Encoding.UTF8.GetString(data, 0, len) Console.WriteLine(txt & " received") Dim cmds() As String = txt.split(" ") select case cmds(0) case "SET_OVERWRITE" expset.setParam(800, 1) case "SET_APPEND" expset.setParam(800, 2) case "SET_FILENAME" expset.setParam(780, cmds(1)) case "EXP_EXPOSURE" expset.setParam(127, cmds(1)) case "CLOSE_FILE" docs.CloseAll() case "START_FOCUS" expset.StartFocus(doc) case "START" expset.Start(doc) case "STOP" expset.Stop() case "CURSOR" wins = CreateObject("WINX32.DocWindows") Dim val As String = wins.GetActive.GetCursor.XPos & " " & wins.GetActive.GetCursor.YPos Dim client2 As TcpClient = server2.AcceptTcpClient() Dim stream2 As NetworkStream = client2.GetStream() Dim enc As System.Text.Encoding = System.Text.Encoding.ASCII Dim sendBytes As Byte() = enc.GetBytes(val) stream2.Write(sendBytes, 0, sendBytes.Length) client2.Close() Console.WriteLine(val & " was sent.") case "SET_CURSOR" wins = CreateObject("WINX32.DocWindows") wins.GetActive.MoveCursor(cmds(1), cmds(2)) case "QUIT" exit_flag = true end select client1.Close() Loop server1.Stop() server1 = Nothing server2.Stop() server2 = Nothing End Sub End Module ****** #/