晨怡热管 >> 资料积累 >> 国外文献 >> gp_Temp5 page 3

gp_Temp5 page 3

晨怡热管 2007-2-6 21:11:53

Source Code for gp_Temp5 to MBM5 Interface

The original Shared Memory source code by Alex van Kaam may be found on http://mbm.livewiredev.com/  under the heading of MBM 5 Shared Memory and also in the Shared Memory section of the help files found in MBM5.  Alex's source code shows additional functions of the shared memory that I have not used in gp_Temp5.

This interface enables the write of the current temperature, highest temperature reached, lowest temperature reached, average temperature, and count of how many times the temperature has been read.
 
 

unit mbminit;
            interface
            uses
              Windows, StdCtrls, Controls, Grids, Classes, Forms, SysUtils;
            type
              TBusType     = (btISA, btSMBus,btVIA686ABus, btDirectIO);
              TSMBType     = (smtSMBIntel, smtSMBAMD, smtSMBALi, smtSMBNForce, smtSMBSIS);
              TSensorType  = (stUnknown, stTemperature, stVoltage, stFan, stMhz, stPercentage);
              TSharedIndex = record
                iType : TSensorType;                          // type of sensor
                Count : integer;                              // number of sensor for that type
              end;
              TSharedSensor = record
                ssType    : TSensorType;                      // type of sensor
                ssName    : array [0..11] of AnsiChar;        // name of sensor
                sspadding1: array [0..2] of Char;             // padding of 3 byte
                ssCurrent : Double;                           // current value
                ssLow     : Double;                           // lowest readout
                ssHigh    : Double;                           // highest readout
                ssCount   : LongInt;                          // total number of readout
                sspadding2: array [0..3] of Char;             // padding of 4 byte
                ssTotal   : Extended;                         // total amout of all readouts
                sspadding3: array [0..5] of Char;             // padding of 6 byte
                ssAlarm1  : Double;                           // temp & fan: high alarm; voltage: % off;
                ssAlarm2  : Double;                           // temp: low alarm
              end;
              TSharedInfo = record
                siSMB_Base       : Word;                      // SMBus base address
                siSMB_Type       : TBusType;                  // SMBus/Isa bus used to access chip
                siSMB_Code       : TSMBType;                  // SMBus sub type, Intel, AMD or ALi
                siSMB_Addr       : Byte;                      // Address of sensor chip on SMBus
                siSMB_Name       : array [0..40] of AnsiChar; // Nice name for SMBus
                siISA_Base       : Word;                      // ISA base address of sensor chip on ISA
                siChipType       : Integer;                   // Chip nr, connects with Chipinfo.ini
                siVoltageSubType : Byte;                      // Subvoltage option selected
              end;
              TSharedData =  record
                sdVersion : Double;                           // version number (example: 51090)
                sdIndex   : array [0..9]   of TSharedIndex;   // Sensor index
                sdSensor  : array [0..99]  of TSharedSensor;  // sensor info
                sdInfo    : TSharedInfo;                      // misc. info
                sdStart   : array [0..40]  of AnsiChar;       // start time
                sdCurrent : array [0..40]  of AnsiChar;       // current time
                sdPath    : array [0..255] of AnsiChar;       // MBM path
              end;
              PSharedData   = ^TSharedData;
            function WriteSharedData : Boolean;
              
            var
              SharedIndex  : TSharedIndex;
              SharedSensor : TSharedSensor;
              SharedInfo   : TSharedInfo;
              SharedData   : PSharedData;
              Temperature       : array[1..10] of Double;     //ssCurent
              TempL             : array[1..10] of Real;       //ssLow
              TempH             : array[1..10] of Real;       //ssHigh
              TempA             : array[1..10] of Extended;   //ssTotal - Readouts
              TempC             : array[1..10] of LongInt;    //ssCount - # of Readouts
            implementation
               // Just do something
            function WriteSharedData : Boolean;
              var     myHandle : Integer;
                      X : integer;
            begin
              myHandle :=  OpenFileMapping(FILE_MAP_ALL_ACCESS, False, '$M$B$M$5$S$D$');
              if myHandle > 0 then begin
                SharedData := MapViewOfFile(myHandle, FILE_MAP_ALL_ACCESS, 0, 0, 0);
                with SharedData^ do begin
                   for X:=3 to 6 do     // 4 sensors - MBM #s 4,5,6, & 7
                   begin
                      sdSensor[X].ssCurrent  := Temperature[X];
                      sdSensor[X].ssLow      := TempL[X];
                      sdSensor[X].ssHigh     := TempH[X];
                      sdSensor[X].ssTotal    := round(TempA[X]);
                      sdSensor[X].ssCount    := round(TempC[X]);
                   end;
                end;
                   UnMapViewOfFile(SharedData);
                   Result := True;
              end else result := false;
                 CloseHandle(myHandle);
            end;
            end.
            
责任编辑: banye 参与评论
本站地图|热管配套|企业邮局|产品说明

Copyright © 1996-2010 China Harbin DawnHappy Heat Pipe Technology Co., Ltd.
哈尔滨晨怡热管技术有限公司   电话:0451-82589558 82589508 82589538   传真:0451-82552085 技术支持:13704813968
地址:哈尔滨市南岗区南通大街256号  邮编:150001  电子信箱:heatpipe@yahoo.cn   heat-pipe@hotmail.com heat.pipe@yahoo.com.cn 
本站永久域名:http://china-heatpipe.net     http://heatpipe.net.cn    http://rg.nx8.net     http://nx8.net  
中华人民共和国信息产业部ICP/IP地址信息备案:黑ICP备07500228  哈尔滨市公安局国际联网备案登记:哈公网监备2301001146

Powered By: KingCMS 3.0 Beta