📄 wscores.pas
字号:
unit wsCores;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics,
Controls, Forms, Dialogs,StdCtrls,DB, DBTables,
ComCtrls, Grids, DBGrids, ExtCtrls,DBCtrls, Mask,
Buttons,ToolWin,WinTypes, WinProcs, Menus,DBCGrids,
iniFiles,resMain,wsTypes,ErrorReport;
Procedure About(AppInfo:TAppInfo);far;external 'wsFrame.dll';
Procedure UserMaintaince(AppInfo:TAppInfo;UserInfo:TUserInfo);far;external 'wsFrame.dll';
Procedure SetWorkPause(AppInfo:TAppInfo;UserInfo1:TUserInfo);far;external 'wsFrame.dll';
Function IsPasswordCorrect(AppInfo:TAppInfo;UserInfo1:TUserInfo):Boolean;far;external 'wsFrame.dll';
Procedure ErrorSong();far;external 'wsFrame.dll';
Procedure WinExecNoWait(strFileName:PChar);far;external 'wsFrame.dll';
Procedure GetCopyRight(strCopyRight:PChar);far;external 'wsFrame.dll';
Function isCopyRightCorrect:Boolean;far;external 'wsFrame.dll';
//////////
Function ExitSystem(AppInfo:TAppInfo):Integer;far;external 'wsFrame.dll';
Function GetUserName(AppInfo:TAppInfo;UserInfo:TUserInfo):TUserInfo;far;external 'wsFrame.dll';
Function GetNewPassword(AppInfo:TAppInfo;UserInfo:TUserInfo):TUserInfo;far;external 'wsFrame.dll';
Function GetBackgroundBMP(AppInfo:TAppInfo):TAppInfo;far;external 'wsFrame.dll';
Function GetIme(AppInfo:TAppInfo):PChar;far;external 'wsFrame.dll';
//Function EncryptMsg (Msg1: string; EncryptNo: integer): string;far;external 'wsFrame.dll';
//Function DecryptMsg (Msg1: string; DecryptNo: integer): string;far;external 'wsFrame.dll';
Function GetDBID(DBInfo:TDBInfo):TDBInfo;far;external 'wsFrame.dll';
Function CurrToChinese(Price:Currency):PChar;far;external 'wsFrame.dll';
Function ProhibitInsDelKey(Key:Word):Word;far;external 'wsFrame.dll';
Function DateToChinese(TransDate:TDate):PChar;far;external 'wsFrame.dll';
Function GetGenCode(QueryInfo:TQueryInfo;var CodeInfo:TCodeInfo):TResultCode;far;external 'wsFrame.dll';
Function IsDateEmpty(DateString:PChar):Boolean;far;external 'wsFrame.dll'
Function IsNumberEmpty(NumberString:PChar):Boolean;far;external 'wsFrame.dll'
Function IsStringEmpty(TempStr:PChar):Boolean;far;external 'wsFrame.dll'
Function GetUserRegister():Boolean;far;external 'wsFrame.dll'
Function GetMaxMinGrivaty(GroupID:String):TMaxMinExtension;
//Public Function;
Function WinDir(optWin:integer):string;far;external 'wsFrame.dll';
Function StrToIMEMode(StrimeMode:string):TimeMode;far;external 'wsFrame.dll';
Function IMEModeToStr(StrimeMode:TimeMode):string;far;external 'wsFrame.dll';
Procedure AppInitialize();
Procedure AppDestroy(AppInfo:TAppInfo);
Procedure SetINIValue(FileName,Section,Ident,Value:String);
Function GetINIValue(Filename,Section,Ident:String):String;
Function HasAttr(Const FileName:String;Attr:Word):Boolean;
Procedure DCopyFile(Const FileName,DestName:TFileName);
/////////////////////////////
Function QueryCodeMeaning(strACODE,strCODENAME:string;QueryTable:Tquery):string;
Function isKeyRepeated(Query:TQuery;strSQL,KeyName,KeyValue:String):Boolean;
Function NameToID(strName:String):String;
Procedure GetBDEParams();
Procedure SetPageControlReadOnly(PageControl:TPageControl;ReadOnly:boolean);
Procedure UpdateSystemDB(qryPublic:TQuery;Flag,Status:String);
Function GetSystemDBStatus(qryPublic:TQuery;Flag:String):String;
Procedure UpdateSchoolDB(qryPublic:TQuery;Flag,Status:String);
Function GetSchoolDB(qryPublic:TQuery;Flag:String):String;
Function GetName(Str:String):String;
Function GetID(Str:String):String;
Function DataParse(Str:String):TDataPacket;
Function ByteParse(ByteData:TByteData):TDataPacket;
Function FormSendData(RawCommand:TRawCommand):TSendPacket;
Procedure InitCommandID();
Procedure WriteLog(qryPublic:TQuery;LogInfo:TLogInfo);
Function FormBCD(Data:String):Byte;
Function FormExtensionID(iExtension:Integer):String;
Procedure CalcAverage();
Function GSatisfied(Gravity:Real;Extension:Integer):Boolean;
Function GetMaxMinDiff(GroupID:String):TMaxMinExtension;
procedure ShowErrorReport(ErrorText:String);
implementation
Procedure InitCommandID();
var
i: Integer;
begin
For i:=0 to MaxCommandCount-1 do
CommandID[i]:='';
CommandID[0]:='000'; // 采样
CommandID[1]:='001'; // 提升准备
CommandID[2]:='003'; // 直接提升
CommandID[3]:='005'; // 吊点上移
CommandID[4]:='002'; // 下降准备
CommandID[5]:='004'; // 直接下降
CommandID[6]:='006'; // 吊点下移
CommandID[7]:='007'; // 调整
CommandID[8]:='008'; // 卸荷
CommandID[9]:='009'; //停止
CommandID[MaxCommandCount-1]:='111';
For i:=0 to MaxOperationCount-1 do
OperationType[i]:='';
OperationType[0]:='提升准备';
OperationType[1]:='直接提升';
OperationType[2]:='吊点上移';
OperationType[3]:='下降准备';
OperationType[4]:='直接下降';
OperationType[5]:='吊点下移';
OperationType[6]:='停止';
OperationType[7]:='卸荷';
OperationType[8]:='倒链';
OperationType[9]:='';
OperationType[10]:='010';
OperationType[MaxOperationCount-1]:='010';
For i:=0 to MaxExtensionCount-1 do
begin
ExtensionState1[i].ExtensionID:='';
ExtensionState1[i].Gravity:=0;
ExtensionState1[i].Height:=0;
ExtensionState1[i].HorizonDiff:=0;
ExtensionState1[i].State:='00';
ExtensionState2[i].ExtensionID:='';
ExtensionState2[i].Gravity:=0;
ExtensionState2[i].Height:=0;
ExtensionState2[i].HorizonDiff:=0;
ExtensionState2[i].State:='00';
ExtensionState8[i].ExtensionID:='';
ExtensionState8[i].Gravity:=0;
ExtensionState8[i].Height:=0;
ExtensionState8[i].HorizonDiff:=0;
ExtensionState8[i].State:='00';
AllExtension[i].GroupID:='';
AllExtension[i].ExtensionID:='';
AllExtension[i].OverCount:=0;
AllExtension[i].Gravity:=0;
AllExtension[i].Height:=0;
AllExtension[i].HorizonDiff:=0;
AllExtension[i].Flag:=0;
AllExtension[i].Status:=ssNormal;
AllExtension[i].CommErr:=False;
AllExtension[i].Adjusting:=False;
AllExtension[i].FirstComm:=False;
StandardG[i].ExtensionID:='';
StandardG[i].Value:=0;
end;
For i:=0 to MaxGroupCount-1 do
begin
AllGroup[i].GroupID:='';
AllGroup[i].ExtensionCount:=0;
AllGroup[i].AverageG:=0;
AllGroup[i].AverageH:=0;
AllGroup[i].Flag:='';
end;
For i:=0 to MaxErrorCount-1 do
begin
ErrorInfo[i].ECode:=0;
ErrorInfo[i].EMessage:='';
end;
ErrorInfo[0].Ecode:=0;
ErrorInfo[0].EMessage:='机位吊点未松脱或倒链装置等故障,请及时排除';
ErrorInfo[1].Ecode:=1;
ErrorInfo[1].EMessage:='可能吊点未连接或收紧链条行程还长,请检查后再操作';
ErrorInfo[2].Ecode:=2;
ErrorInfo[2].EMessage:='机位电机不运转故障,请予修理或更换';
ErrorInfo[3].Ecode:=3;
ErrorInfo[3].EMessage:='机位吊点或提升设备发生破断或滑链等故障,请立即将架体与附着支撑先行固定,然后再更换故障设备或配件';
ErrorInfo[4].Ecode:=4;
ErrorInfo[4].EMessage:='机位处导轨垂直度偏差已超标,请排除鼓掌';
ErrorInfo[5].Ecode:=5;
ErrorInfo[5].EMessage:='机位尚未固定好,必须按规定立即重新固定。';
ErrorInfo[6].Ecode:=6;
ErrorInfo[6].EMessage:='';
ErrorInfo[7].Ecode:=7;
ErrorInfo[7].EMessage:='';
ErrorInfo[8].Ecode:=8;
ErrorInfo[8].EMessage:='';
ErrorInfo[9].Ecode:=9;
ErrorInfo[9].EMessage:='';
With StateInfo do
begin
UpperLimit13:=1.3;
UpperLimit16:=1.7;
LowLimit07:=0.7;
LowLimit04:=0.3;
end;
GProjectInfo.ProjectName:='';
GProjectInfo.ProjectID:='';
GProjectInfo.HourseName:='';
GProjectInfo.HourseID:='';
ReceiveString.Str1:='';
ReceiveString.Str2:='';
ReceiveString.Str3:='';
ReceiveString.Str4:='';
ReceiveString.Str5:='';
ReceiveString.Str6:='';
end;
Procedure CalcAverage();
var
i,j:Integer;
AverageG,AverageH:Real;
begin
for i:=0 to MaxGroupCount-1 do
begin
if AllGroup[i].GroupID<>'' then
begin
AverageG:=0;
AverageH:=0;
for j:=0 to MaxExtensionCount - 1 do
begin
if AllGroup[i].GroupID=AllExtension[j].GroupID then
begin
AverageG:=AverageG+AllExtension[j].Gravity;
AverageH:=AverageH+AllExtension[j].Height;
end;
end;
if AllGroup[i].ExtensionCount<>0 then
begin
AllGroup[i].AverageG:=AverageG/AllGroup[i].ExtensionCount;
AllGroup[i].AverageH:=AverageH/AllGroup[i].ExtensionCount;
end;
end;
end;
for j:=0 to MaxExtensionCount - 1 do
begin
if AllExtension[j].ExtensionID<>'' then
AllExtension[j].HorizonDiff:=AllExtension[j].Height-AllGroup[StrToInt(AllExtension[j].GroupID)].AverageH;
end;
end;
Function HasAttr(Const FileName:String;Attr:Word):Boolean;
begin
Result:=(FileGetAttr(FileName) and Attr)=Attr;
end;
procedure DCopyFile(Const FileName,DestName:TFileName);
var
CopyBuffer:Pointer;
TimeStamp,BytesCopied:Longint;
Source,Dest:Integer;
Destination:TFileName;
Const
ChunkSize:Longint=8192;
Begin
Destination:=ExpandFileName(DestName);
if HasAttr(Destination,faDirectory) then
Destination:=Destination+'\'+ExtractFileName(FileName);
TimeStamp:=FileAge(FileName);
GetMem(CopyBuffer,ChunkSize);
try
Source:=FileOpen(Filename,fmShareDenyWrite);
if Source<0 then
Raise Exception.Create('文件打开错误');
try
Dest:=FileCreate(Destination);
if Dest<0 then
Raise Exception.Create('文件创建错误');
try
repeat
BytesCopied:=FileRead(Source,CopyBuffer^,ChunkSize);
if BytesCopied>0 then
FileWrite(Dest,CopyBuffer^,BytesCopied);
until BytesCopied<ChunkSize;
finally
FileSetDate(Dest,TimeStamp);
FileClose(Dest);
end;
finally
FileClose(Source);
end;
finally
FreeMem(CopyBuffer,ChunkSize);
end;
end;
Procedure SetINIValue(FileName,Section,Ident,Value:String);
var
wsINI: TIniFile;
begin
wsIni:=TIniFile.Create(FileName);
wsIni.WriteString(Section, Ident, Value);
wsIni.Free;
end;
Function GetINIValue(Filename,Section,Ident:String):String;
var
wsIni: TIniFile;
begin
wsIni:= TIniFile.Create(FileName);
Result:=wsIni.ReadString(Section, Ident,'');
wsIni.Free;
end;
Procedure AppInitialize();
var
wsIni: TIniFile;
begin
with AppInfo do
begin
Path:=ExtractFilePath(Application.ExeName);
INIFileName:=Path+'SFWIN.INI';
IDFileName:=Path+'UserInfo.ID';
wsIni:= TIniFile.Create(INIFileName);
CompanyName:=SCompanyName;
Title:=wsIni.ReadString('System','SoftWareName','全能');
BMPFileName:=wsIni.ReadString('Background','WallPaper','wsl.BMP');
IsBMPChanged:=True;
ToolStatus:=wsIni.ReadString('System','Tool','1111111111');
ImeName:=wsIni.ReadString('Chinese','IMEChinese',SIMEChinese);
ImeMode:=ImChinese;
end;
With UserInfo do
begin
UserName:=wsIni.ReadString('System','UserName','TeChen');
UserID:='';
Password:='';
UserLevel:=90;
Next:=nil;
end;
wsINI.Free;
bSampling:=False;
end;
Procedure AppDestroy(AppInfo:TAppInfo);
var
wsINI: TIniFile;
begin
wsIni:=TIniFile.Create(AppInfo.INIFileName);
If UserInfo.UserName<>'' Then
wsIni.WriteString('System','UserName',UserInfo.UserName);
wsIni.WriteString('System','Tool',AppInfo.ToolStatus);
wsIni.WriteString('Chinese','IMEChinese',AppInfo.ImeName);
wsIni.Free;
RWSyn.Free;
end;
//////////////////////////////////////////
Function QueryCodeMeaning(strACODE,strCODENAME:string;QueryTable:Tquery):string;
var str1:string;
begin
if strCodeName<>'' then
str1:='select CODEMEANING from PUBS.MARKET_CODEDETAIL where ( ACODE='''+strACODE+
''' and CODENAME='''+strCODENAME+''')'
else
str1:='select CODEMEANING from PUBS.TRADECODE where ( ACODE='''+strACODE+''')';
QueryTable.Close;
QueryTable.SQL.Clear;
QueryTable.SQL.Add(str1);
QueryTable.Open;
if QueryTable.IsEmpty then
Begin
if Trim(strACode)='' then
Result:=''
else
Result:='无此代码';
end
else
Result:=QueryTable.FieldByName('CODEMEANING').AsString;
end;
Function isKeyRepeated(Query:TQuery;strSQL,KeyName,KeyValue:String):Boolean;
begin
Result:=False;
if Trim(KeyValue)='' then
Result:=False
else
begin
with Query do
begin
Close;
SQL.Clear;
SQL.Add(strSQL);
ParamByName(KeyName).AsString:=KeyValue;
Prepare;
try
Open;
except
ExecSQL;
end;
Result:=not IsEmpty;
end;
end;
end;
Procedure SetPageControlReadOnly(PageControl:TPageControl;ReadOnly:boolean);
var i:integer;
begin
for i:=0 to PageControl.PageCount-1 do
begin
PageControl.Pages[i].Enabled:=not ReadOnly;
end;
end;
Function NameToID(strName:String):String;
begin
Result:=Copy(strName,Length(StrName)-6,6);
end;
Procedure GetBDEParams();
var
BDEList:TStringList;
begin
try
BDEList:=TStringList.Create;
if Session.IsAlias('JSJ') then
begin
Session.DeleteAlias('JSJ');
Session.SaveConfigFile;
end;
with Session do
begin
ConfigMode := cmSession;
try
AddStandardAlias('JSJ',ExtractFilePath(Application.ExeName)+'DB', 'PARADOX');
finally
ConfigMode := cmAll;
end;
end;
Session.GetAliasParams('JSJ',BDEList);
BDEParams.Path:=Copy(BDElist.Strings[0],6,255);
BDEParams.PathWithItialic:=BDEParams.Path+'\';
Session.AddPassword('19661114');
finally
BDEList.Free;
end;
end;
Function GetID(Str:String):String;
var
iP,iCount:Integer;
begin
Result:='';
iP:=0;
iCount:=0;
iP:=Pos('[',Str)+1;
iCount:=Pos(']',Str)-iP;
if iCount>=1 then
Result:=Copy(Str,iP,iCount);
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -