tank.cpp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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_Roughadjust_timeout()
  37. {
  38. int timeout = 0;
  39. if(m_volume > 30000){
  40. timeout = 60*60;
  41. }else if(m_volume > 15000){
  42. timeout = 45*60;
  43. }else if(m_volume > 10000){
  44. timeout = 30*60;
  45. }else if(m_volume > 5000){
  46. timeout = 15*60;
  47. }else if(m_volume > 1000){
  48. timeout = 5*60;
  49. }else{
  50. timeout = 3*60;
  51. }
  52. timeout = 30*60;
  53. return timeout;
  54. }
  55. int Compartment::get_adjust_timeout()
  56. {
  57. int timeout = 0;
  58. if(m_volume > 9000){
  59. timeout = 5*60;
  60. }else if(m_volume > 7000){
  61. timeout = 5*60;
  62. }else if(m_volume > 5000){
  63. timeout = 5*60;
  64. }else if(m_volume > 3000){
  65. timeout = 5*60;
  66. }else if(m_volume > 1000){
  67. timeout = 5*60;
  68. }else{
  69. timeout = 5*60;
  70. }
  71. timeout = 15*60;
  72. return timeout;
  73. }
  74. void Compartment::clear_result()
  75. {
  76. m_result.pass_sys_pressure = false;
  77. m_result.pass_valve_pressure = false;
  78. m_result.sys_test_ok = false;
  79. m_result.valve_test_ok = false;
  80. m_bpicReady = false;
  81. }
  82. Tanker::Tanker()
  83. {
  84. for(int i =0; i< VRS_VISUAL_INSPECTION_ITEMS_NUM; i++){
  85. vrs_results[i] = RESULT_QUALIFIED;
  86. }
  87. for(int i=0; i< BLS_VISUAL_INSPECTION_ITEMS_NUM; i++){
  88. bls_results[i] = RESULT_QUALIFIED;
  89. }
  90. }
  91. Tanker::~Tanker()
  92. {
  93. }
  94. Compartment& Tanker::get_compartment(int id)
  95. {
  96. return m_comparts[id];
  97. }
  98. QJsonObject Tanker::get_vrs_items()
  99. {
  100. QJsonObject jsonObj;
  101. jsonObj.insert("count", VRS_VISUAL_INSPECTION_ITEMS_NUM);
  102. QJsonArray itemsArray;
  103. for(int i=0; i < VRS_VISUAL_INSPECTION_ITEMS_NUM; i++){
  104. QJsonObject itemObj;
  105. //itemObj.insert("index", i);
  106. itemObj.insert("name", vrs_visual_inspection_items[i]);
  107. itemObj.insert("value", QString::number(vrs_results[i]));
  108. itemsArray.append(itemObj);
  109. }
  110. jsonObj.insert("item", itemsArray);
  111. return jsonObj;
  112. }
  113. QJsonObject Tanker::get_bls_items()
  114. {
  115. QJsonObject jsonObj;
  116. jsonObj.insert("count", BLS_VISUAL_INSPECTION_ITEMS_NUM);
  117. QJsonArray itemsArray;
  118. for(int i=0; i < BLS_VISUAL_INSPECTION_ITEMS_NUM; i++){
  119. QJsonObject itemObj;
  120. //jsonObj.insert("index", i);
  121. itemObj.insert("name", bls_visual_inspection_items[i]);
  122. itemObj.insert("value", QString::number(bls_results[i]));
  123. itemsArray.append(itemObj);
  124. }
  125. jsonObj.insert("item", itemsArray);
  126. return jsonObj;
  127. }
  128. bool Tanker::set_item_result(const QString& jsonStr )
  129. {
  130. QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonStr.toUtf8());
  131. QJsonObject jsonObj = jsonDoc.object();
  132. QString table_str;
  133. QString item_name_str;
  134. int value = RESULT_QUALIFIED;
  135. if(jsonObj.contains("table") && jsonObj.value("table").isString()){
  136. table_str = jsonObj.value("table").toString();
  137. }else{
  138. qDebug() << "set_item_result no table";
  139. return false;
  140. }
  141. if(jsonObj.contains("name") && jsonObj.value("name").isString()){
  142. item_name_str = jsonObj.value("name").toString();
  143. }else{
  144. qDebug() << "set_item_result no name";
  145. return false;
  146. }
  147. if(jsonObj.contains("value") && jsonObj.value("value").isString()){
  148. value = jsonObj.value("value").toString().toInt();
  149. }else{
  150. qDebug() << "set_item_result no value";
  151. return false;
  152. }
  153. qDebug() << "table:" << table_str;
  154. if(table_str == "vrs"){
  155. for(int i=0; i<VRS_VISUAL_INSPECTION_ITEMS_NUM; i++){
  156. if(item_name_str == vrs_visual_inspection_items[i]){
  157. if(value >= RESULT_QUALIFIED && value <= RESULT_NOITEM){
  158. vrs_results[i] = value;
  159. qDebug() << "item_name:" << item_name_str;
  160. qDebug() << "value:" << value;
  161. }
  162. }
  163. }
  164. }else if(table_str == "bls"){
  165. for(int i=0; i<BLS_VISUAL_INSPECTION_ITEMS_NUM; i++){
  166. if(item_name_str == bls_visual_inspection_items[i]){
  167. if(value >= RESULT_QUALIFIED && value <= RESULT_NOITEM){
  168. vrs_results[i] = value;
  169. qDebug() << "item_name:" << item_name_str;
  170. qDebug() << "value:" << value;
  171. }
  172. }
  173. }
  174. }else{
  175. qDebug() << "set_item_result table_str invalid";
  176. return false;
  177. }
  178. return true;
  179. }