164 lines
5.3 KiB
C++
164 lines
5.3 KiB
C++
#include "LayerStatus.h"
|
|
|
|
|
|
|
|
LayerStatus::LayerStatus()
|
|
:m_Id(0)
|
|
, m_JobId(0)
|
|
, m_JobName("")
|
|
, m_LayerIndex(0)
|
|
, m_InsertTitme(0)
|
|
,m_MoldMainPos(0.0)
|
|
,m_MoldSlavePos(0.0)
|
|
,m_PrintOxygen1(0.0f)
|
|
,m_PrintOxygen2(0.0f)
|
|
,m_OutsideOxygen(0.0f)
|
|
,m_PrintTemp1(0.0f)
|
|
,m_PrintTemp2(0.0f)
|
|
,m_PrintHumidity1(0.0f)
|
|
,m_PrintHumidity2(0.0f)
|
|
,m_PrintPressure(0.0f)
|
|
, m_FanFrequency(0.0f)
|
|
,m_PlateTemp(0.0f)
|
|
,m_WindRate(0.0f)
|
|
,m_LaserWaterTemp(0.0f)
|
|
,m_ScannerWaterTemp(0.0f)
|
|
,m_PurifierWaterTemp(0.0f)
|
|
{
|
|
}
|
|
|
|
|
|
LayerStatus::~LayerStatus()
|
|
{
|
|
}
|
|
|
|
void LayerStatus::CreateIfNoExist(SQLite::Database* db)
|
|
{
|
|
if (db == nullptr)return;
|
|
char buffer[1024];
|
|
if (db->tableExists(STATUS_TABLE_NAME))
|
|
{
|
|
sprintf_s(buffer, sizeof(buffer), "SELECT * FROM %s LIMIT 0", STATUS_TABLE_NAME.c_str());
|
|
SQLite::Statement query(*db, buffer);
|
|
//if (query.executeStep()) {
|
|
try {
|
|
query.getColumnIndex(STATUS_FIELD_FAN_FREQUENCY.c_str());
|
|
}
|
|
catch (SQLite::Exception&) {
|
|
sprintf_s(buffer, "ALTER TABLE %s ADD COLUMN %s INTEGER", STATUS_TABLE_NAME.c_str(), STATUS_FIELD_FAN_FREQUENCY.c_str());
|
|
db->exec(buffer);
|
|
sprintf_s(buffer, "UPDATE %s SET %s=0", STATUS_TABLE_NAME.c_str(), STATUS_FIELD_FAN_FREQUENCY.c_str());
|
|
db->exec(buffer);
|
|
}
|
|
return;
|
|
}
|
|
|
|
string createsql = "CREATE TABLE IF NOT EXISTS %s(%s INTEGER PRIMARY KEY AUTOINCREMENT,\
|
|
%s LONG,%s INTEGER,%s INTEGER,%s INTEGER,%s REAL, %s REAL,\
|
|
%s REAL,%s REAL,%s REAL,%s REAL,%s REAL,%s REAL,%s REAL,%s REAL,%s REAL,%s REAL,%s REAL,%s REAL,%s REAL,%s REAL)";
|
|
sprintf_s(buffer, sizeof(buffer), createsql.c_str(),
|
|
STATUS_TABLE_NAME.c_str(),
|
|
STATUS_FIELD_ID.c_str(),
|
|
STATUS_FIELD_INSERT_TIME.c_str(),
|
|
STATUS_FIELD_JOB_ID.c_str(),
|
|
STATUS_FIELD_LAYER_INDEX.c_str(),
|
|
STATUS_FIELD_SPEND_SECOND.c_str(),
|
|
STATUS_FIELD_MOLD_MAIN_POS.c_str(),
|
|
STATUS_FIELD_MOLD_SLAVE_POS.c_str(),
|
|
STATUS_FIELD_PRINT_OXYGEN1.c_str(),
|
|
STATUS_FIELD_PRINT_OXYGEN2.c_str(),
|
|
STATUS_FIELD_OUTSIDE_OXYGEN.c_str(),
|
|
STATUS_FIELD_PRINT_TEMP1.c_str(),
|
|
STATUS_FIELD_PRINT_TEMP2.c_str(),
|
|
STATUS_FIELD_PRINT_HUMIDITY1.c_str(),
|
|
STATUS_FIELD_PRINT_HUMIDITY2.c_str(),
|
|
STATUS_FIELD_PRINT_PRESSURE.c_str(),
|
|
STATUS_FIELD_FAN_FREQUENCY.c_str(),
|
|
STATUS_FIELD_PLATE_TEMP.c_str(),
|
|
STATUS_FIELD_WIND_RATE.c_str(),
|
|
STATUS_FIELD_LASER_WATER_TEMP.c_str(),
|
|
STATUS_FIELD_SCANNER_WATER_TEMP.c_str(),
|
|
STATUS_FIELD_PURIFIER_WATER_TEMP.c_str()
|
|
);
|
|
db->exec(buffer);
|
|
|
|
sprintf_s(buffer, sizeof(buffer), "CREATE INDEX IF NOT EXISTS idx_%s_%s ON %s (%s)",
|
|
STATUS_TABLE_NAME.c_str(),
|
|
STATUS_FIELD_JOB_ID.c_str(),
|
|
STATUS_TABLE_NAME.c_str(),
|
|
STATUS_FIELD_JOB_ID.c_str()
|
|
);
|
|
db->exec(buffer);
|
|
|
|
sprintf_s(buffer, sizeof(buffer), "CREATE INDEX IF NOT EXISTS idx_%s_%s ON %s (%s,%s,%s)",
|
|
STATUS_TABLE_NAME.c_str(),
|
|
STATUS_FIELD_INSERT_TIME.c_str(),
|
|
STATUS_TABLE_NAME.c_str(),
|
|
STATUS_FIELD_INSERT_TIME.c_str(),
|
|
STATUS_FIELD_JOB_ID.c_str(),
|
|
STATUS_FIELD_LAYER_INDEX.c_str()
|
|
);
|
|
db->exec(buffer);
|
|
|
|
}
|
|
|
|
const string LayerStatus::STATUS_TABLE_NAME = "Status";
|
|
const string LayerStatus::STATUS_FIELD_ID = "id";
|
|
const string LayerStatus::STATUS_FIELD_JOB_ID = "job";
|
|
const string LayerStatus::STATUS_FIELD_LAYER_INDEX = "layer_index";
|
|
const string LayerStatus::STATUS_FIELD_INSERT_TIME = "insert_time";
|
|
const string LayerStatus::STATUS_FIELD_SPEND_SECOND = "spend_second";
|
|
const string LayerStatus::STATUS_FIELD_MOLD_MAIN_POS="mold_main_pos";
|
|
const string LayerStatus::STATUS_FIELD_MOLD_SLAVE_POS="mold_slave_pos";
|
|
const string LayerStatus::STATUS_FIELD_PRINT_OXYGEN1="print_oxygen1";
|
|
const string LayerStatus::STATUS_FIELD_PRINT_OXYGEN2="print_oxygen2";
|
|
const string LayerStatus::STATUS_FIELD_OUTSIDE_OXYGEN="outside_oxygen";
|
|
const string LayerStatus::STATUS_FIELD_PRINT_TEMP1="print_temp1";
|
|
const string LayerStatus::STATUS_FIELD_PRINT_TEMP2="print_temp2";
|
|
const string LayerStatus::STATUS_FIELD_PRINT_HUMIDITY1="print_humidity1";
|
|
const string LayerStatus::STATUS_FIELD_PRINT_HUMIDITY2="print_humidity2";
|
|
const string LayerStatus::STATUS_FIELD_PRINT_PRESSURE="print_pressure";
|
|
const string LayerStatus::STATUS_FIELD_FAN_FREQUENCY = "fan_frequency";
|
|
const string LayerStatus::STATUS_FIELD_PLATE_TEMP="plate_temp";
|
|
const string LayerStatus::STATUS_FIELD_WIND_RATE="wind_rate";
|
|
const string LayerStatus::STATUS_FIELD_LASER_WATER_TEMP="laser_water_temp";
|
|
const string LayerStatus::STATUS_FIELD_SCANNER_WATER_TEMP="scanner_water_temp";
|
|
const string LayerStatus::STATUS_FIELD_PURIFIER_WATER_TEMP="purifier_water_temp";
|
|
|
|
LayerStatusMaximum::LayerStatusMaximum()
|
|
{
|
|
m_MinMaxPrintOxygen1[0]=0.0f;
|
|
m_MinMaxPrintOxygen2[0]=0.0f;
|
|
m_MinMaxOutsideOxygen[0]=0.0f;
|
|
m_MinMaxPrintTemp1[0]=0.0f;
|
|
m_MinMaxPrintTemp2[0]=0.0f;
|
|
m_MinMaxPringHumidity1[0]=0.0f;
|
|
m_MinMaxPringHumidity2[0]=0.0f;
|
|
m_MinMaxPrintPressure[0]=0.0f;
|
|
m_MinMaxFanFrequency[0] = 0.0f;
|
|
m_MinMaxPlateTemp[0]=0.0f;
|
|
m_MinMaxWindRate[0]=0.0f;
|
|
m_MinMaxLaserWaterTemp[0]=0.0f;
|
|
m_MinMaxScannerWaterTemp[0]=0.0f;
|
|
m_MinMaxPurifierWaterTemp[0]=0.0f;
|
|
|
|
m_MinMaxPrintOxygen1[1]=0.0f;
|
|
m_MinMaxPrintOxygen2[1]=0.0f;
|
|
m_MinMaxOutsideOxygen[1]=0.0f;
|
|
m_MinMaxPrintTemp1[1]=0.0f;
|
|
m_MinMaxPrintTemp2[1]=0.0f;
|
|
m_MinMaxPringHumidity1[1]=0.0f;
|
|
m_MinMaxPringHumidity2[1]=0.0f;
|
|
m_MinMaxPrintPressure[1]=0.0f;
|
|
m_MinMaxFanFrequency[1] = 0.0f;
|
|
m_MinMaxPlateTemp[1]=0.0f;
|
|
m_MinMaxWindRate[1]=0.0f;
|
|
m_MinMaxLaserWaterTemp[1]=0.0f;
|
|
m_MinMaxScannerWaterTemp[1]=0.0f;
|
|
m_MinMaxPurifierWaterTemp[1]=0.0f;
|
|
}
|
|
|
|
LayerStatusMaximum::~LayerStatusMaximum()
|
|
{
|
|
|
|
} |