SiLA 2 集成

概述

SiLA 2 (Standardization in Lab Automation) 是实验室自动化领域的国际标准通信协议。本系统实现了 SiLA 2 标准接口,支持与符合 SiLA 2 标准的上位系统通信。


实现的接口

1. ChromatographService

服务描述:色谱仪控制接口

命令

命令说明参数返回值
StartRun开始分析NoParametersStartedRun
StopRun停止分析NoParametersStoppedRun
PauseRun暂停分析NoParametersPausedRun
ResumeRun恢复分析NoParametersResumedRun
AbortRun中止分析NoParametersAbortedRun
GetState获取状态NoParametersChromatographState

2. DetectorService

服务描述:检测器控制接口

命令

命令说明参数返回值
Ignite点火控制Ignite_ParametersIgnite_Responses

属性

属性说明类型
DetectorType检测器类型String
IgnitionState点火状态Boolean
SignalLevel信号电平Double

3. TemperatureController

服务描述:温度控制接口

属性

属性说明类型
TemperatureSetpoint温度设定值Double
ActualTemperature实际温度Double
TemperatureStatus温度状态String

4. PneumaticController

服务描述:气路控制接口

属性

属性说明类型
PressureSetpoint压力设定值Double
ActualPressure实际压力Double
FlowRate流量Double

5. HistoryService

服务描述:历史数据查询接口

命令

命令说明参数返回值
GetResults查询历史结果ResultQuery[]AnalysisResult
GetRun查询单条记录RunQueryAnalysisRun

gRPC 接口

连接地址

grpc://host:50051

协议文件

协议定义位于 src/edge/internal/sila2/proto/

文件说明
chromatograph.proto色谱仪服务
detector.proto检测器服务
temperature.proto温度控制服务
pneumatic.proto气路控制服务

客户端示例

import (
    "context"
    pb "chromatography-workstation/edge/internal/sila2/pb"
    "google.golang.org/grpc"
)

func main() {
    conn, err := grpc.Dial("localhost:50051", grpc.WithInsecure())
    if err != nil {
        panic(err)
    }
    defer conn.Close()
    
    client := pb.NewChromatographServiceClient(conn)
    _, err = client.StartRun(context.Background(), &pb.StartRun_Parameters{})
}

HTTP 网关

为方便集成,系统提供 SiLA 2 HTTP 网关:

基础路径

/api/sila2/v1/

接口映射

HTTP 端点SiLA 2 命令方法
/ChromatographService/StartRunStartRunPOST
/ChromatographService/StopRunStopRunPOST
/ChromatographService/GetStateGetStateGET
/DetectorService/IgniteIgnitePOST
/SystemDiscoveryService/CapabilitiesGetCapabilitiesGET

使用示例

# 开始分析
curl -X POST http://localhost:8080/api/sila2/v1/ChromatographService/StartRun

# 获取状态
curl http://localhost:8080/api/sila2/v1/ChromatographService/GetState

# 点火控制
curl -X POST http://localhost:8080/api/sila2/v1/DetectorService/Ignite \
  -H "Content-Type: application/json" \
  -d '{"Ignite": true}'

ANIML 数据格式

系统支持 ANIML (Analytical Information Markup Language) 标准数据格式。

结果结构

{
  "schema": "voc-result.v1",
  "deviceId": "GC97002020100110",
  "traceId": "GC97002020100110-0-1781244750403763550",
  "createdAt": "2026-06-12T06:12:30Z",
  "engine": {
    "name": "edge-analyzer",
    "version": "0.3.88",
    "gitSha": "dev"
  },
  "methodId": "default",
  "methodVersion": 1,
  "pollutants": [
    {
      "name": "THC",
      "code": "THC",
      "rtS": 4.9,
      "area": 4.55,
      "height": 10.19,
      "amount": 1.98,
      "status": "detected"
    }
  ],
  "groups": [
    {"name": "NMHC", "code": "NMHC", "amount": 0.98}
  ],
  "stationId": "GC97002020100110"
}

安全考虑

认证

SiLA 2 gRPC 接口支持:

  • 无认证模式(默认)
  • TLS 加密(可选)

控制权限

通过环境变量控制:

# 允许控制指令
EDGE_ALLOW_CONTROL=1

# 只读模式
EDGE_ALLOW_CONTROL=0