Private Sub AcqButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AcqButton.Click
Dim objExp As New WINX32Lib.ExpSetup
Dim objDoc As WINX32Lib.DocFile
Dim intStatus As Integer
If objExp.Start(objDoc) Then '測定開始
While objExp.GetParam(WINX32Lib.EXP_CMD.EXP_RUNNING, intStatus) '測定がまだ続いているかをチェック
System.Windows.Forms.Application.DoEvents() '待っている間に他の仕事をさせる
End While
End If
End Sub Private Sub SetButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SetButton.Click
Dim objExp As New WINX32Lib.ExpSetup
Dim objDoc As WINX32Lib.DocFile
Dim objWin As WINX32Lib.DocWindow
Dim objCur As WINX32Lib.CursorObj
Dim objCal As WINX32Lib.CalibObj
Dim wl0 As Double
Dim objWins As New WINX32Lib.DocWindows
objWin = objWins.GetActive()
objDoc = objWin.GetDocument
objCal = objDoc.GetCalibration
objCur = objWin.GetCursor
wl0 = objCal.Lambda(objCur.XPos)
TextBox1.Text() = Str(Int(wl0 * 1000) / 1000) ' 1000で掛けて、割っているのは小数点以下三桁まで残すため。
End Sub Private Sub Form1_Close(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.FormClosing
Dim objExp As New WINX32Lib.ExpSetup
Dim ttl As Integer
laser = 0 'port 1; 0がoff, 1ならon 回転NDフィルターなので0なら吸収max, 1なら吸収min位置へ回転する
light1 = 0 'port 2; 0がoff, 2ならon 落射照明のOFF/ON
light2 = 0 'port 3; 0がoff, 4ならon 透過照明のOFF/ON
'port 4; 未使用
bs1 = 0 'port 5; 0がoff, 16ならon ビームスプリッター1のIN/OUT
bs2 = 0 'port 6; 0がoff, 32ならon ビームスプリッター2のIN/OUT
ttl = laser + light1 + light2 + bs1 + bs2
objExp.SetParam(WINX32Lib.EXP_CMD.EXP_TTL_LINES, ttl)
End Sub For Each sp As String In My.Computer.Ports.SerialPortNames
ComboBox1.Items.Add(sp)
Next
SerialPort1.NewLine = vbCrLf ' 改行の設定.このコントローラではcr + lfを送る。 Private Sub ComboBox1_SelectedValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedValueChanged
If SerialPort1.IsOpen Then ' 既にオープンされているなら閉じる。
SerialPort1.Close()
End If
SerialPort1.PortName = ComboBox1.SelectedItem ' 選択されたポートを設定
Try
SerialPort1.Open() ' ポートをオープン
Catch ex As Exception ' エラー時にメッセージを出す
MessageBox.Show(ex.Message)
End Try
End Sub Private Sub CurrentStatus()
Dim t As String
SerialPort1.WriteLine("!:") '現在の状態を要求
While SerialPort1.ReadLine = "B" '返事を読んで、Bが帰ってくると装置がbusyであるので、しばらく待つ
SerialPort1.WriteLine("!:")
Threading.Thread.Sleep(10)
End While
SerialPort1.WriteLine("Q:") ' 現在位置を要求
t = SerialPort1.ReadLine ' 位置を読み込む
End Sub