123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- #include "tank.h"
- #include <QJsonDocument>
- #include <QJsonArray>
- #include <QJsonObject>
- #include <QByteArray>
- //油气回收系统 外观检查项
- static QString vrs_visual_inspection_items[VRS_VISUAL_INSPECTION_ITEMS_NUM] ={
- "油气回收耦合阀",
- "通气阀",
- "油气回收阀",
- "密封盖",
- "气动联锁阀",
- "连接管路",
- "控制管路",
- "多仓油气管路并联"
- };
- //底部装油系统 外观检查项
- static QString bls_visual_inspection_items[BLS_VISUAL_INSPECTION_ITEMS_NUM] ={
- "卸油阀",
- "呼吸阀",
- "紧急切断阀",
- "连接管线",
- "防溢流系统"
- };
- Compartment::Compartment()
- {
- m_result.delta_sys_pressure= 0.0;
- m_result.pass_sys_pressure = false;
- m_result.delta_valve_pressure = 0.0;
- m_result.pass_valve_pressure = false;
- m_bpicReady=false;
- }
- Compartment::~Compartment()
- {
- }
- int Compartment::get_Roughadjust_timeout()
- {
- int timeout = 0;
- if(m_volume > 30000){
- timeout = 60*60;
- }else if(m_volume > 15000){
- timeout = 45*60;
- }else if(m_volume > 10000){
- timeout = 30*60;
- }else if(m_volume > 5000){
- timeout = 15*60;
- }else if(m_volume > 1000){
- timeout = 5*60;
- }else{
- timeout = 3*60;
- }
- timeout = 30*60;
- return timeout;
- }
- int Compartment::get_adjust_timeout()
- {
- int timeout = 0;
- if(m_volume > 9000){
- timeout = 5*60;
- }else if(m_volume > 7000){
- timeout = 5*60;
- }else if(m_volume > 5000){
- timeout = 5*60;
- }else if(m_volume > 3000){
- timeout = 5*60;
- }else if(m_volume > 1000){
- timeout = 5*60;
- }else{
- timeout = 5*60;
- }
- timeout = 15*60;
- return timeout;
- }
- void Compartment::clear_result()
- {
- m_result.pass_sys_pressure = false;
- m_result.pass_valve_pressure = false;
- m_result.sys_test_ok = false;
- m_result.valve_test_ok = false;
- m_bpicReady = false;
- }
- Tanker::Tanker()
- {
- for(int i =0; i< VRS_VISUAL_INSPECTION_ITEMS_NUM; i++){
- vrs_results[i] = RESULT_QUALIFIED;
- }
- for(int i=0; i< BLS_VISUAL_INSPECTION_ITEMS_NUM; i++){
- bls_results[i] = RESULT_QUALIFIED;
- }
- }
- Tanker::~Tanker()
- {
- }
- Compartment& Tanker::get_compartment(int id)
- {
- return m_comparts[id];
- }
- QJsonObject Tanker::get_vrs_items()
- {
- QJsonObject jsonObj;
- jsonObj.insert("count", VRS_VISUAL_INSPECTION_ITEMS_NUM);
- QJsonArray itemsArray;
- for(int i=0; i < VRS_VISUAL_INSPECTION_ITEMS_NUM; i++){
- QJsonObject itemObj;
- //itemObj.insert("index", i);
- itemObj.insert("name", vrs_visual_inspection_items[i]);
- itemObj.insert("value", QString::number(vrs_results[i]));
- itemsArray.append(itemObj);
- }
- jsonObj.insert("item", itemsArray);
- return jsonObj;
- }
- QJsonObject Tanker::get_bls_items()
- {
- QJsonObject jsonObj;
- jsonObj.insert("count", BLS_VISUAL_INSPECTION_ITEMS_NUM);
- QJsonArray itemsArray;
- for(int i=0; i < BLS_VISUAL_INSPECTION_ITEMS_NUM; i++){
- QJsonObject itemObj;
- //jsonObj.insert("index", i);
- itemObj.insert("name", bls_visual_inspection_items[i]);
- itemObj.insert("value", QString::number(bls_results[i]));
- itemsArray.append(itemObj);
- }
- jsonObj.insert("item", itemsArray);
- return jsonObj;
- }
- bool Tanker::set_item_result(const QString& jsonStr )
- {
- QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonStr.toUtf8());
- QJsonObject jsonObj = jsonDoc.object();
- QString table_str;
- QString item_name_str;
- int value = RESULT_QUALIFIED;
- if(jsonObj.contains("table") && jsonObj.value("table").isString()){
- table_str = jsonObj.value("table").toString();
- }else{
- qDebug() << "set_item_result no table";
- return false;
- }
- if(jsonObj.contains("name") && jsonObj.value("name").isString()){
- item_name_str = jsonObj.value("name").toString();
- }else{
- qDebug() << "set_item_result no name";
- return false;
- }
- if(jsonObj.contains("value") && jsonObj.value("value").isString()){
- value = jsonObj.value("value").toString().toInt();
- }else{
- qDebug() << "set_item_result no value";
- return false;
- }
- qDebug() << "table:" << table_str;
- if(table_str == "vrs"){
- for(int i=0; i<VRS_VISUAL_INSPECTION_ITEMS_NUM; i++){
- if(item_name_str == vrs_visual_inspection_items[i]){
- if(value >= RESULT_QUALIFIED && value <= RESULT_NOITEM){
- vrs_results[i] = value;
- qDebug() << "item_name:" << item_name_str;
- qDebug() << "value:" << value;
- }
- }
- }
- }else if(table_str == "bls"){
- for(int i=0; i<BLS_VISUAL_INSPECTION_ITEMS_NUM; i++){
- if(item_name_str == bls_visual_inspection_items[i]){
- if(value >= RESULT_QUALIFIED && value <= RESULT_NOITEM){
- vrs_results[i] = value;
- qDebug() << "item_name:" << item_name_str;
- qDebug() << "value:" << value;
- }
- }
- }
- }else{
- qDebug() << "set_item_result table_str invalid";
- return false;
- }
- return true;
- }
|