Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > C/C++ программирование > Общие вопросы C/C++
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 19.10.2010, 19:38   #1
n-gage
Новичок
Джуниор
 
Регистрация: 19.10.2010
Сообщений: 1
По умолчанию с 2 функ.проблемы )

вот код,помогите дописать 2 функции для AllMesures
[CODE] //---------------------------------------------------------------------------

#ifndef CalibrateStatH
#define CalibrateStatH
//---------------------------------------------------------------------------

#include <stdio.h>
#include <vector>
#include <vcl.h>
#include <ScktComp.hpp>
#include <stdio.h>


/*// данные одного замера
struct OneMeasure{
int ohm;
int volt;
OneMeasure(int r, int u);
};
*/

// история изменений данных одного замера
struct MeasureDataHistory{
bool bGood;
std::vector<unsigned long> mBuffer;

void Add ( unsigned long measure);
void Reset ();
double MeanAllTime ();
double Mean5Last ();
long int DeviationLow5Last ();
long int DeviationHigh5Last ();
int CheckMeasureQuality();
int LastMeasure();
AnsiString GetString();
};

struct FileBaseR
{
FILE *f;
FileBaseR(const char* fname)
{
f= fopen(fname, "rb");
}
bool IsOpen()
{
return (f!=NULL);
}
virtual ~FileBaseR()
{
fclose(f);
}
};

struct FileBaseW
{
FILE *f;
FileBaseW(const char* fname)
{
f= fopen(fname, "wb");
}
~FileBaseW()
{
fclose(f);
}
};

void operator >> ( FileBaseR &f, unsigned long &val)
{
unsigned long v;
fread(&v,sizeof(unsigned long),1,f.f);
val = v;
}

void operator << ( FileBaseW &f, unsigned long &val)
{
unsigned long v= val;
fwrite(&v,sizeof(unsigned long),1,f.f);
}

void operator >> ( FileBaseR &f, MeasureDataHistory &in)
{
unsigned long nvals= 0;
unsigned long val= 0;
in.bGood = false;
in.mBuffer.clear();
f >> nvals;
while(nvals--)
{
f >> val;
in.mBuffer.push_back(val);
}
}

void operator << ( FileBaseW &f, MeasureDataHistory &out)
{
unsigned long nvals= out.mBuffer.size();
unsigned long i= 0;
f << nvals;
while(i<nvals)
{
f << out.mBuffer[i++];
}
}

struct DeviceCalibrationData
{
int tag;
MeasureDataHistory mPower[3];
MeasureDataHistory mFiders[7][12];

void AddMeasure(int fider, int type, unsigned long value)
{
if(type<3)
mPower[type].Add(value);
else
mFiders[type-3][fider].Add(value);
}

void ResetMeasure(int fider, int type)
{
if(type<3)
mPower[type].Reset();
else
mFiders[type-3][fider].Reset();
}

void Reset()
{
for(int i=0; i<120; ++i)
ResetMeasure( i/10, i%10);
}

MeasureDataHistory* GetHistory(int fider, int type)
{
if(type<3)
return &mPower[type];
else
return &mFiders[type-3][fider];
}
};
#define HEAD 0xFEEF
void operator >> ( FileBaseR &f, DeviceCalibrationData &in)
{
unsigned long head;
f >> head;
if(head != HEAD)
return;
unsigned long Num=0;
f >> Num;
while(Num)
{
if(Num < 4)
f >> in.mPower[Num-1];
else
{
unsigned long type= (Num - 4)/12;
unsigned long fider= (Num - 4)%12;
f >> in.mFiders[type][fider];
}
f >> Num;
}
}

void operator << ( FileBaseW &f, DeviceCalibrationData &out)
{
unsigned long head = HEAD;
f << head;

unsigned long Num=0;
while( Num++ < ( 7*12 + 3 ) )
{
f << Num;
if(Num < 4)
f << out.mPower[Num-1];
else
{
unsigned long type= (Num - 4)/12;
unsigned long fider= (Num - 4)%12;
f << out.mFiders[type][fider];
}
}
f << Num;
}


// данные всех замеров
struct AllMeasures
{
int mFider;
int mType;
int LastTag;
DeviceCalibrationData mAll[8];
AllMeasures();
~AllMeasures();
void ResetAll();
void ResetMeasure(int fider, int type);

void SetCurrentMeasure(int fider, int type)
{
mFider= fider;
mType= type;
}

void AddMeasure(int fider, int type, int tag, unsigned long value);
void AddCurrentMeasureValue(int tag, unsigned long value);

MeasureDataHistory* GetHistory(int fider, int type, int tag)
{
return mAll[tag].GetHistory(fider,type);
}
MeasureDataHistory* GetHistory(int tag)
{
return mAll[tag].GetHistory(mFider,mType);
}
};
//------------------------------------------------------------------------------
void operator << ( FileBaseW &f, AllMeasures &out)
{

}
//------------------------------------------------------------------------------

void operator >> ( FileBaseR &f, AllMeasures &in)
{

}
//------------------------------------------------------------------------------

bool IsDigit(char c);

int ToDigit(char c);
//------------------------------------------------------------------------------
n-gage вне форума Ответить с цитированием
Старый 20.10.2010, 19:55   #2
_ILYA_
Пользователь
 
Аватар для _ILYA_
 
Регистрация: 12.10.2010
Сообщений: 79
По умолчанию

слишком длинно, сузь поиск, сам понимаеш всем лень, будет строк 20-30 будут читать, а такой большой и плохо офрмленный текст всем будет просто лень разбирать
Имею хитрый план по личному обогащению
_ILYA_ вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Проблемы с С# PDV199003 Помощь студентам 0 04.06.2010 14:38
проблемы с if Vergil Общие вопросы C/C++ 8 21.04.2010 21:43
проблемы с GetProcAddress waryg Win Api 4 06.04.2010 11:30
проблемы с IE xakzona Помощь студентам 1 16.12.2008 21:53