ПЗ (1229304), страница 11
Текст из файла (страница 11)
"---------------------------------------------\r\n"
"Ст-ть 1-цы прироста фондов:\t" + FloatToStr(pow_inc_price) + "\r\n"
"Ур-нь мощности фондов:\t\t" + FloatToStr(pow_cur_lev) + "\r\n"
"---------------------------------------------\r\n"
"Ст-ть 1-цы прироста НИР:\t\t" + IntToStr(SRW_inc_price) + "\r\n"
"---------------------------------------------\r\n"
"Кол-во покупателей:\t\t" + IntToStr(V_market) + "\r\n"
"---------------------------------------------\r\n"
"Макс. займ у банка:\t\t" + FloatToStr(max_occupy) + "\r\n"
"Банковский процент:\t\t" + IntToStr(bank_perc) + "\r\n"
"---------------------------------------------\r\n"
"Налоговая ставка:\t\t" + FloatToStr(tax) + "\r\n"
"---------------------------------------------\r\n"
"Время шага:\t\t\t" + IntToStr(Timer);
return report;
}
//----------------------------------------------------------------------------
void* MakeBuf(int * pdatasz, UnicodeString ustr)
{
void* pBuf = 0;
int length = ustr.Length();
*pdatasz = sizeof(length)+sizeof(wchar_t)*(length);
pBuf = malloc(*pdatasz);
*((int*)pBuf)=length;
for (int i=0; i < length; i++) {
((wchar_t*)(((int*)(pBuf))+1))[i]=ustr[i+1];
}
return pBuf;
};
//----------------------------------------------------------------------------
void ReadUSFromBuf(TCustomIpClient *ClientSocket, UnicodeString* p_result_string)
{
int length = 0;
ClientSocket->ReceiveBuf(&length,sizeof(int),0);
length++;
wchar_t * fff = new wchar_t [length];
memset(fff,0,length*sizeof(wchar_t));
ClientSocket->ReceiveBuf(fff,length*sizeof(wchar_t),0);
*p_result_string = fff;
delete[]fff;
};
//----------------------------------------------------------------------------
Модуль UClient
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <math.h>
#include "UConnect.h"
#include "UCFuncList.h"
#include "UClient.h"
#include "UReports.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "Chart"
#pragma link "TeEngine"
#pragma link "TeeProcs"
#pragma link "Series"
#pragma link "GanttCh"
#pragma resource "*.dfm"
TForm1 *Form1;
TMemo *Memo;
TStringList *SList;
TStringList *SList2;
//////Наличность////////
double cur_cash, cur_cash2, // текущие накопления (денежные единицы)
gross_profit, gross_profit2; // валовая прибыль
////////////////////////
//////Фонды/////////////
int inv,inv2; // ввод пользователя: инвестиции в фонды
double pow_cur_lev,pow_cur_lev2, // текущий уровень мощности (фондов)
pow_inc_price,pow_inc_price2; // начальная стоимость 1-цы прироста фондов
////////////////////////
//////Нир///////////////
double SRW_level,SRW_level2; // текущий уровень НИР
int inv_SRW,inv_SRW2, // инвестиции в НИР
SRW_inc_price,SRW_inc_price2, // стоимость 1-цы прироста НИР
SRW_start_inc_price,SRW_start_inc_price2; // начальня стоимость 1-цы прироста НИР
////////////////////////
//////Выпуск товара/////
int st_inner_price,st_inner_price2, // начальная цена товара
planed_output,planed_output2, // запланированный выпуск продукции
pow_use_lev,pow_use_lev2; // выпуск
double cur_inn_price,cur_inn_price2, // текущая себестоимость товара
trg_inn_price,trg_inn_price2, // целевая себестоимость
trg_output,trg_output2; // стоимость (price)
////////////////////////
/////////Цена///////////
int price_prod,price_prod2; // цена (может быть double?)
////////////////////////
//////кредит банка//////
double max_occupy,max_occupy2, // максимальный кредит банка
cur_occupy,cur_occupy2, // текущий займ у банка
step_occupy,step_occupy2; // занял на текущем шаге
int bank_perc,bank_perc2, // банковский кредит
repayment,repayment2; // Возврат долга банку (может быть double?)
////////////////////////
//////Маркетинг/////////
int marketing,marketing2; // Маркетинг
////////////////////////
///Привлекательность////
double attractivness,attractivness2; //
////////////////////////
////////Рынок///////////
int V_market,V_market2, // объем рынка
USD,USD2, // up, stable, down
NoBuy,NoBuy2; // Те кто не купил товар
////////////////////////
/////амортизация////////
int amort_perc,amort_perc2; // процент амортизации на один шаг
double pow_load,pow_load2, // загрузка
cur_amort_perc,cur_amort_perc2;// текущая амортизация
////////////////////////
/////////Налог//////////
double tax,tax2; // налоговая ставка
////////////////////////
//////доли рынка////////
int part_mark,part_mark2, // доля рынка по маркетинку
part_attr,part_attr2; // доля рынка по привлекательности
double part_sold,part_sold2, // доля рынка в продукции
part_gross_profit,part_gross_profit2;// доля рынка в деньгах
////////////////////////
////////Другие//////////
int store,store2, // склад
sold,sold2, // продано кол-во штук
Number_Client, Number_Client2, // Порядковый номер клиента
Timer,Timer2; // Время за которое игрок должен отправить данные
////////////////////////
int TimeOff = 0;
AnsiString Name_of_client="", // Имя клиента
Name_of_sim="", // Имя симуляции
otchet;
bool Show_Main_Form = false;
const int server_port = 55555;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
TcpClient1 = new TTcpClient(this);
TcpServer1 = new TTcpServer(this);
TcpServer1->OnAccept = TcpServer1Accept;
TcpServer1->LocalPort = server_port;
TcpServer1->Active = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ListBox1DblClick(TObject *Sender)
{
int index = ListBox1->ItemIndex;
TMemo *Memo = new TMemo(this);
Memo->ManualDock(Panel1,NULL,alRight);
Memo->DragKind = dkDock;
Memo->ScrollBars = ssBoth;
Memo->Lines->Add(ListBox1->Items->Strings[index]);
Memo->Lines->Add(SList->Strings[index]);
Receive_Inf2(SList2->Strings[index]);
/*Все параметры которые не меняются в течении симуляции отражать нет смысла*/
Form1->Series2->Clear();
Form1->Series2->Add(cur_cash2,"денежные единицы",clGreen);
Form1->Series2->Add(gross_profit2,"валовая прибыль",clGreen);
Form1->Series2->Add(pow_cur_lev2,"текущий уровень мощности (фондов)",clWhite);
Form1->Series2->Add(SRW_level2,"текущий уровень НИР",clWhite);
Form1->Series2->Add(pow_use_lev2,"выпуск",clBlue);
Form1->Series2->Add(store2,"склад",clBlue);
Form1->Series2->Add(sold2,"продано кол-во штук",clBlue);
Form1->Series2->Add(V_market2,"объем рынка",clAqua);
Form1->Series2->Add(cur_inn_price2,"текущая себестоимость товара",clYellow);
Form1->Series2->Add(trg_output2,"стоимость",clYellow);
Form1->Series2->Add(cur_occupy2,"текущий займ у банка",clRed);
Form1->Series2->Add(repayment2,"Возврат долга банку",clRed);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
// Посылаем серверу сигнал, что клиент продолжать симуляцию не будет.
Form1->TcpClient1->Active = true;
if (TcpClient1->Connect())
{
int datasz = 0;
void* pBuf = MakeBuf(&datasz,"Disconnect: Number_Client " + IntToStr(Number_Client));
Form1->TcpClient1->SendBuf(pBuf, datasz ,0);
Form1->TcpClient1->Active = false;
free(pBuf);
}
if (TcpServer1->Active == true)
TcpServer1->Active = false;
Application->Terminate();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
SList = new TStringList();
SList2 = new TStringList();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::LEFondKeyPress(TObject *Sender, wchar_t &Key)
{
Set <char, '0', '9'> Dig;
Dig << '0' << '1' << '2' << '3' << '4' << '5'
<< '6' << '7' << '8' << '9';
if (!Dig.Contains(Key))
{Key=8; Beep(); }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::LEFondChange(TObject *Sender)
{
if (NoMoney())
Form1->LEFond->Text = 0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::LENIRKeyPress(TObject *Sender, wchar_t &Key)
{
Set <char, '0', '9'> Dig;
Dig << '0' << '1' << '2' << '3' << '4' << '5'
<< '6' << '7' << '8' << '9';
if (!Dig.Contains(Key))
{Key=8; Beep(); }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::LENIRChange(TObject *Sender)
{
if (NoMoney())
Form1->LEFond->Text = 0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::LEMarkKeyPress(TObject *Sender, wchar_t &Key)
{
Set <char, '0', '9'> Dig;
Dig << '0' << '1' << '2' << '3' << '4' << '5'
<< '6' << '7' << '8' << '9';
if (!Dig.Contains(Key))
{Key=8; Beep(); }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::LEMarkChange(TObject *Sender)
{
if (NoMoney())
Form1->LEFond->Text = 0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BSendServClick(TObject *Sender)
{
UnicodeString s;
s = Send_Inf();
TcpClient1->Active = true;
if (!TcpClient1->Connect())
{
Application->MessageBox(L"Данные не переданы, нет контакта с сервером!",
L"Внимание", MB_ICONWARNING) ;
}
else
{
int datasz = 0;
void* pBuf = MakeBuf(&datasz,s);
Form1->TcpClient1->SendBuf(pBuf, datasz ,0);
Form1->TcpClient1->Active = false;
free(pBuf);
Timer1->Enabled = false;
// заблокировали кнопку
BSendServ->Enabled = false;
TimeOff = 0;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::LabeledEdit4KeyPress(TObject *Sender, wchar_t &Key)
{
Set <char, '0', '9'> Dig;
Dig << '0' << '1' << '2' << '3' << '4' << '5'
<< '6' << '7' << '8' << '9';
if (!Dig.Contains(Key))
{Key=8; Beep(); }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::LabeledEdit5KeyPress(TObject *Sender, wchar_t &Key)
{
Set <char, '0', '9'> Dig;
Dig << '0' << '1' << '2' << '3' << '4' << '5'
<< '6' << '7' << '8' << '9';
if (!Dig.Contains(Key))
{Key=8; Beep(); }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::LabeledEdit6KeyPress(TObject *Sender, wchar_t &Key)
{
Set <char, '0', '9'> Dig;
Dig << '0' << '1' << '2' << '3' << '4' << '5'
<< '6' << '7' << '8' << '9';
if (!Dig.Contains(Key))
{Key=8; Beep(); }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormDestroy(TObject *Sender)















