📄 result.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Result.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TTResult *TResult;
//---------------------------------------------------------------------------
__fastcall TTResult::TTResult(TComponent* Owner)
: TForm(Owner)
{
GraphicDlg=0;
}
//---------------------------------------------------------------------------
void __fastcall TTResult::CancelClick(TObject *Sender)
{
if(GraphicDlg!=0)
delete GraphicDlg;
ModalResult = mrCancel;
}
//---------------------------------------------------------------------------
void __fastcall TTResult::GraphicClick(TObject *Sender)
{
if(GraphicDlg==0)
{
GraphicDlg=new TTResultGraphic(this);
GraphicDlg->Selected=Selected;
}
GraphicDlg->Modal=false;
GraphicDlg->Show();
}
//---------------------------------------------------------------------------
void __fastcall TTResult::FormShow(TObject *Sender)
{
WellHead *TempHead,*CurrentHead,*SubHead;
Head=(WellHead*) new WellHead;
TFileStream *File;
AnsiString FileName,Pipe,Station;
switch(Selected)
{
case 0:
{
FileName="Nan.pos";
Pipe="pipe_nan";
Station="station_nan";
break;
}
case 1:
{
FileName="Bei.pos";
Pipe="pipe_bei";
Station="station_bei";
break;
}
case 2:
{
FileName="Dong.pos";
Pipe="pipe_dong";
Station="station_dong";
break;
}
}
File=new TFileStream(FileName,fmOpenRead|fmShareExclusive);
__int64 Position;
Position=File->Size;
int TempInt;
double TempDouble;
char *str;
WellUnit *Well,*CurrentWell;
//读取布局优化结果
File->Read(&TempInt,sizeof(int));
str=(char*)new char[TempInt+1];
File->Read(str,TempInt);
str[TempInt]=0;
Head->No=(AnsiString)str;
delete str;
File->Read(&TempInt,sizeof(int));
if(TempInt)
{
Head->Fixed=true;
}
else
{
Head->Fixed=false;
}
File->Read(&TempDouble,sizeof(double));
File->Read(&TempDouble,sizeof(double));
Head->Next=0;
Head->Sub=0;
Head->Well=0;
bool SubH;
CurrentHead=Head;
while(File->Position<Position)
{
File->Read(&TempInt,sizeof(int));
switch(TempInt)
{
case 0:
Well=(WellUnit*) new WellUnit;
File->Read(&TempInt,sizeof(int));
str=(char*) new char[TempInt+1];
File->Read(str,TempInt);
str[TempInt]=0;
Well->No=(AnsiString)str;
delete str;
if(SubH)
{
Well->Next=SubHead->Well;
SubHead->Well=Well;
}
else
{
Well->Next=CurrentHead->Well;
CurrentHead->Well=Well;
}
break;
case 1:
TempHead=(WellHead*)new WellHead;
File->Read(&TempInt,sizeof(int));
str=(char*)new char[TempInt+1];
File->Read(str,TempInt);
str[TempInt]=0;
TempHead->No=(AnsiString)str;
delete str;
TempHead->Sub=0;
TempHead->Well=0;
TempHead->Next=SubHead;
SubHead=TempHead;
CurrentHead->Sub=TempHead;
SubH==true;
break;
case 2:
TempHead=(WellHead*)new WellHead;
File->Read(&TempInt,sizeof(int));
str=(char*)new char[TempInt+1];
File->Read(str,TempInt);
str[TempInt]=0;
TempHead->No=(AnsiString)str;
delete str;
File->Read(&TempInt,sizeof(int));
if(TempInt)
{
TempHead->Fixed=true;
}
else
{
TempHead->Fixed=false;
}
TempHead->Next=0;
TempHead->Sub=0;
TempHead->Well=0;
SubHead=0;
CurrentHead->Next=TempHead;
CurrentHead=TempHead;
SubH=false;
break;
case 3:
TempHead=(WellHead*)new WellHead;
File->Read(&TempInt,sizeof(int));
str=(char*)new char[TempInt+1];
File->Read(str,TempInt);
str[TempInt]=0;
TempHead->No=(AnsiString)str;
delete str;
File->Read(&TempInt,sizeof(int));
if(TempInt)
{
TempHead->Fixed=true;
}
else
{
TempHead->Fixed=false;
}
TempHead->Next=0;
TempHead->Sub=0;
TempHead->Well=0;
SubHead=0;
Head->Sub=TempHead;
CurrentHead=TempHead;
break;
}
}
delete File;
AnsiString TempStr;
RichEdit->Lines->Clear();
RichEdit->Paragraph->Numbering = nsNone;
RichEdit->Paragraph->Alignment = taCenter;
RichEdit->Lines->Add("");
RichEdit->Lines->Add("****优化结果****");
RichEdit->Lines->Add("");
ADOResult->TableName="over";
ADOResult->Open();
ADOResult->First();
ADOResult->MoveBy(Selected);
RichEdit->Lines->Add("总体统计");
RichEdit->Paragraph->Numbering = nsBullet;
RichEdit->Paragraph->Alignment = taLeftJustify;
RichEdit->Paragraph->FirstIndent = 10;
TempStr=ADOResult->FieldByName("位置")->AsString;
TempStr="油井范围:"+TempStr;
RichEdit->Lines->Add(TempStr);
RichEdit->Paragraph->Numbering = nsBullet;
TempDouble=ADOResult->FieldByName("耗钢量")->AsFloat;
TempStr=TempStr.sprintf("%.4lf吨",TempDouble/1000);
RichEdit->Lines->Add("总耗钢量:"+TempStr);
RichEdit->Paragraph->Numbering = nsBullet;
TempInt=ADOResult->FieldByName("增压点")->AsInteger;
TempStr=TempStr.sprintf("%d",TempInt);
RichEdit->Lines->Add("增压点个数:"+TempStr);
RichEdit->Paragraph->Numbering = nsBullet;
TempInt=ADOResult->FieldByName("转油站")->AsInteger;
TempStr=TempStr.sprintf("%d",TempInt);
RichEdit->Lines->Add("转油站个数:"+TempStr);
RichEdit->Paragraph->Numbering = nsBullet;
TempDouble=ADOResult->FieldByName("流量")->AsFloat;
TempStr=TempStr.sprintf("%.2lf吨/天",TempDouble*3600*24/1000);
RichEdit->Lines->Add("总输量:"+TempStr);
CurrentHead=Head->Sub;
if(CurrentHead!=0)
{
ADOResult->Close();
ADOResult->TableName=Station;
ADOResult->CursorLocation=clUseServer;
ADOResult->CursorType=ctKeyset;
ADOResult->TableDirect=true;
ADOResult->IndexName="PrimaryKey";
ADOResult->Open();
if(ADOResult->Seek(Variant(CurrentHead->No),soFirstEQ))
{
if(CurrentHead->Fixed)
{
TempStr=ADOResult->FieldByName("编号")->AsString;
RichEdit->Paragraph->Numbering = nsNone;
RichEdit->Paragraph->Alignment = taLeftJustify;
RichEdit->Paragraph->FirstIndent = 10;
RichEdit->Lines->Add(TempStr+AnsiString(":(已建)"));
TempDouble=ADOResult->FieldByName("流量")->AsFloat;
TempStr=TempStr.sprintf("新流量:%.2ft/d",TempDouble*3600*24/1000);
RichEdit->Paragraph->Numbering = nsNone;
RichEdit->Paragraph->Alignment = taLeftJustify;
RichEdit->Paragraph->FirstIndent = 30;
RichEdit->Lines->Add(TempStr);
TempDouble=ADOResult->FieldByName("最低出站温度")->AsFloat;
TempStr=TempStr.sprintf("原来流量:%.2ft/d",TempDouble*3600*24/1000);
RichEdit->Paragraph->Numbering = nsNone;
RichEdit->Paragraph->Alignment = taLeftJustify;
RichEdit->Paragraph->FirstIndent = 30;
RichEdit->Lines->Add(TempStr);
TempDouble=ADOResult->FieldByName("最低出站压力")->AsFloat;
TempStr=TempStr.sprintf("现在流量:%.2ft/d",TempDouble*3600*24/1000);
RichEdit->Paragraph->Numbering = nsNone;
RichEdit->Paragraph->Alignment = taLeftJustify;
RichEdit->Paragraph->FirstIndent = 30;
RichEdit->Lines->Add(TempStr);
}
else
{
TempStr=ADOResult->FieldByName("编号")->AsString;
RichEdit->Paragraph->Numbering = nsNone;
RichEdit->Paragraph->Alignment = taLeftJustify;
RichEdit->Paragraph->FirstIndent = 10;
RichEdit->Lines->Add(TempStr+AnsiString(":(新建)"));
TempDouble=ADOResult->FieldByName("流量")->AsFloat;
TempStr=TempStr.sprintf("流量:%.2ft/d",TempDouble*3600*24/1000);
}
}
if(ADOResult->Seek(Variant(Head->No),soFirstEQ))
{
if(Head->Fixed)
{
TempStr=ADOResult->FieldByName("编号")->AsString;
RichEdit->Paragraph->Numbering = nsNone;
RichEdit->Paragraph->Alignment = taLeftJustify;
RichEdit->Paragraph->FirstIndent = 10;
RichEdit->Lines->Add(TempStr+AnsiString(":(已建)"));
TempDouble=ADOResult->FieldByName("流量")->AsFloat;
TempStr=TempStr.sprintf("新流量:%.2ft/d",TempDouble*3600*24/1000);
RichEdit->Paragraph->Numbering = nsNone;
RichEdit->Paragraph->Alignment = taLeftJustify;
RichEdit->Paragraph->FirstIndent = 30;
RichEdit->Lines->Add(TempStr);
TempDouble=ADOResult->FieldByName("最低出站温度")->AsFloat;
TempStr=TempStr.sprintf("原来流量:%.2ft/d",TempDouble*3600*24/1000);
RichEdit->Paragraph->Numbering = nsNone;
RichEdit->Paragraph->Alignment = taLeftJustify;
RichEdit->Paragraph->FirstIndent = 30;
RichEdit->Lines->Add(TempStr);
TempDouble=ADOResult->FieldByName("最低出站压力")->AsFloat;
TempStr=TempStr.sprintf("现在流量:%.2ft/d",TempDouble*3600*24/1000);
RichEdit->Paragraph->Numbering = nsNone;
RichEdit->Paragraph->Alignment = taLeftJustify;
RichEdit->Paragraph->FirstIndent = 30;
RichEdit->Lines->Add(TempStr);
}
else
{
TempStr=ADOResult->FieldByName("编号")->AsString;
RichEdit->Paragraph->Numbering = nsNone;
RichEdit->Paragraph->Alignment = taLeftJustify;
RichEdit->Paragraph->FirstIndent = 10;
RichEdit->Lines->Add(TempStr+AnsiString(":(新建)"));
TempDouble=ADOResult->FieldByName("流量")->AsFloat;
TempStr=TempStr.sprintf("流量:%.2ft/d",TempDouble*3600*24/1000);
}
}
}
ADOResult->Close();
ADOResult->TableName=Pipe;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -