@jnrs/lingshu-smart 3.0.0 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,7 +13,7 @@ export declare function hasStationSlotLayers(layer: ILayer | null): layer is Ext
13
13
  stationSlotGroups?: any[];
14
14
  }>;
15
15
  export declare function isResourceStore(layer: ILayer | null): layer is import('./index').IResourceStoreConfig;
16
- export declare function hasFixtureChange(layer: ILayer | null): layer is import('./index').ISingleJointRobotConfig | import('./index').IDoubleJointRobotConfig;
16
+ export declare function isJointRobot(layer: ILayer | null): layer is import('./index').ISingleJointRobotConfig | import('./index').IDoubleJointRobotConfig;
17
17
  export declare function isRail(layer: ILayer | null): layer is import('./index').IRailConfig;
18
18
  export declare function isShuttleStation(layer: ILayer | null): layer is import('./index').IShuttleStationConfig;
19
19
  export declare function isPallet(layer: ILayer | null): layer is Extract<ILayer, {
@@ -11,6 +11,13 @@ export interface IPositionOperating {
11
11
  x?: number;
12
12
  y?: number;
13
13
  z?: number;
14
+ /**
15
+ * 画布内部字段:协议 `position.x` 的**原始值**(SocketDispatcher 换算像素时附带,不入协议)。
16
+ * 设备绑定轨道(linkRailId)时用于沿轨定位:≤ 1 视为沿轨道长度的比例(0 = 轨道起点端、1 = 终点端);
17
+ * > 1 视为自轨道起点端算起的沿轨像素距离(代理已配置「像素转换」特殊处理的情形)。
18
+ * 未绑定轨道时不参与定位(仍用 x 的场景像素值)
19
+ */
20
+ rawX?: number;
14
21
  j1?: number;
15
22
  j2?: number;
16
23
  fork_xy?: number;
@@ -27,6 +34,11 @@ export interface IModelOperating {
27
34
  device_station?: number;
28
35
  /** 设备状态(协议 device_state 状态码;画布默认不做任何处理,由使用方按需在代理器自行配置映射) */
29
36
  device_state?: number;
37
+ /**
38
+ * 铭牌文本(全部设备通用):传入时更新画布铭牌文字,并按文字长度重算铭牌宽度与两端螺钉孔位置;
39
+ * 仅影响画布 UI,不写入设备配置——复位(scene_reset)后铭牌回到配置里的初始文本,动态文本需复位后重新下发
40
+ */
41
+ nameplate?: string;
30
42
  raw_data: IRowData;
31
43
  resource?: IResourceOperating;
32
44
  }
@@ -136,6 +136,11 @@ export interface DeviceCommandPayload {
136
136
  raw_data?: object;
137
137
  /** 设备状态(状态码);画布默认不做处理,由使用方按需在代理器自行配置映射 */
138
138
  device_state?: number;
139
+ /**
140
+ * 铭牌文本(全部设备通用):传入时更新画布铭牌文字(宽度按文字长度重算);
141
+ * 仅影响画布 UI,scene_reset 后回到配置里的初始文本
142
+ */
143
+ nameplate?: string;
139
144
  light?: SocketLight;
140
145
  progress?: SocketProgress;
141
146
  passage?: SocketPassage;
@@ -208,6 +213,8 @@ export interface DeviceInitItem {
208
213
  device_station?: number;
209
214
  /** 设备状态(状态码);画布默认不做处理,由使用方按需在代理器自行配置映射 */
210
215
  device_state?: number;
216
+ /** 铭牌文本(全部设备通用):传入时更新画布铭牌文字(宽度按文字长度重算) */
217
+ nameplate?: string;
211
218
  light?: SocketLight;
212
219
  progress?: SocketProgress;
213
220
  passage?: SocketPassage;
@@ -1,4 +1,4 @@
1
- import { ILayer, InteractiveUi, IEventHandler, ILayerOperating, EnumResourceType } from '../../types';
1
+ import { ILayer, InteractiveUi, IEventHandler, ILayerOperating, IRailConfig, EnumResourceType } from '../../types';
2
2
  import { StationSlotGroup } from '../components/StationSlotGroup';
3
3
  import { AppController } from '../../controller/AppController';
4
4
  import { BaseAbs } from './BaseAbs';
@@ -15,7 +15,28 @@ export declare abstract class ModelAbs<T extends ILayer = ILayer> extends BaseAb
15
15
  * 托盘跟随等联动使用该值保持动画同步;子类可覆盖(如双关节机器人 0.5s)
16
16
  */
17
17
  get moveDuration(): number;
18
+ /**
19
+ * 沿 x 位移(搬运设备通用)
20
+ * - 未绑定轨道(linkRailId):按场景绝对坐标位移(原行为,x 为像素)
21
+ * - 已绑定轨道:按「沿轨距离」定位——rawX ≤ 1 为沿轨道长度的比例(0 = 轨道起点端、1 = 终点端),
22
+ * rawX > 1 为自轨道起点端算起的沿轨像素距离(代理已配置「像素转换」的情形);
23
+ * 横向沿用编辑期设计的「相对轨道偏移」(不消费协议 y),朝向 = 编辑期 rotation + 轨道 rotation
24
+ * @param x 场景绝对 x(像素,由协议比例按场景宽度换算;> 1 的代理像素值原样透传)
25
+ * @param rawX 协议 position.x 原始值(画布内部字段,绑定轨道时使用)
26
+ */
27
+ protected moveX(x?: number, rawX?: number): void;
28
+ /** 绑定轨道(linkRailId,或轨道侧 linkEquipIdArray 反查)的轨道配置;未绑定或轨道未加载时返回 null */
29
+ protected get boundRailConfig(): IRailConfig | null;
30
+ /** 沿轨定位:协议值 → 沿轨局部距离 → 场景坐标;越出轨道长度收敛到 [0, 轨道长度] */
31
+ private moveXAlongRail;
18
32
  handleOperation: (data: ILayerOperating) => void;
33
+ /**
34
+ * 更新设备铭牌文本(铭牌宽度、文字宽度与两端螺钉孔位置同步重算)
35
+ * 仅作用于画布 UI,不写入 config:复位(resetUI)后铭牌回到配置里的初始文本,
36
+ * 动态文本(如「名称(资源数/工位数)」)需由使用方在 scene_reset 后重新下发
37
+ * @param title 铭牌文本
38
+ */
39
+ setNameplate(title: string): void;
19
40
  /**
20
41
  * 将最近一次 operating 接收到的原始数据写入模型 config 及整棵 UI 树的 data 属性,
21
42
  * 使点击回调(onTap/onMenuTap/onDragEnd)中的 layer 与 data 都能读取到各自 operatingData。
@@ -31,7 +31,6 @@ export declare class DoubleJointRobot extends ModelAbs<IDoubleJointRobotConfig>
31
31
  protected collectStationSlotGroups(): StationSlotGroup[];
32
32
  private handleRotateR1;
33
33
  private handleRotateR2;
34
- private moveX;
35
34
  private switchFork;
36
35
  /** 设置托盘夹具状态:辅料夹具沿用工件夹具造型,压扁 + 直角 + 描边补偿,并补偿 y 使垂直中心对齐手抓关节 */
37
36
  private setPalletFixture;
@@ -17,7 +17,6 @@ export declare class Pallet extends ModelAbs<IPalletConfig> {
17
17
  private resolveLayers;
18
18
  private buildLayers;
19
19
  protected createUi(): Box;
20
- private moveX;
21
20
  private moveY;
22
21
  protected operating(data: IPalletOperating): void;
23
22
  /** 资源增删:data.resource 提供 device_layer(>0) 时定位到该层;缺省时默认识别为第一层 */
@@ -12,10 +12,12 @@ export declare class Rail extends ModelAbs<IRailConfig> {
12
12
  * (设备移动时 AppController 逐帧调用 followChain,保证拖链与设备相对静止) */
13
13
  protected operating(_data: ILayerOperating): void;
14
14
  /**
15
- * 逐帧跟随(AppController 托盘/拖链联动调用):
15
+ * 逐帧跟随(AppController 拖链联动调用):
16
16
  * 以设备实时位置直接驱动拖链,保证拖链与设备移动时相对静止
17
+ * @param botId 设备业务 id
18
+ * @param along 设备在「轨道局部坐标系」下的沿轨距离(0 = 轨道起点端,未缩放局部单位)
17
19
  */
18
- followChain(botId: string, x: number): void;
20
+ followChain(botId: string, along: number): void;
19
21
  private initChains;
20
22
  private createChain;
21
23
  private moveChain;
@@ -21,7 +21,6 @@ export declare class ResourceStore extends ModelAbs<IResourceStoreConfig> {
21
21
  containsStationIndex(index: number): boolean;
22
22
  /** 定位资源所在的工位组:优先按 device_layer 层号,其次按工位序号在工作位组中匹配,缺省回退资源类型 */
23
23
  private findGroupForResource;
24
- private moveX;
25
24
  protected operating(data: IResourceStoreOperating): void;
26
25
  protected collectStationSlotGroups(): StationSlotGroup[];
27
26
  }
@@ -20,7 +20,6 @@ export declare class Rgv extends ModelAbs<IRGVConfig> {
20
20
  private findGroupForResource;
21
21
  protected collectStationSlotGroups(): StationSlotGroup[];
22
22
  private handleRotate;
23
- private moveX;
24
23
  /**
25
24
  * forks 前后移动(直接赋值,高频移动不走动画)
26
25
  * @param percent 移动比例,[-1,1]
@@ -3,7 +3,7 @@ import { Box } from 'leafer';
3
3
  import { ModelAbs } from '../abstract/ModelAbs';
4
4
  import { StationSlotGroup } from '../components/StationSlotGroup';
5
5
  /**
6
- * 单关节机器人
6
+ * 单关节机器人(SingleJointRobot)
7
7
  */
8
8
  export declare class SingleJointRobot extends ModelAbs<ISingleJointRobotConfig> {
9
9
  private static readonly DEFAULT_WIDTH;
@@ -18,6 +18,8 @@ export declare class SingleJointRobot extends ModelAbs<ISingleJointRobotConfig>
18
18
  private slotLayerIndexes;
19
19
  get currentFixture(): EnumResourceType | 'none';
20
20
  set currentFixture(type: EnumResourceType | 'none');
21
+ /** 移动动画时长:与 moveX 默认 0.5s 一致,供托盘跟随等联动同步 */
22
+ get moveDuration(): number;
21
23
  protected createUi(): Box;
22
24
  protected operating(data: ISingleJointRobotOperating): void;
23
25
  /** 资源路由(与夹具装饰无关):device_layer 层号优先(当前夹具绑定了层时以绑定层为索引基准),其次工位号(优先类型匹配),最后首个工位组 */
@@ -28,7 +30,6 @@ export declare class SingleJointRobot extends ModelAbs<ISingleJointRobotConfig>
28
30
  private applyFixtureBindingVisibility;
29
31
  protected collectStationSlotGroups(): StationSlotGroup[];
30
32
  private handleRotate;
31
- private moveX;
32
33
  private switchFork;
33
34
  /** 设置托盘夹具状态:辅料夹具沿用工件夹具造型,压扁 + 直角 + 描边补偿,并补偿 y 使垂直中心对齐手抓关节 */
34
35
  private setPalletFixture;
@@ -14,4 +14,18 @@ export interface NamePlateOptions {
14
14
  screwHole?: boolean;
15
15
  zIndex?: number | string;
16
16
  }
17
+ /** 铭牌默认字号(未显式指定 width 时使用) */
18
+ export declare const NAME_PLATE_FONT_SIZE = 14;
19
+ /** 铭牌默认高度 */
20
+ export declare const NAME_PLATE_HEIGHT = 18;
21
+ /**
22
+ * 按字符实际显示宽度估算铭牌宽度:
23
+ * 中文等全角字符占 1×fontSize,英文/数字等半角字符占 0.5×fontSize,另加左右各 1 字符边距
24
+ */
25
+ export declare function calcNamePlateWidth(title: string, fontSize?: number): number;
26
+ /**
27
+ * 运行时更新铭牌文本:同步文字内容、铭牌宽度与两端螺钉孔位置
28
+ * (字号沿用创建时的设置;铭牌 around 为 center,宽度变化后仍保持居中显示)
29
+ */
30
+ export declare function updateNamePlate(box: Box, title: string): void;
17
31
  export declare function NamePlate(options: NamePlateOptions): Box;
@@ -0,0 +1,36 @@
1
+ import { IRailConfig } from '../../types';
2
+ /** 轨道坐标系参数(由轨道配置一次性解析) */
3
+ export interface IRailFrame {
4
+ /** 轨道中心场景坐标 x */
5
+ cx: number;
6
+ /** 轨道中心场景坐标 y */
7
+ cy: number;
8
+ /** 轨道旋转角余弦 */
9
+ cos: number;
10
+ /** 轨道旋转角正弦 */
11
+ sin: number;
12
+ /** 轨道缩放系数 */
13
+ scale: number;
14
+ /** 轨道长度(局部单位,= width) */
15
+ length: number;
16
+ /** 轨道厚度(局部单位,= height) */
17
+ thickness: number;
18
+ }
19
+ /** 解析轨道坐标系参数(rotation / scale 缺省按 0 / 1 处理;兼容编辑器序列化出的空串等非数值) */
20
+ export declare function createRailFrame(rail: IRailConfig): IRailFrame;
21
+ /**
22
+ * 协议值 → 沿轨局部距离(未缩放的轨道局部单位)
23
+ * - source ≤ 1:协议比例 [0,1](0 = 轨道起点端、1 = 终点端)→ 比例 × 轨道长度
24
+ * - source > 1:已被代理「像素转换」特殊处理成的像素值 → 视为自轨道起点端算起的沿轨像素距离(除以轨道 scale 换算为局部单位)
25
+ */
26
+ export declare function resolveRailAlong(frame: IRailFrame, source: number): number;
27
+ /** 场景坐标 → 轨道局部坐标(along 沿轨方向、lateral 垂直轨道方向,均为未缩放的轨道局部单位) */
28
+ export declare function sceneToRailLocal(frame: IRailFrame, x: number, y: number): {
29
+ along: number;
30
+ lateral: number;
31
+ };
32
+ /** 轨道局部坐标 → 场景坐标(先平移到以轨道中心为原点,再缩放、旋转) */
33
+ export declare function railLocalToScene(frame: IRailFrame, along: number, lateral: number): {
34
+ x: number;
35
+ y: number;
36
+ };