tank.cpp 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. #include "tank.h"
  2. #include <QJsonDocument>
  3. #include <QJsonArray>
  4. #include <QJsonObject>
  5. #include <QByteArray>
  6. //油气回收系统 外观检查项
  7. static QString vrs_visual_inspection_items[VRS_VISUAL_INSPECTION_ITEMS_NUM] ={
  8. "油气回收耦合阀",
  9. "通气阀",
  10. "油气回收阀",
  11. "密封盖",
  12. "气动联锁阀",
  13. "连接管路",
  14. "控制管路",
  15. "多仓油气管路并联"
  16. };
  17. //底部装油系统 外观检查项
  18. static QString bls_visual_inspection_items[BLS_VISUAL_INSPECTION_ITEMS_NUM] ={
  19. "卸油阀",
  20. "呼吸阀",
  21. "紧急切断阀",
  22. "连接管线",
  23. "防溢流系统"
  24. };
  25. Compartment::Compartment()
  26. {
  27. m_result.delta_sys_pressure= 0.0;
  28. m_result.pass_sys_pressure = false;
  29. m_result.delta_valve_pressure = 0.0;
  30. m_result.pass_valve_pressure = false;
  31. m_bpicReady=false;
  32. }
  33. Compartment::~Compartment()
  34. {
  35. }
  36. int Compartment::get_addpressure_timeout()
  37. {
  38. int timeout = 0;
  39. if(m_volume > 5000){
  40. timeout = 10*60;
  41. }else if(m_volume > 1000){
  42. timeout = 5*60;
  43. }
  44. timeout = 5*60;
  45. return timeout;
  46. }
  47. int Compartment::get_adjust_timeout()
  48. {
  49. int timeout = 0;
  50. if(m_volume > 9000){
  51. timeout = 5*60;
  52. }else if(m_volume > 7000){
  53. timeout = 5*60;
  54. }else if(m_volume > 5000){
  55. timeout = 5*60;
  56. }else if(m_volume > 3000){
  57. timeout = 5*60;
  58. }else if(m_volume > 1000){
  59. timeout = 5*60;
  60. }else{
  61. timeout = 5*60;
  62. }
  63. timeout = 15*60;
  64. return timeout;
  65. }
  66. void Compartment::clear_result()
  67. {
  68. m_result.pass_sys_pressure = false;
  69. m_result.pass_valve_pressure = false;
  70. m_result.sys_test_finished = false;
  71. m_result.valve_test_finished = false;
  72. m_bpicReady = false;
  73. }
  74. Tanker::Tanker()
  75. {
  76. for(int i =0; i< VRS_VISUAL_INSPECTION_ITEMS_NUM; i++){
  77. vrs_results[i] = RESULT_QUALIFIED;
  78. }
  79. for(int i=0; i< BLS_VISUAL_INSPECTION_ITEMS_NUM; i++){
  80. bls_results[i] = RESULT_QUALIFIED;
  81. }
  82. }
  83. Tanker::~Tanker()
  84. {
  85. }
  86. Compartment& Tanker::get_compartment(int id)
  87. {
  88. return m_comparts[id];
  89. }
  90. QJsonObject Tanker::get_vrs_items()
  91. {
  92. QJsonObject jsonObj;
  93. jsonObj.insert("count", VRS_VISUAL_INSPECTION_ITEMS_NUM);
  94. QJsonArray itemsArray;
  95. for(int i=0; i < VRS_VISUAL_INSPECTION_ITEMS_NUM; i++){
  96. QJsonObject itemObj;
  97. //itemObj.insert("index", i);
  98. itemObj.insert("name", vrs_visual_inspection_items[i]);
  99. itemObj.insert("value", QString::number(vrs_results[i]));
  100. itemsArray.append(itemObj);
  101. }
  102. jsonObj.insert("item", itemsArray);
  103. return jsonObj;
  104. }
  105. QJsonObject Tanker::get_bls_items()
  106. {
  107. QJsonObject jsonObj;
  108. jsonObj.insert("count", BLS_VISUAL_INSPECTION_ITEMS_NUM);
  109. QJsonArray itemsArray;
  110. for(int i=0; i < BLS_VISUAL_INSPECTION_ITEMS_NUM; i++){
  111. QJsonObject itemObj;
  112. //jsonObj.insert("index", i);
  113. itemObj.insert("name", bls_visual_inspection_items[i]);
  114. itemObj.insert("value", QString::number(bls_results[i]));
  115. itemsArray.append(itemObj);
  116. }
  117. jsonObj.insert("item", itemsArray);
  118. return jsonObj;
  119. }
  120. bool Tanker::set_item_result(const QString& jsonStr )
  121. {
  122. QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonStr.toUtf8());
  123. QJsonObject jsonObj = jsonDoc.object();
  124. QString table_str;
  125. QString item_name_str;
  126. int value = RESULT_QUALIFIED;
  127. if(jsonObj.contains("table") && jsonObj.value("table").isString()){
  128. table_str = jsonObj.value("table").toString();
  129. }else{
  130. qDebug() << "set_item_result no table";
  131. return false;
  132. }
  133. if(jsonObj.contains("name") && jsonObj.value("name").isString()){
  134. item_name_str = jsonObj.value("name").toString();
  135. }else{
  136. qDebug() << "set_item_result no name";
  137. return false;
  138. }
  139. if(jsonObj.contains("value") && jsonObj.value("value").isString()){
  140. value = jsonObj.value("value").toString().toInt();
  141. }else{
  142. qDebug() << "set_item_result no value";
  143. return false;
  144. }
  145. qDebug() << "table:" << table_str;
  146. if(table_str == "vrs"){
  147. for(int i=0; i<VRS_VISUAL_INSPECTION_ITEMS_NUM; i++){
  148. if(item_name_str == vrs_visual_inspection_items[i]){
  149. if(value >= RESULT_QUALIFIED && value <= RESULT_NOITEM){
  150. vrs_results[i] = value;
  151. qDebug() << "item_name:" << item_name_str;
  152. qDebug() << "value:" << value;
  153. }
  154. }
  155. }
  156. }else if(table_str == "bls"){
  157. for(int i=0; i<BLS_VISUAL_INSPECTION_ITEMS_NUM; i++){
  158. if(item_name_str == bls_visual_inspection_items[i]){
  159. if(value >= RESULT_QUALIFIED && value <= RESULT_NOITEM){
  160. bls_results[i] = value;
  161. qDebug() << "item_name:" << item_name_str;
  162. qDebug() << "value:" << value;
  163. }
  164. }
  165. }
  166. }else{
  167. qDebug() << "set_item_result table_str invalid";
  168. return false;
  169. }
  170. return true;
  171. }