# sa_wfs — 快速使用

> Doc Ver: 0.3 · 2026-10-28 · 风场集群，不进 device / server / wind 包  
> 详细说明见 [sa_wfs.md](sa_wfs.md) · 总览图见 [sa.md](sa.md)

**一句话**：风场集群在 `:3040` 看多场大屏。每台 `sa_wt` 仍是一个风场，由场站连出中心 `:3041` 主动汇报。测点历史留在场内。

## 程序快捷入口

| 入口 | URL |
|------|-----|
| GIS 大屏 | `http://<中心IP>:3040/` |
| 设置 | `http://<中心IP>:3040/settings.html` |
| 摘要表 | `http://<中心IP>:3040/table.html` |
| 多场摘要 | `http://<中心IP>:3040/api/portfolio` |
| 风场 GeoJSON | `http://<中心IP>:3040/api/portfolio.geojson` |
| 北向状态 | `http://<中心IP>:3040/api/northbound/state` |
| **本程序在线帮助** | `http://<中心IP>:3040/help/` |
| 独立帮助 Hub（镜像） | http://192.168.3.9/sa2/help/wfs/ · http://sc.casstk.com/sa2/help/wfs/ |
| 健康检查 | `http://<中心IP>:3040/api/health` |
| 版本 | `http://<中心IP>:3040/api/version` |
| OpenAPI | `http://<中心IP>:3040/openapi.yaml` |
| 报文格式 | `http://<中心IP>:3040/schema/report.schema.json` |
| 其他系统接入 | [sa_wfs-api.md](sa_wfs-api.md) |

返回：[帮助门户](index.html ':ignore') · [wfs Hub](wfs/index.html ':ignore') · [系统总览](sa.md) · [sa_wt 快速使用](sa_wt-quickstart.md)

## 命令行

```bash
sa_wfs help
sa_wfs -version
sa_wfs -port 3040 -root /path/to/sa_wfs
```

| 标志 | 作用 |
|------|------|
| `-port` | HTTP 端口，默认 3040 |
| `-root` | 配置根目录 |
| `-version` | 打印版本后退出 |
| `-h` / `help` | 命令说明 |

## 和 sa_wt 接上

场站编号两边用同一个。中心 `conf/farms.yaml` 的 `id` 等于场站 `conf/farm.json` 的 `farmId`。密钥两边相同，不写人机口令。

中心：

```yaml
farms:
  - id: F01
    name: 示范风场
    secret: <与场站 center.secret 相同>
    base_url: http://<场站地址>:3010
```

场站 `conf/northbound.yaml`：

```yaml
center:
  enabled: true
  broker: tcp://<中心地址>:3041
  secret: <与中心该场 secret 相同>
  report_interval_sec: 10
```

`base_url` 只用于从大屏打开该场 `:3010/farm.html`。浏览器到不了场站时留空。场站改完 `center` 后重启一次 `sa_wt`。之后的汇报间隔由中心设置页下发，不必再重启。详细对照见 [sa_wfs.md](sa_wfs.md)。

登录口令都是 `temppwd`。示例用户文件里是超级用户 `admin`、管理员 `operator`、普通用户 `viewer`。登录后画面显示当前账户，可退出。设置页维护允许汇报的场站、汇报间隔和日志轮转。超级用户还可改大屏中间名称和底部版权。普通用户不能改场站名单。大屏「历史」可查已收下的汇报。北向读取用请求头 `X-API-Key`。机器换令牌见 [sa_wfs.md](sa_wfs.md)。新口令至少 8 位，且大写、小写、数字、特殊字符至少三种。

## 5 分钟验收

```bash
ss -lntp | grep 3040
curl -sf http://127.0.0.1:3040/api/health
curl -sf -H "X-API-Key: <中心密钥>" http://127.0.0.1:3040/api/portfolio
```

浏览器打开 `http://<中心IP>:3040/`，用 `admin` / `temppwd` 登录（示例里这是超级用户），表里应出现 `conf/farms.yaml` 中的每个风场。

## 安装

普通包装在中心机，不装进各风场。制品在 `casstk/sa_wfs`，不进 wind 包。

```bash
cspkg install sa_wfs --edition center -y
cspkg status sa_wfs
cspkg upgrade sa_wfs -y
```

Docker 拉取地址和标签以下面整行为准。内网 Registry 是 `192.168.3.8:5050`，配置和日志挂在外面：

```bash
docker pull 192.168.3.8:5050/casstk/sa2/sa-wfs:0.4.8
docker run -d --name sa_wfs --network host --restart unless-stopped \
  -v /path/to/sa_wfs/conf:/conf -v /path/to/sa_wfs/data:/data \
  192.168.3.8:5050/casstk/sa2/sa-wfs:0.4.8 -port 3040
```

## 实验室最短启动

```bash
cd src/sa_wfs
cp conf/app.yaml.example conf/app.yaml
cp conf/farms.example.yaml conf/farms.yaml
cp conf/users.example.yaml conf/users.yaml
make build
./build/sa_wfs -port 3040
```
