first commit

This commit is contained in:
2026-01-02 19:20:35 +09:00
commit a10cb30c4a
94 changed files with 28609 additions and 0 deletions

137
hardware/channelmanager.h Normal file
View File

@@ -0,0 +1,137 @@
#ifndef CHANNELMANAGER_H
#define CHANNELMANAGER_H
#include <QDateTime>
#include <QList>
#include <QMap>
#include <QObject>
/**
* @brief 通道管理器
*
* 管理校验仪的输入/输出通道状态
* - 输入通道1: 4线制支持所有测量功能
* - 输入通道2: 2线制支持基本测量
* - 输出通道1/2: 2线制支持电压/电流/波形输出
*/
class ChannelManager : public QObject
{
Q_OBJECT
public:
enum ChannelType
{
INPUT_CHANNEL,
OUTPUT_CHANNEL
};
enum ChannelId
{
INPUT_CHANNEL_1 = 1,
INPUT_CHANNEL_2 = 2,
OUTPUT_CHANNEL_1 = 3,
OUTPUT_CHANNEL_2 = 4
};
enum OperationType
{
// 通用状态
NONE,
// 输入通道操作状态
VOLTAGE_MEASUREMENT, // 电压测量
MV_MEASUREMENT, // mV测量
MA_MEASUREMENT, // mA测量
AC_MEASUREMENT, // 交流测量
RESISTANCE_MEASUREMENT, // 电阻测量(含热电阻及多线制)
FREQUENCY_MEASUREMENT, // 频率测量
SWITCH_MEASUREMENT, // 开关量测量
INSULATION_MEASUREMENT, // 绝缘电阻测量
// 输出通道操作状态
VOLTAGE_OUTPUT, // 电压输出
MV_OUTPUT, // mV输出
MA_OUTPUT, // mA输出
WAVEFORM_OUTPUT, // 波形输出
RESISTANCE_SIMULATION // 电阻模拟(含热电阻及多线制)
};
enum ConnectionType
{
TWO_WIRE,
THREE_WIRE,
FOUR_WIRE
};
struct ChannelCapability
{
ChannelType type;
int maxWires;
QStringList wireColors;
QList<ConnectionType> supportedConnections;
QList<OperationType> supportedOperations;
};
struct OperationDetails
{
OperationType operation;
QString description;
ConnectionType connectionType;
};
static ChannelManager *instance();
// 通道状态查询
bool isChannelAvailable(ChannelId channel) const;
bool canChannelSupport(ChannelId channel, OperationType operation,
ConnectionType connection = TWO_WIRE) const;
// 通道占用/释放
bool occupyChannel(ChannelId channel, OperationType operation,
const QString &description = QString(),
ConnectionType connectionType = TWO_WIRE);
void releaseChannel(ChannelId channel);
// 通道信息获取
OperationType getChannelOperation(ChannelId channel) const;
QString getChannelDescription(ChannelId channel) const;
OperationDetails getChannelOperationDetails(ChannelId channel) const;
ChannelCapability getChannelCapability(ChannelId channel) const;
QList<ChannelId> getAvailableChannels(ChannelType type) const;
QList<OperationType> getSupportedOperations(ChannelId channel) const;
// 显示名称
QString getOperationDisplayName(OperationType operation) const;
QString getConnectionTypeDisplayName(ConnectionType connection) const;
QString getDetailedOperationDescription(const OperationDetails &details) const;
QString getChannelDisplayName(ChannelId channel) const;
// 类型判断
bool isInputChannelOperation(OperationType operation) const;
bool isOutputChannelOperation(OperationType operation) const;
// 查询
QList<ChannelId> getChannelsWithOperation(OperationType operation) const;
signals:
void channelStatusChanged(ChannelId channel, OperationType operation,
const QString &description);
void channelReleased(ChannelId channel);
private:
explicit ChannelManager(QObject *parent = nullptr);
void initializeChannelCapabilities();
struct ChannelStatus
{
bool occupied;
OperationDetails operationDetails;
QDateTime occupiedTime;
};
QMap<ChannelId, ChannelStatus> m_channelStatus;
QMap<ChannelId, ChannelCapability> m_channelCapabilities;
static ChannelManager *m_instance;
};
#endif // CHANNELMANAGER_H