Public Class alarm
    Inherits System.Windows.Forms.Form

#Region " Windows tH[ fUCiŐꂽR[h "

    Public Sub New()
        MyBase.New()

        ' ̌Ăяo Windows tH[ fUCiŕKvłB
        InitializeComponent()

        ' InitializeComponent() Ăяǒɏǉ܂B

    End Sub

    ' Form  dispose I[o[ChăR|[lgꗗ܂B
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    ' Windows tH[ fUCiŕKvłB
    Private components As System.ComponentModel.IContainer

    '  : ȉ̃vV[ẂAWindows tH[ fUCiŕKvłB
    ' Windows tH[ fUCigĕύXĂB  
    ' R[h GfB^͎gpȂłB
	Friend WithEvents btnSet As System.Windows.Forms.Button
	Friend WithEvents btnGet As System.Windows.Forms.Button
	Friend WithEvents groupBox1 As System.Windows.Forms.GroupBox
	Friend WithEvents label6 As System.Windows.Forms.Label
	Friend WithEvents label5 As System.Windows.Forms.Label
	Friend WithEvents label4 As System.Windows.Forms.Label
	Friend WithEvents label3 As System.Windows.Forms.Label
	Friend WithEvents label2 As System.Windows.Forms.Label
	Friend WithEvents label1 As System.Windows.Forms.Label
	Friend WithEvents txtLL As System.Windows.Forms.TextBox
	Friend WithEvents txtLU As System.Windows.Forms.TextBox
	Friend WithEvents txtUL As System.Windows.Forms.TextBox
	Friend WithEvents txtUU As System.Windows.Forms.TextBox
	Friend WithEvents cboAlarm As System.Windows.Forms.ComboBox
	Friend WithEvents txtChannel As System.Windows.Forms.TextBox
	Friend WithEvents btnOK As System.Windows.Forms.Button
	<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
		Me.btnSet = New System.Windows.Forms.Button()
		Me.btnGet = New System.Windows.Forms.Button()
		Me.groupBox1 = New System.Windows.Forms.GroupBox()
		Me.label6 = New System.Windows.Forms.Label()
		Me.label5 = New System.Windows.Forms.Label()
		Me.label4 = New System.Windows.Forms.Label()
		Me.label3 = New System.Windows.Forms.Label()
		Me.label2 = New System.Windows.Forms.Label()
		Me.label1 = New System.Windows.Forms.Label()
		Me.txtLL = New System.Windows.Forms.TextBox()
		Me.txtLU = New System.Windows.Forms.TextBox()
		Me.txtUL = New System.Windows.Forms.TextBox()
		Me.txtUU = New System.Windows.Forms.TextBox()
		Me.cboAlarm = New System.Windows.Forms.ComboBox()
		Me.txtChannel = New System.Windows.Forms.TextBox()
		Me.btnOK = New System.Windows.Forms.Button()
		Me.groupBox1.SuspendLayout()
		Me.SuspendLayout()
		'
		'btnSet
		'
		Me.btnSet.Location = New System.Drawing.Point(125, 231)
		Me.btnSet.Name = "btnSet"
		Me.btnSet.Size = New System.Drawing.Size(96, 24)
		Me.btnSet.TabIndex = 6
		Me.btnSet.Text = "ݒ"
		'
		'btnGet
		'
		Me.btnGet.Location = New System.Drawing.Point(17, 231)
		Me.btnGet.Name = "btnGet"
		Me.btnGet.Size = New System.Drawing.Size(96, 24)
		Me.btnGet.TabIndex = 5
		Me.btnGet.Text = "ǂݍ"
		'
		'groupBox1
		'
		Me.groupBox1.Controls.AddRange(New System.Windows.Forms.Control() {Me.label6, Me.label5, Me.label4, Me.label3, Me.label2, Me.label1, Me.txtLL, Me.txtLU, Me.txtUL, Me.txtUU, Me.cboAlarm, Me.txtChannel})
		Me.groupBox1.Location = New System.Drawing.Point(17, 15)
		Me.groupBox1.Name = "groupBox1"
		Me.groupBox1.Size = New System.Drawing.Size(312, 200)
		Me.groupBox1.TabIndex = 4
		Me.groupBox1.TabStop = False
		Me.groupBox1.Text = "A[ݒ"
		'
		'label6
		'
		Me.label6.Location = New System.Drawing.Point(32, 157)
		Me.label6.Name = "label6"
		Me.label6.Size = New System.Drawing.Size(88, 24)
		Me.label6.TabIndex = 11
		Me.label6.Text = "lF"
		Me.label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight
		'
		'label5
		'
		Me.label5.Location = New System.Drawing.Point(32, 130)
		Me.label5.Name = "label5"
		Me.label5.Size = New System.Drawing.Size(88, 24)
		Me.label5.TabIndex = 10
		Me.label5.Text = "lF"
		Me.label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight
		'
		'label4
		'
		Me.label4.Location = New System.Drawing.Point(32, 103)
		Me.label4.Name = "label4"
		Me.label4.Size = New System.Drawing.Size(88, 24)
		Me.label4.TabIndex = 9
		Me.label4.Text = "㉺lF"
		Me.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight
		'
		'label3
		'
		Me.label3.Location = New System.Drawing.Point(32, 76)
		Me.label3.Name = "label3"
		Me.label3.Size = New System.Drawing.Size(88, 24)
		Me.label3.TabIndex = 8
		Me.label3.Text = "lF"
		Me.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight
		'
		'label2
		'
		Me.label2.Location = New System.Drawing.Point(32, 49)
		Me.label2.Name = "label2"
		Me.label2.Size = New System.Drawing.Size(88, 24)
		Me.label2.TabIndex = 7
		Me.label2.Text = "A[LF"
		Me.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight
		'
		'label1
		'
		Me.label1.Location = New System.Drawing.Point(32, 22)
		Me.label1.Name = "label1"
		Me.label1.Size = New System.Drawing.Size(88, 24)
		Me.label1.TabIndex = 6
		Me.label1.Text = "`lԍF"
		Me.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight
		'
		'txtLL
		'
		Me.txtLL.Location = New System.Drawing.Point(128, 160)
		Me.txtLL.Name = "txtLL"
		Me.txtLL.Size = New System.Drawing.Size(104, 19)
		Me.txtLL.TabIndex = 5
		Me.txtLL.Text = ""
		'
		'txtLU
		'
		Me.txtLU.Location = New System.Drawing.Point(128, 133)
		Me.txtLU.Name = "txtLU"
		Me.txtLU.Size = New System.Drawing.Size(104, 19)
		Me.txtLU.TabIndex = 4
		Me.txtLU.Text = ""
		'
		'txtUL
		'
		Me.txtUL.Location = New System.Drawing.Point(128, 106)
		Me.txtUL.Name = "txtUL"
		Me.txtUL.Size = New System.Drawing.Size(104, 19)
		Me.txtUL.TabIndex = 3
		Me.txtUL.Text = ""
		'
		'txtUU
		'
		Me.txtUU.Location = New System.Drawing.Point(128, 79)
		Me.txtUU.Name = "txtUU"
		Me.txtUU.Size = New System.Drawing.Size(104, 19)
		Me.txtUU.TabIndex = 2
		Me.txtUU.Text = ""
		'
		'cboAlarm
		'
		Me.cboAlarm.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
		Me.cboAlarm.Items.AddRange(New Object() {"", "L"})
		Me.cboAlarm.Location = New System.Drawing.Point(128, 51)
		Me.cboAlarm.Name = "cboAlarm"
		Me.cboAlarm.Size = New System.Drawing.Size(104, 20)
		Me.cboAlarm.TabIndex = 1
		'
		'txtChannel
		'
		Me.txtChannel.Location = New System.Drawing.Point(128, 24)
		Me.txtChannel.Name = "txtChannel"
		Me.txtChannel.Size = New System.Drawing.Size(104, 19)
		Me.txtChannel.TabIndex = 0
		Me.txtChannel.Text = ""
		'
		'btnOK
		'
		Me.btnOK.Location = New System.Drawing.Point(233, 231)
		Me.btnOK.Name = "btnOK"
		Me.btnOK.Size = New System.Drawing.Size(96, 24)
		Me.btnOK.TabIndex = 7
		Me.btnOK.Text = ""
		'
		'alarm
		'
		Me.AutoScaleBaseSize = New System.Drawing.Size(5, 12)
		Me.ClientSize = New System.Drawing.Size(346, 271)
		Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnSet, Me.btnGet, Me.groupBox1, Me.btnOK})
		Me.Font = New System.Drawing.Font("lr oSVbN", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
		Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
		Me.MaximizeBox = False
		Me.MinimizeBox = False
		Me.Name = "alarm"
		Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
		Me.Text = "A[ݒ"
		Me.groupBox1.ResumeLayout(False)
		Me.ResumeLayout(False)

	End Sub

#End Region
	Dim m_Id As Short

	'	R[ID擾
	Public Sub SetId(ByVal id As Short)

		m_Id = id

	End Sub

	'	_CAȌ
	Private Sub alarm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

		txtChannel.Text = "0"
		txtUU.Text = "0"
		txtUL.Text = "0"
		txtLU.Text = "0"
		txtLL.Text = "0"

		' `lԍ0ɐݒ
		cboAlarm.SelectedIndex = 0
		btnGet_Click(btnGet, New System.EventArgs())

	End Sub

	'	[ǂݍ]{^NbN
	Private Sub btnGet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGet.Click

		Dim ret As Integer
		Dim enable As Short
		Dim uu, ul, lu, ll As Integer

		' A[̐ݒԂ擾
		ret = PtGetAlarm(m_Id, Val(txtChannel.Text), enable, uu, ul, lu, ll)
		If ret <> 0 Then
			ErrorHandling("PtGetAlarm", ret)
			Exit Sub
		End If

		' ݒԂ_CAOɔf
		cboAlarm.SelectedIndex = enable
		txtUU.Text = uu / 100
		txtUL.Text = ul / 100
		txtLU.Text = lu / 100
		txtLL.Text = ll / 100

	End Sub

	'	[ݒ]{^NbN
	Private Sub btnSet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSet.Click

		Dim ret As Integer
		Dim enable As Short
		Dim uu, ul, lu, ll As Integer

		' _CAO̐ݒe擾
		enable = cboAlarm.SelectedIndex
		uu = Val(txtUU.Text) * 100
		ul = Val(txtUL.Text) * 100
		lu = Val(txtLU.Text) * 100
		ll = Val(txtLL.Text) * 100

		' A[̐ݒ
		ret = PtSetAlarm(m_Id, Val(txtChannel.Text), enable, uu, ul, lu, ll)
		If ret <> 0 Then
			ErrorHandling("PtSetAlarm", ret)
			Exit Sub
		End If

	End Sub

	'	[]{^NbN
	Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click

		Me.Close()

	End Sub

	'	G[
	Private Sub ErrorHandling(ByVal Dfunction As String, ByVal ret As Integer)

		Dim errstr As New System.Text.StringBuilder("", 256)
		PtGetErrorString(ret, errstr)
        MsgBox(errstr.ToString(), MsgBoxStyle.OKOnly, Dfunction)

	End Sub
End Class
