VERSION 5.00
Begin VB.Form frmTempFan 
   BorderStyle     =   1  'Œ()
   Caption         =   "Temp/Fan State"
   ClientHeight    =   1875
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   3660
   Icon            =   "frmTempFan.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   1875
   ScaleWidth      =   3660
   StartUpPosition =   3  'Windows ̊l
   Begin VB.Frame Frame4 
      Caption         =   "FAN"
      Height          =   1575
      Left            =   1920
      TabIndex        =   3
      Top             =   135
      Width           =   1575
      Begin VB.Label lblFan 
         AutoSize        =   -1  'True
         Caption         =   "Label1"
         BeginProperty Font 
            Name            =   "lr SVbN"
            Size            =   9
            Charset         =   128
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   195
         Index           =   0
         Left            =   240
         TabIndex        =   8
         Top             =   285
         Width           =   540
      End
      Begin VB.Label lblFan 
         AutoSize        =   -1  'True
         Caption         =   "Label1"
         BeginProperty Font 
            Name            =   "lr SVbN"
            Size            =   9
            Charset         =   128
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   195
         Index           =   1
         Left            =   240
         TabIndex        =   7
         Top             =   525
         Width           =   540
      End
      Begin VB.Label lblFan 
         AutoSize        =   -1  'True
         Caption         =   "Label1"
         BeginProperty Font 
            Name            =   "lr SVbN"
            Size            =   9
            Charset         =   128
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   180
         Index           =   2
         Left            =   240
         TabIndex        =   6
         Top             =   765
         Width           =   540
      End
      Begin VB.Label lblFan 
         AutoSize        =   -1  'True
         Caption         =   "Label1"
         BeginProperty Font 
            Name            =   "lr SVbN"
            Size            =   9
            Charset         =   128
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   180
         Index           =   3
         Left            =   240
         TabIndex        =   5
         Top             =   1005
         Width           =   540
      End
      Begin VB.Label lblFan 
         AutoSize        =   -1  'True
         Caption         =   "Label1"
         BeginProperty Font 
            Name            =   "lr SVbN"
            Size            =   9
            Charset         =   128
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   165
         Index           =   4
         Left            =   240
         TabIndex        =   4
         Top             =   1245
         Width           =   540
      End
   End
   Begin VB.Frame Frame2 
      Caption         =   "Temp"
      Height          =   1575
      Left            =   165
      TabIndex        =   0
      Top             =   135
      Width           =   1575
      Begin VB.Label lblTemp1 
         Caption         =   "Label1"
         BeginProperty Font 
            Name            =   "lr SVbN"
            Size            =   9
            Charset         =   128
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   240
         TabIndex        =   2
         Top             =   285
         Width           =   1110
      End
      Begin VB.Label lblTemp2 
         Caption         =   "Label1"
         BeginProperty Font 
            Name            =   "lr SVbN"
            Size            =   9
            Charset         =   128
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   240
         TabIndex        =   1
         Top             =   525
         Width           =   1110
      End
   End
   Begin VB.Timer Timer1 
      Left            =   0
      Top             =   480
   End
End
Attribute VB_Name = "frmTempFan"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

'*****************************************************************************
'   t@C F frmTenpFan.frm
'
'   @\ F x^FANXe[^X\@\
'
'
' Copyright (C) NEC Corporation 2009
'*****************************************************************************


'*****************************************************************************
' x/FAN擾p萔`
'*****************************************************************************

' RETURNXe[^X
Private Const FCSRASAPI_SUCCESS   As Integer = &H0
Private Const FCSRASAPI_DRVERR    As Integer = &H1

Private strFan(0 To 4) As String


'*****************************************************************************
' \tgRASI/F`
'*****************************************************************************
Private Declare Function fcsoftrasOpen Lib "FcSrasapiP.dll" Alias "fcsoftrasOpenP" () As Long
Private Declare Function fcsoftrasClose Lib "FcSrasapiP.dll" Alias "fcsoftrasCloseP" () As Long
Private Declare Function fcsoftrasGetTemp Lib "FcSrasapiP.dll" Alias "fcsoftrasGetTempP" (ByRef buff() As Byte) As Long
Private Declare Function fcsoftrasGetFan Lib "FcSrasapiP.dll" Alias "fcsoftrasGetFanP" (ByRef buff() As Byte) As Long
Private Declare Function fcsoftrasGetFanInf Lib "FcSrasapiP.dll" Alias "fcsoftrasGetFanInfP" (ByRef buff() As Byte) As Long

'****************************************************
'   ֐ F Form_Load
'   @\   Fʂ̋N()
'      F Ȃ
'   ߂l F Ȃ
'****************************************************
Private Sub Form_Load()
    ' ƃtH_st@CtH_ɕύX DLLǂݏo
    ChDrive App.Path
    ChDir App.Path

    ' \tgRAS̃Cu
    Call fcsoftrasOpen

    strFan(0) = "FAN1 F"
    strFan(1) = "FAN2 F"
    strFan(2) = "FAN3 F"
    strFan(3) = "FAN4 F"
    strFan(4) = "FAN5 F"

    ' ݂̏Ԃ擾Ɖʂւ̔f
    Call subSetTemp
    Call subSetFan
    
    ' ʍXVp̃^C}[ݒ
    Timer1.Interval = 10000                             ' PObݒ
    Timer1.Enabled = True                               ' L

End Sub

'****************************************************
'   ֐ F Form_Unload
'   @\   Fʂ̏I(㏈)
'      F Ȃ
'   ߂l F Ȃ
'****************************************************
Private Sub Form_Unload(Cancel As Integer)
    ' \tgRAS̃CuI
    Call fcsoftrasClose
End Sub

'****************************************************
'   ֐ F Timer1_Timer
'   @\   F^C}[ɂʍXV
'      F Ȃ
'   ߂l F Ȃ
'****************************************************
Private Sub Timer1_Timer()
    ' ݂̏Ԃ擾Ɖʂւ̔f
    Call subSetTemp
    Call subSetFan
End Sub

'****************************************************
'   ֐ F subSetTemp
'   @\   Fx̏Ԃ擾Aʂ̍XVsȂ
'      F Ȃ
'   ߂l F Ȃ
'****************************************************
Private Sub subSetTemp()
    Dim buff(0 To 3) As Byte                            ' xXe[^Xۑp
    Dim Ret As Integer                                  ' ߂lۑp
    
    Ret = fcsoftrasGetTemp(buff)
    ' xf[^擾H
    If FCSRASAPI_SUCCESS = Ret Then
        lblTemp1.Caption = "CPU   F" & buff(2)
        lblTemp2.Caption = "SYSTEMF" & buff(3)
    Else
        lblTemp1.Caption = "NG"
        lblTemp2.Caption = "NG"
        Timer1.Enabled = False
    End If

End Sub

'****************************************************
'   ֐ F subSetFan
'   @\   FFAN̏Ԃ擾Aʂ̍XVsȂ
'      F Ȃ
'   ߂l F Ȃ
'****************************************************
Private Sub subSetFan()
    Dim buff1(0) As Byte                                ' FANڑXe[^Xۑp
    Dim buff2(0 To 10) As Byte                          ' FANXe[^Xۑp
    Dim count1 As Integer
    Dim Ret As Integer                                  ' ߂lۑp

    Ret = fcsoftrasGetFanInf(buff1)
    ' FANڑ擾H
    If FCSRASAPI_SUCCESS = Ret Then
        Ret = fcsoftrasGetFan(buff2)
        ' FANf[^擾H
        If FCSRASAPI_SUCCESS = Ret Then
            For count1 = 0 To 4
                If ((buff1(0) And (2 ^ count1)) <> 0) Then
                    ' FANڑ
                    lblFan(count1).Caption = strFan(count1) & (buff2(count1 * 2 + 1) + (buff2(count1 * 2 + 2) * &H100))
                Else
                    ' FANڑȂ
                    lblFan(count1).Caption = strFan(count1) & "None"
                End If
            Next count1
        Else
            lblFan(0).Caption = "NG"
            Timer1.Enabled = False
        End If
    Else
        lblFan(0).Caption = "NG"
        Timer1.Enabled = False
    End If

End Sub

