Структура вычислительной системы: трехмерная с размерностью 4х4х3, страница 4

#include "vkss1.h"

#include "Vkss1Dlg.h"

#include "zadacha.h"

#include "cpu.h"

#include "MainFrm.h"

#ifdef _DEBUG

#define new DEBUG_NEW

#undef THIS_FILE

static char THIS_FILE[] = __FILE__;

#endif

CVkss1Dlg::CVkss1Dlg(CWnd* pParent /*=NULL*/)

                  : CDialog(CVkss1Dlg::IDD, pParent)

{kolzocher=0;

                  //{{AFX_DATA_INIT(CVkss1Dlg)

                  m_P = 1;

                  m_time = 1;

                  m_numzp = 1;

                  m_ndelcpu = 1;

                  //}}AFX_DATA_INIT

                  m_kolz=0;

CMainFrame *pp=(CMainFrame*)(AfxGetApp()->m_pMainWnd);

                                    for (int i=0;i<48;i++)

                  {

                                    m_pcpu[i]=new cpu(i+1);

                                    pp->pcpumf[i]=m_pcpu[i];

                                    if(m_pcpu[i]==NULL)AfxMessageBox("Не могу выделить память");

                  }

                  for (int i1=0;i1<100;i1++) m_pz[i1]=NULL;

}

CVkss1Dlg::~CVkss1Dlg()

{//AfxMessageBox("faaaaaaaaaaaa");}

void CVkss1Dlg::DoDataExchange(CDataExchange* pDX)

{

                  CDialog::DoDataExchange(pDX);

                  DDX_Control(pDX, IDC_Lcpu, m_Lcpu);

                  DDX_Text(pDX, IDC_EDIT1, m_P);

                  DDV_MinMaxInt(pDX, m_P, 1, 4800);

                  DDX_Text(pDX, IDC_EDIT2, m_time);

                  DDV_MinMaxInt(pDX, m_time, 1, 50);

                  DDX_Text(pDX, IDC_EDIT3, m_numzp);

                  DDX_Text(pDX, IDC_ndelcpu, m_ndelcpu);

                  DDV_MinMaxInt(pDX, m_ndelcpu, 1, 48);

}

BEGIN_MESSAGE_MAP(CVkss1Dlg, CDialog)

                  //{{AFX_MSG_MAP(CVkss1Dlg)

                  ON_BN_CLICKED(IDC_BUTTON1, OnAddZad)

                  ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1)

                  ON_EN_CHANGE(IDC_ndelcpu, OnChangendelcpu)

                  ON_BN_CLICKED(IDC_Clok, OnClok)

                  ON_WM_DESTROY()

                  ON_BN_CLICKED(IDC_delcpu, Ondelcpu)

                  ON_EN_CHANGE(IDC_EDIT2, OnChangeEdit2)

                  //}}AFX_MSG_MAP

END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////

void CVkss1Dlg::OnAddZad()

{

                  // TODO: Add your control notification handler code here

                  UpdateData(TRUE);

                  if(m_P<1||m_P>4800)

                  {AfxMessageBox("Введите мощность от 1 до 4800");return;}

                  if(m_time<1||m_time>4800)

                  {AfxMessageBox("Введите время от 1 до 50");return;}

                  if(m_kolz>99)

                  {AfxMessageBox("Система расчитана только на 100 задач. Дождитесь окончания выполнения какой-нибудь задачи !");return;}

                  if((m_pz[m_kolz]=new zadacha)==NULL)

                  {AfxMessageBox("Не могу выделить память !");return;}

                  m_pz[m_kolz]->P=m_P;

                  m_pz[m_kolz]->time=m_time;

                  m_pz[m_kolz]->numzad=m_numzp;

                  int SumTr=0;

                  SumTr=SumT();

                  if(m_P>4800-SumTr)

                  {

                                    AfxMessageBox("Система перегружена!!! ВВод задачи невозможен");

                                    delete m_pz[m_kolz];

                                    return;

                  }

                  RasprZad(m_pz[m_kolz],m_P);

                  m_kolz++;

                  AddstrLcpu();

                  m_numzp++;

                  UpdateData(FALSE);

}

int CVkss1Dlg::SumT()

{

                  int SumTr=0;

                  for(int i=0;i<48;i++)

                  {if(m_pcpu[i]->bitrab==0){SumTr+=100;continue;}

                                    for(int j=1;j<=m_pcpu[i]->kolzad;j++)

                                    {