1998-09-28 07:37:18 +00:00
|
|
|
// Gestione parametri ditta MRP
|
|
|
|
|
|
|
|
#ifndef __CONFAPP_H
|
|
|
|
#include <confapp.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "mrplib.h"
|
|
|
|
#include "mr0400.h"
|
|
|
|
|
|
|
|
#define NTURNI 8
|
|
|
|
|
|
|
|
class TConf_MRP_mask : public TCalendar_mask
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
|
|
|
|
|
|
|
public:
|
|
|
|
TConf_MRP_mask(const char* name, int num = 0);
|
|
|
|
virtual ~TConf_MRP_mask();
|
|
|
|
};
|
|
|
|
|
|
|
|
bool TConf_MRP_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
TConf_MRP_mask::TConf_MRP_mask(const char* name, int num)
|
|
|
|
: TCalendar_mask(name, num)
|
|
|
|
{
|
|
|
|
set_handlers();
|
|
|
|
}
|
|
|
|
|
|
|
|
TConf_MRP_mask::~TConf_MRP_mask()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////
|
|
|
|
// TConf_MRP_application
|
|
|
|
//////////////////////////////////////////////////
|
|
|
|
class TConf_MRP_application : public TConfig_application
|
|
|
|
{
|
|
|
|
TMRP_calendar* _calendar;
|
1998-09-28 08:31:07 +00:00
|
|
|
TConf_MRP_mask *_mask;
|
1998-09-28 07:37:18 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual TMask* get_mask() { return _mask; }
|
1998-09-28 08:31:07 +00:00
|
|
|
virtual TMask* create_mask(const TFilename& f) { if (_mask == NULL) _mask = new TConf_MRP_mask(f); return _mask;}
|
|
|
|
virtual void destroy_mask() { delete _mask; _mask = NULL; }
|
1998-09-28 07:37:18 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
virtual bool preprocess_config (TMask& mask, TConfig& config);
|
|
|
|
virtual bool postprocess_config (TMask& mask, TConfig& config);
|
|
|
|
virtual bool user_create();
|
|
|
|
virtual bool user_destroy();
|
|
|
|
|
|
|
|
TConf_MRP_application() : TConfig_application(CONFIG_DITTA) { _mask = NULL; _calendar = NULL;}
|
|
|
|
virtual ~TConf_MRP_application() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
bool TConf_MRP_application::preprocess_config (TMask& mask, TConfig& config)
|
|
|
|
{
|
|
|
|
TToken_string ora_inizio("",':');
|
|
|
|
|
|
|
|
for (int i = 0; i < NTURNI; i++)
|
|
|
|
{
|
|
|
|
// Traduce le ore ed i minuti
|
|
|
|
const short h = F_T1HINIZIO+(i*4);
|
|
|
|
ora_inizio = config.get("TINIZIO","mr", i);
|
|
|
|
mask.set(h,ora_inizio.get(0)); // Hour...
|
|
|
|
mask.set(h+1,ora_inizio.get(1)); // Minutes...
|
|
|
|
const long tdurata = config.get_long("TDURATA", "mr", i);
|
|
|
|
const int hours = (int)tdurata / 60; // numero di ore
|
|
|
|
const int minutes = (int)tdurata % 60; // numero di minuti
|
|
|
|
mask.set(h+2, hours);
|
|
|
|
mask.set(h+3, minutes);
|
|
|
|
}
|
|
|
|
// Carica il calendario
|
|
|
|
TCalendar_field& cf = (TCalendar_field&)mask.field(F_CALENDAR);
|
|
|
|
cf.set_calendar(_calendar, mask.get_int(F_YEAR));
|
|
|
|
cf.win().force_update();
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TConf_MRP_application::postprocess_config (TMask& mask, TConfig& config)
|
|
|
|
{
|
|
|
|
TToken_string ora_inizio("",':');
|
|
|
|
for (int i = 0; i < NTURNI; i++)
|
|
|
|
{
|
|
|
|
// Traduce le ore ed i minuti
|
|
|
|
const short h = F_T1HINIZIO+(i*4);
|
|
|
|
ora_inizio.add(mask.get(h),0); // Hour...
|
|
|
|
ora_inizio.add(mask.get(h+1),1); // Minutes
|
|
|
|
config.set("TINIZIO",ora_inizio,"mr", TRUE, i);
|
|
|
|
const int durata_h = mask.get_int(h+2);
|
|
|
|
const int durata_m = mask.get_int(h+3);
|
|
|
|
const long minutes = durata_h * 60 + durata_m;
|
|
|
|
config.set("TDURATA", minutes, "mr", TRUE, i);
|
|
|
|
}
|
1998-09-28 08:31:07 +00:00
|
|
|
config.set("GESTIMPIANTI", mask.get_bool(F_GESTIMPIANTI) ? "X" : "", "mr", TRUE);
|
|
|
|
config.set("NTURNI", mask.get(F_NTURNI), "mr", TRUE);
|
|
|
|
|
|
|
|
TString paragraph(config.get_paragraph());
|
|
|
|
config.set_paragraph(""); // Akkrokkio per salvare il calendario...
|
|
|
|
_calendar->write();
|
|
|
|
config.set_paragraph(paragraph); // re-read
|
1998-09-28 07:37:18 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TConf_MRP_application::user_create()
|
|
|
|
{
|
|
|
|
TConfig conf(CONFIG_DITTA);
|
|
|
|
conf.set( "EdMask", "mr0400a", "mr");
|
|
|
|
_calendar = new TMRP_calendar(); // Calendario standard
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TConf_MRP_application::user_destroy()
|
|
|
|
{
|
|
|
|
if (_calendar)
|
|
|
|
delete _calendar;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int mr0400(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
TConf_MRP_application app;
|
|
|
|
|
|
|
|
app.run(argc, argv, "Parametri gestione MRP");
|
|
|
|
return 0;
|
|
|
|
}
|