| | |
| | | import com.zy.core.model.CommandResponse; |
| | | import com.zy.core.model.StationObjModel; |
| | | import com.zy.core.model.command.StationCommand; |
| | | import com.zy.core.model.protocol.StationTaskBufferItem; |
| | | import com.zy.core.network.api.ZyStationConnectApi; |
| | | import com.zy.core.network.entity.ZyStationStatusEntity; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.text.MessageFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.Comparator; |
| | | import java.util.Date; |
| | |
| | | statusEntity.setError(0);//默认无报警 |
| | | |
| | | statusEntity.setTaskWriteIdx((int) siemensNet.getByteTransform().TransInt16(result.Content, i * 10 + 8));//任务可写区 |
| | | fillTaskBufferStatus(i, statusEntity); |
| | | } |
| | | } |
| | | |
| | |
| | | return null; |
| | | } |
| | | |
| | | private void fillTaskBufferStatus(int stationIdx, ZyStationStatusEntity statusEntity) { |
| | | if (statusEntity == null || stationIdx < 0) { |
| | | return; |
| | | } |
| | | List<StationTaskBufferItem> itemList = new ArrayList<>(); |
| | | OperateResultExOne<byte[]> resultTask = siemensNet.Read("DB13." + (stationIdx * TASK_AREA_LENGTH), (short) TASK_AREA_LENGTH); |
| | | if (resultTask.IsSuccess && resultTask.Content != null) { |
| | | for (int slotIdx = 1; slotIdx <= TASK_AREA_SLOT_COUNT; slotIdx++) { |
| | | int offset = slotIdx * TASK_AREA_SLOT_SIZE; |
| | | int taskNo = siemensNet.getByteTransform().TransInt32(resultTask.Content, offset); |
| | | int targetPoint = siemensNet.getByteTransform().TransInt16(resultTask.Content, offset + 6); |
| | | StationTaskBufferItem item = new StationTaskBufferItem(); |
| | | item.setSlotIdx(slotIdx); |
| | | item.setTaskNo(taskNo); |
| | | item.setTargetStaNo(targetPoint); |
| | | itemList.add(item); |
| | | } |
| | | } |
| | | statusEntity.setTaskBufferItems(itemList); |
| | | } |
| | | |
| | | private int findIndex(Integer stationId) { |
| | | for (int i = 0; i < statusList.size(); i++) { |
| | | ZyStationStatusEntity statusEntity = statusList.get(i); |