DEVICEMGR — 设备管理器 · CONTAINER
DEVICEMGR 是按名称处理项目中所有容器的管理对象。它以容器名称作为第一个参数,添加 · 移除 · 移动物料(设备),并查询物料数量与位置。
从 4.0 开始,也可以通过 CONTAINER["名称"] 直接访问容器本身(见下面的 CONTAINER 一节)。
单件物料的数据见 DEVICE,容器定义见 Device Data Editor。
容器类型
| 类型 | 结构 | 物料的添加 · 移除 |
|---|---|---|
| Single | 1 件物料(传送带、单个拾取器) | AddDevice(名称) · RemoveDevice(名称) |
| Queue | 先放入的物料先取出的结构 (FIFO) | AddDevice(名称) · RemoveDevice(名称) — 删除先进入的物料 |
| Stack | 后放入的物料先取出的缓冲结构 | AddDevice(名称) · RemoveDevice(名称) — 删除最后进入的物料 |
| Array | 按格号直接访问(槽位 · 料盒 · 料仓 · 拾取器) | AddDevice(名称, index) · RemoveDevice(名称, index) |
| Map | 按 X · Y 坐标访问(托盘 · 晶圆) | AddDevice(名称, col, row) · RemoveDeviceMap(名称, col, row) |
- 格号 · 坐标从 0 开始计数。
- Array · Map 只在空格中放置物料。对已有物料的格子执行
AddDevice不会覆盖,而是返回 false。若要有意替换,请使用SetDevice。 - Single · Queue · Stack 的
AddDevice,为了应对交接物料瞬间的暂时重叠,最多接收到容量的 2 倍。超出容量的状态持续超过 1 秒时,会记录错误日志。
示例
//==================
// Tray 5 x 5 托盘
int trayRowCount = DEVICEMGR.GetRowCount("Tray");
int trayColCount = DEVICEMGR.GetColumnCount("Tray");
DEVICEMGR.MakeFull("Tray", 1); // 用 Rank 1 的物料填满托盘的所有格子
if( DEVICEMGR.IsFull("Tray") == true )
{
Log("Tray Is Full. Col = {0}, Row = {1}", trayColCount, trayRowCount);
}
else
{
Log("Tray Is Not Full. Col = {0}, Row = {1}", trayColCount, trayRowCount);
}
int devCount = DEVICEMGR.GetDeviceCount("Tray");
Log("Before Remove, Device Count = {0}", devCount);
DEVICEMGR.RemoveDeviceMap("Tray", 0, 0);
devCount = DEVICEMGR.GetDeviceCount("Tray");
Log("After Remove, Device Count = {0}", devCount);Map 位置搜索 4.0+
3.x 的行搜索函数 GetDeviceRow · GetDeviceRankRow · GetEmptyRow 在 4.0 中已取消,改为在整个 Map 中一次找出(col, row)的 Get…Pos 函数。
因为一次找出,所以不会出现两次调用之间物料状态变化而导致行 · 列错位的情况。
int col = 0;
int row = 0;
if( DEVICEMGR.GetDevicePos("Tray", /*frontToRear*/false, /*leftToRight*/true, /*ref*/col, /*ref*/row) == true )
{
Log($"pick ( col={col}, row={row} )");
}实战示例 — 单元之间的移动
// 将订单物料移到下一个单元
DEVICEMGR.MoveDevice(DEVICE_NAME, unitIndex - 1, DEVICE_NAME, unitIndex);
// 删除从最后一个单元送出的物料
DEVICEMGR.RemoveDevice(DEVICE_NAME, unitIndex);
// 确认所有容器的物料数量
if( DEVICEMGR.GetDeviceCountAll() > 0 )
{
// 产线上仍有物料
}CONTAINER — 直接访问容器 4.0+
CONTAINER["名称"] 是容器对象本身。与 DEVICEMGR 的同名函数行为相同,只是不再把容器名称作为参数传入
(例:DEVICEMGR.MakeFull("Tray", 1) 与 CONTAINER["Tray"].MakeFull(1) 相同)。若容器名称不存在,属性为默认值(0 · false),函数不执行任何操作。
// 托盘有空格时,在第一个空格放置 Rank 2 的物料
if( CONTAINER["Tray"].IsFull == false )
{
int col = 0;
int row = 0;
if( DEVICEMGR.GetEmptyPos("Tray", /*frontToRear*/false, /*leftToRight*/true, /*ref*/col, /*ref*/row) == true )
{
CONTAINER["Tray"].AddDevice(col, row);
DEVICE["Tray", col, row].Rank = 2;
}
}
Log("Tray : {0} / {1}, empty = {2}", CONTAINER["Tray"].Count, CONTAINER["Tray"].Capacity, CONTAINER["Tray"].EmptyCount);| 属性 | 类型 | 说明 |
|---|---|---|
Name | string | 容器名称 |
SensorName | string | 检测有无物料的传感器 IO 名称 |
Count | int | 现有物料数量(只读) |
Capacity | int | 可容纳的物料数量 — Map 为列数 × 行数。更改时使用 DEVICEMGR.SetCapacity · SetMapSize |
EmptyCount | int | 空位数量(只读)。超出容量时为 0 |
IsFull · IsEmpty | bool | 是否已满(物料数量大于等于容量)· 是否为空(只读) |
HaveDevice | bool | 是否至少有一件物料(只读) |
ColumnCount · RowCount | int | Map 的列 · 行数 |
| 方法 | 说明 |
|---|---|
bool AddDevice() · bool AddDevice(int index) · bool AddDevice(int col, int row) | 添加物料 — 与 DEVICEMGR.AddDevice 相同 |
bool RemoveDevice(int index=-1) · bool RemoveDevice(int col, int row) | 删除物料 — 与 DEVICEMGR.RemoveDevice · RemoveDeviceMap 相同 |
int GetRank(int index) · int GetRank(int col, int row) | 该格物料的 Rank。没有物料或位置错误时为 0 |
bool MakeFull(int rank) | 用 Rank 为 rank 的物料填满 Array · Map 的所有格子(替换已有物料) |
bool Clear() | 删除所有物料 |
方法
DEVICEMGR 函数的第一个参数是容器名称。若没有该名称的容器,会记录错误日志并返回 false(数量 · 大小函数返回 0,列搜索函数返回 -1)。
容器
| 方法 | 说明 |
|---|---|
bool ClearContainerAll(void) | 删除所有容器的物料,并且也清除所有容器的注册。项目的容器会在重新打开项目时重新注册,但在此之前保存项目的话,容器定义会从项目中消失 |
bool AddContainer(string containerName, string sensorName="", bool log=true) | 添加 Single 容器(容量 1)。sensorName 是该位置的传感器 IO 名称,log 表示是否输出日志。已存在同名容器则返回 false |
bool Contains(string name) | 确认是否存在该名称的容器 |
bool SetCapacity(string containerName, int capacity) 4.0+ | 更改容量(1 以上)。Map 请使用 SetMapSize。在仍有物料的情况下缩小时,Array 后部格子中的物料会一并消失 |
bool SetMapSize(string containerName, int col, int row) 4.0+ | 更改 Map 容器的列 · 行数(各 1 以上)。若仍有物料,物料的位置可能会改变 |
int GetCapacity(string containerName) | 可容纳的物料数量 |
int GetColumnCount(string containerName) | Map 的 Column(列)数 |
int GetRowCount(string containerName) | Map 的 Row(行)数 |
物料的添加 · 移除
| 方法 | 说明 |
|---|---|
bool AddDevice(string containerName) | 向 Single · Queue · Stack 添加 1 件物料。若为 Array · Map 则返回 false |
bool AddDevice(string containerName, int index) | 在 Array · Map 的第 index 个空格放置 1 件物料 |
bool AddDevice(string containerName, int colIndex, int rowIndex) | 在 Map 的(colIndex, rowIndex)空格放置 1 件物料 |
bool SetDevice(string containerName, int index) · bool SetDevice(string containerName, int colIndex, int rowIndex) | 在 Array · Map 的格子中放置新物料。与 AddDevice 不同,即使已有物料也会替换为新物料(该格原有数据会消失) |
bool RemoveDevice(string containerName, int index=-1) | 删除 1 件物料。Single · Queue 为先进入的物料,Stack 为最后一件,Array · Map 为第 index 格(-1 则为靠前的第一件物料) |
bool RemoveDeviceMap(string containerName, int colIndex, int rowIndex) | 删除 Map 的(colIndex, rowIndex)格的物料 |
bool RemoveContainerDevice(string containerName) | 只删除 1 件物料(与 RemoveDevice(名称) 相同)。只要容器存在,即使为空也返回 true |
bool ClearContainerDevice(string containerName) | 删除容器的所有物料 |
bool MakeEmpty(string containerName) | 与 ClearContainerDevice 相同 |
bool MakeFull(string containerName, int rank) | 用 Rank 为 rank 的物料填满 Array · Map 的所有格子(替换已有物料)。与 CONTAINER["名称"].MakeFull(rank) 相同 |
bool ClearAllDevice(void) | 删除所有容器的物料。容器保留 |
移动
将物料从 name1 容器移到 name2 容器。物料数据整体移动。
接收方没有空位(Array · Map 的该格已有物料),或没有可发送的物料时,不会移动并返回 false,物料保留在原位置。
Array · Map 容器必须指定位置。
| 方法 | 说明 |
|---|---|
bool MoveDevice(string name1, string name2) | 将代表物料从一个容器移到另一个容器 |
bool MoveDevice(string name1, int index1, string name2) | 从 name1 的指定位置移到 name2 |
bool MoveDevice(string name1, string name2, int index2) | 从 name1 移到 name2 的指定位置 |
bool MoveDevice(string name1, int index1, string name2, int index2) | 两边都指定位置 |
bool MoveDevice(string name1, int col1, int row1, string name2) | 从 name1 的 Column/Row 移到 name2 |
bool MoveDevice(string name1, string name2, int col2, int row2) | 从 name1 移到 name2 的 Column/Row |
bool MoveDevice(string name1, int col1, int row1, string name2, int index2) | Column/Row → 索引 |
bool MoveDevice(string name1, int index1, string name2, int col2, int row2) | 索引 → Column/Row |
bool MoveDevice(string name1, int col1, int row1, string name2, int col2, int row2) | 两边都指定 Column/Row |
bool MoveDeviceAll(string name1, string name2) | 将所有物料从 name1 移到 name2。两个容器的类型必须相同,Array · Map 的容量必须相同且接收方必须为空。不能用于 Stack |
| 参数 | 说明 |
|---|---|
string name1 | 发送物料的容器名称 |
string name2 | 接收物料的容器名称 |
int index1 / col1 / row1 | 发送容器中的物料位置 |
int index2 / col2 / row2 | 接收容器中的物料位置 |
查询
| 方法 | 说明 |
|---|---|
int GetDeviceCount(string containerName) | 容器中的物料数量 |
int GetDeviceCountAll(void) | 所有容器的物料数量合计 |
bool IsFull(string containerName) | 是否已满(物料数量大于等于容量) |
bool IsEmpty(string containerName) | 是否一件物料也没有 |
Map 位置搜索
frontToRear 是行搜索方向(false:从第 0 行开始 / true:从最后一行开始),leftToRight 是列搜索方向(true:从第 0 列开始 / false:从最后一列开始)。
在非 Map 的容器中视为未找到(false,列搜索为 -1)。
| 方法 | 说明 |
|---|---|
bool GetDevicePos(string containerName, bool frontToRear, bool leftToRight, ref int col, ref int row) 4.0+ | 找出第一个有物料的位置。没有则返回 false,col · row 为 -1 |
bool GetDeviceRankPos(string containerName, int rank, bool frontToRear, bool leftToRight, ref int col, ref int row) 4.0+ | 找出 Rank 为 rank 的物料的第一个位置 |
bool GetEmptyPos(string containerName, bool frontToRear, bool leftToRight, ref int col, ref int row) 4.0+ | 找出第一个空位置(用于放下物料) |
int GetDeviceCol(string containerName, int row, bool leftToRight) | 返回指定 row 中有物料的 Column(没有则 -1) |
int GetDeviceRankCol(string containerName, int row, int rank, bool leftToRight) | 返回指定 row 中 Rank 为 rank 的物料的 Column(没有则 -1) |
int GetEmptyCol(string containerName, int row, bool leftToRight) | 返回指定 row 中空着的 Column(没有则 -1) |
传感器比较 · 日志
| 方法 | 说明 |
|---|---|
bool CompareDeviceDataSensor(void) | 在所有指定了传感器的容器中,比较物料有无与传感器检测状态是否一致。只要有一个不同,或传感器 IO 名称有误,则返回 false。未指定传感器的容器不参与比较 |
string GetDeviceDataSensorCompareResult(void) | 返回按行记录不一致容器内容的字符串(全部一致则返回空字符串) |
bool AddLogDeviceInfo(string info) | 将各容器的 名称(物料数/容量) 以一行调试日志记录。info 是附加在该行上的标识字符串(可用 SYS.SetDebugLog(false) 关闭) |
void AddLogContainerDevice(string containerName) | 将容器所有格子以 ●(有物料)· ○(无)记录到日志。Map 每行一行 |
属性
| 属性 | 类型 | 说明 |
|---|---|---|
DeviceInfo | string | 将所有容器的 名称(物料数/容量) 以逗号连接的字符串(只读) |
Count | int | 已注册的容器数量(只读)。物料数量通过 GetDeviceCountAll() 获得 |
Name | string | DEVICEMGR 自身的名称(Main)— 不是容器名称 |
参考
- Map 通过
GetColumnCount·GetRowCount,Array 通过GetCapacity获得大小,再用循环依次查看格子。 - 离开产线的物料用
RemoveDevice删除。设备初始化时,用ClearAllDevice清除所有物料信息(容器保留)。ClearContainerAll连容器注册也会清除,因此运行中不要使用。 - 3.x 的
GetDeviceRow·GetDeviceRankRow·GetEmptyRow在 4.0 中已取消 — 请换成GetDevicePos·GetDeviceRankPos·GetEmptyPos。