69 lines
2.2 KiB
C
69 lines
2.2 KiB
C
|
|
#pragma once
|
||
|
|
/**
|
||
|
|
* @file entCentExit.h
|
||
|
|
* @brief 机组状态标记量
|
||
|
|
* 使用 入口段速度设定/实际 中央段速度设定/实际 出口段速度设定/实际
|
||
|
|
* 更新 入口段是否稳定 中央段是否稳定 出口段是否稳定
|
||
|
|
* @author your name (you@domain.com)
|
||
|
|
* @version 0.1
|
||
|
|
* @date 2023-12-22
|
||
|
|
*
|
||
|
|
* Copyright: Baosight Co. Ltd.
|
||
|
|
* DO NOT COPY/USE WITHOUT PERMISSION
|
||
|
|
*
|
||
|
|
*/
|
||
|
|
#include <eqpalg/gb_item_memory.h>
|
||
|
|
#include <glob/SingletonTemplate.h>
|
||
|
|
#include <zlib/MemVar.h>
|
||
|
|
#include <chrono>
|
||
|
|
#include <map>
|
||
|
|
#include <queue>
|
||
|
|
#include <string>
|
||
|
|
using std::queue;
|
||
|
|
const int TRUEMAXTIME = 10; /// 5以上 500ms调一次 5s调10次
|
||
|
|
struct ECELabel {
|
||
|
|
ECELabel(bool cent, bool ent, bool exit)
|
||
|
|
: cent_speed_stable(cent),
|
||
|
|
ent_speed_stable(ent),
|
||
|
|
exit_speed_stable(exit) {}
|
||
|
|
bool cent_speed_stable = false;
|
||
|
|
bool ent_speed_stable = false;
|
||
|
|
bool exit_speed_stable = false;
|
||
|
|
};
|
||
|
|
class entCentExit {
|
||
|
|
private:
|
||
|
|
bool cent_speed_stable_ = false;
|
||
|
|
bool ent_speed_stable_ = false;
|
||
|
|
bool exit_speed_stable_ = false;
|
||
|
|
int cent_times_OK_ = 0; ///<满足次数
|
||
|
|
int ent_times_OK_ = 0; ///<满足次数
|
||
|
|
int exit_times_OK_ = 0; ///<满足次数
|
||
|
|
|
||
|
|
bool cent_speed_stable_last_ = false;
|
||
|
|
bool ent_speed_stable_last_ = false;
|
||
|
|
bool exit_speed_stable_last_ = false;
|
||
|
|
|
||
|
|
queue<ECELabel> ECEqueue_;
|
||
|
|
// std::chrono::system_clock::time_point before_five_seconds_ =
|
||
|
|
// std::chrono::system_clock::now();
|
||
|
|
|
||
|
|
public:
|
||
|
|
entCentExit() = default;
|
||
|
|
~entCentExit() = default;
|
||
|
|
bool isEntOK() { return this->ent_speed_stable_; }
|
||
|
|
bool isCentOK() { return this->cent_speed_stable_; }
|
||
|
|
bool isExitOK() { return this->exit_speed_stable_; }
|
||
|
|
|
||
|
|
bool isEntOK_ihd() { return this->ent_speed_stable_last_; }
|
||
|
|
bool isCentOK_ihd() { return this->cent_speed_stable_last_; }
|
||
|
|
bool isExitOK_ihd() { return this->exit_speed_stable_last_; }
|
||
|
|
void statusDetection();
|
||
|
|
|
||
|
|
const std::string cent_speed_set = "CenterSpeedSet";
|
||
|
|
const std::string cent_speed_act = "MAIN_SPEED";
|
||
|
|
const std::string ent_speed_act = "EntSpeed";
|
||
|
|
const std::string exit_speed_act = "ExitSpeed";
|
||
|
|
const std::string prefix = string(CMemVar::Const()->UnitNo) + "_";
|
||
|
|
};
|
||
|
|
void stableDetector(double v1, double v2, double th, int& times,
|
||
|
|
bool& isStable);
|