using cakeslice; using DefaultNamespace; using System; using System.Collections.Generic; using Unity.VisualScripting; using UnityEngine; using UnityEngine.UI; using static InterfaceManager; /// /// 判断箱子的状态 /// public enum Status { Alayer, Layertwo, Cutonefloor, Openbilayer } public class Interaction : MonoBehaviour { /// /// 箱子弹窗 /// public Boxdatapanel UIBoxdatapanel; /// /// 小车弹窗 /// public DeviceBaseInfoPanel UIDeviceBaseInfoPanel; /// /// 输送机 /// public Conveyorpanel UIConveyorpanel; /// /// 提升机窗口 /// public Hoister UIHoister; /// /// 码垛机弹窗 /// public Palletizer UIPalletizer; /// /// 换电池弹窗 /// public Replacebattery UIReplacebattery; /// /// 落地式提升机 /// public Floorelevator UIFloorelevator; /// /// 加去盖机 /// public Coverremovalmachine UICoverremovalmachine; /// /// 显示隐藏箱子按钮 /// public Button boxbtn; /// /// 控制箱子显示隐藏 /// public Status status = Status.Alayer; /// /// 计算双击间隔时间 /// private float lastClickTime = 0f; public float doubleClickTime = 0.3f; public List Pages = new List(); void Start() { boxbtn.onClick.AddListener(Tests); } public void Tests() { switch (status) { case Status.Alayer: for (int i = 0; i < MqttManager.Instance.firstbox.Count; i++) { MqttManager.Instance.firstbox[i].SetActive(false); } status = Status.Layertwo; break; case Status.Layertwo: for (int i = 0; i < MqttManager.Instance.secondbox.Count; i++) { MqttManager.Instance.secondbox[i].SetActive(false); } status = Status.Cutonefloor; break; case Status.Cutonefloor: for (int i = 0; i < MqttManager.Instance.firstbox.Count; i++) { MqttManager.Instance.firstbox[i].SetActive(true); } status = Status.Openbilayer; break; case Status.Openbilayer: for (int i = 0; i < MqttManager.Instance.secondbox.Count; i++) { MqttManager.Instance.secondbox[i].SetActive(true); } status = Status.Alayer; break; default: break; } } /// /// 显示各个设备页面信息 /// void Update() { if (UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject()) return; if (Input.GetMouseButtonDown(0)) { if (Time.time - lastClickTime < doubleClickTime) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { if (hit.collider.CompareTag("Car")) { Carinformation carinformation = hit.collider.gameObject.GetComponent(); //Debug.Log(carinformation.ID); string url = Carinterface + carinformation.ID; StartCoroutine(Post1(url, (data) => { // Debug.Log(data); Debug.Log("小车返回数据" + data); Cardata cardata = JsonUtility.FromJson(data); string pos = cardata.result.carRow + "行-" + cardata.result.carColumn + "列-" + cardata.result.carLayer + "层"; UIDeviceBaseInfoPanel.Getdata(cardata.result.id, cardata.result.carMode, pos, cardata.result.carPlt, cardata.result.isOnline, cardata.result.boxCode, cardata.result.batCurrent, cardata.result.jobID, cardata.result.error1, cardata.result.batVoltage, cardata.result.carAngle, cardata.result.batTemperature, () => { Removeprompt(); UIDeviceBaseInfoPanel.gameObject.SetActive(false); }); UIDeviceBaseInfoPanel.gameObject.SetActive(true); })); } else if (hit.collider.CompareTag("Box")) { //Debug.Log(gameObject.name); if (hit.collider.gameObject.GetComponent()) { //Debug.Log("ID" + hit.collider.gameObject.GetComponent().ID); if (hit.collider.gameObject.GetComponent().ID.Length > 0) { // Debug.Log("暂无数据"); //Debug.Log(hit.collider.gameObject.GetComponent().ID); Boxtasknumber boxtasknumber = hit.collider.gameObject.GetComponent(); string url = Tasknumber + boxtasknumber.ID; //Debug.Log(url); StartCoroutine(Getstring(url, (data) => { //Debug.Log(data); Initdata initdata = JsonUtility.FromJson(data); for (int i = 0; i < initdata.result.Count; i++) { UIBoxdatapanel.Getbox(initdata.result[i].dLocDesc, initdata.result[i].creatDate, initdata.result[i].itemDesc, initdata.result[i].batch, initdata.result[i].topBoxCode, initdata.result[i].bottomBoxWeight, initdata.result[i].palletNum, initdata.result[i].topBoxWeight, () => { UIBoxdatapanel.gameObject.SetActive(false); }); } UIBoxdatapanel.gameObject.SetActive(true); })); } else { Boxinformation boxinformation = hit.collider.gameObject.GetComponent(); if (boxinformation.locationId.Length > 0) { string url = Boxinformationface + boxinformation.locationId; StartCoroutine(Post1(url, (data) => { //Debug.Log(data); Cigaretteinformation cigaretteinformation = JsonUtility.FromJson(data); // Debug.Log(cigaretteinformation.time); for (int i = 0; i < cigaretteinformation.result.Count; i++) { if (cigaretteinformation.result[i].lineNum.Equals(1)) { UIBoxdatapanel.GetDragdown(cigaretteinformation.result[i].palletNum, cigaretteinformation.result[i].weight); }; if (cigaretteinformation.result[i].lineNum.Equals(2)) { UIBoxdatapanel.Getdata(cigaretteinformation.result[i].dLocDesc, cigaretteinformation.result[i].moveInDate, cigaretteinformation.result[i].itemDesc, cigaretteinformation.result[i].batch, cigaretteinformation.result[i].rfIdCode, cigaretteinformation.result[i].weight); ; } } UIBoxdatapanel.Getoff(() => { UIBoxdatapanel.gameObject.SetActive(false); }); UIBoxdatapanel.gameObject.SetActive(true); })); } else { //Debug.Log("不满足条件"); } } } } else if (hit.collider.CompareTag("Hoister")) { //Debug.Log(gameObject.name); Consentmark hoistinformation = hit.collider.gameObject.GetComponent(); // Debug.Log(hoistinformation.ID); string url = Hoisinterface + hoistinformation.ID; // Debug.Log(url); StartCoroutine(Post1(url, (data) => { Debug.Log(data); Elevatorpopup elevatdata = JsonUtility.FromJson(data); // Debug.Log(elevatdata.result.lowerDecelerationInspection); UIHoister.Gethoister(elevatdata.result.equipmentPlaneNumber, elevatdata.result.taskNumber, elevatdata.result.currentLayer, elevatdata.result.targetLayer, elevatdata.result.startingLayer, elevatdata.result.workingStatus, elevatdata.result.lowerBoxNumber, elevatdata.result.descent, elevatdata.result.forwardCargoInspection, elevatdata.result.downInPlaceInspection, elevatdata.result.upperInPlaceInspection, elevatdata.result.overboundaryInspection1, elevatdata.result.overboundaryInspection2, elevatdata.result.upperlimitInspection, elevatdata.result.lowerlimitInspection, elevatdata.result.conveyingForwardOperation, elevatdata.result.deliveryTimeoutFault, elevatdata.result.faultFree, elevatdata.result.carRGVInspection1, elevatdata.result.liftAirSwitchFault, elevatdata.result.carRGVInspection2, elevatdata.result.deliveryControllerFault, elevatdata.result.deliveryIsolationSwitchFault, elevatdata.result.liftAirSwitchFault, () => { Removeprompt(); UIHoister.gameObject.SetActive(false); }); UIHoister.gameObject.SetActive(true); })); } else if (hit.collider.CompareTag("Palletizer")) { //Debug.Log(gameObject.name); Consentmark palletizerparameters = hit.collider.gameObject.GetComponent(); // Debug.Log(palletizerparameters.ID); string url = Palletizerface + palletizerparameters.ID; //Debug.Log(url); StartCoroutine(Post1(url, (data) => { Debug.Log(data); PalletizerMessage palletizer = JsonUtility.FromJson(data); // Debug.Log(palletizer.result.id); UIPalletizer.Getpalletizer(palletizer.result.equipmentPlaneNumber, palletizer.result.boxesNumber, palletizer.result.leftExtensionForkPositionInspection, palletizer.result.rightExtensionForkPositionInspection, palletizer.result.upperInPlace, palletizer.result.downInPlace, palletizer.result.leftRetractionForkPositionInspection, palletizer.result.rightRetractionForkPositionInspection, palletizer.result.forkExtensionInPlace, palletizer.result.forkRetractionInPlace, palletizer.result.forkCargoInspection, palletizer.result.superelevationFault, palletizer.result.faultFree, palletizer.result.leftCargoForkExtensionFork, palletizer.result.liftAirSwitchFault, palletizer.result.liftControllerFault, palletizer.result.leftForkIsolationFault, palletizer.result.rightForkIsolationFault, palletizer.result.liftIsolatingFault, () => { Removeprompt(); UIPalletizer.gameObject.SetActive(false); }); UIPalletizer.gameObject.SetActive(true); })); } else if (hit.collider.CompareTag("Battery")) { //Debug.Log(gameObject.name); Consentmark batterychanger = hit.collider.gameObject.GetComponent(); //Debug.Log(batterychanger.ID); string url = Batteryface + batterychanger.ID; // Debug.Log(url); StartCoroutine(Post1(url, (data) => { //Debug.Log(data); Batterydata batterydata = JsonUtility.FromJson(data); //Debug.Log(batterydata.result.id); UIReplacebattery.Getbattery(batterydata.result.equipmentPlaneNumber, batterydata.result.taskNumber, batterydata.result.batteryStatus0, batterydata.result.batteryStatus1, batterydata.result.batteryStatus2, batterydata.result.batteryStatus3, batterydata.result.retractingClaws, batterydata.result.upperInPlace, batterydata.result.lowerInPlace, batterydata.result.hookClawInPlace, batterydata.result.clawRetractedInPlace, batterydata.result.walkingAirSwitchFault, batterydata.result.liftAirSwitchFault, batterydata.result.walkControllerFault, batterydata.result.liftControllerFault, batterydata.result.forkExtensionTimeoutFault, batterydata.result.forkRetractionTimeoutFault, () => { Removeprompt(); UIReplacebattery.gameObject.SetActive(false); }); UIReplacebattery.gameObject.SetActive(true); })); } else if (hit.collider.CompareTag("Outofthe")) { //Debug.Log(gameObject.name); Consentmark outofthe = hit.collider.GetComponent(); // Debug.Log(outofthe.ID); string url = Outoftheface + outofthe.ID; // Debug.Log(url); StartCoroutine(Post1(url, (data) => { Debug.Log(data); Conveyors outofthe = JsonUtility.FromJson(data); Debug.Log(outofthe.result.id); UIConveyorpanel.Getconvey(outofthe.result.equipmentPlaneNumber, outofthe.result.taskNumber, outofthe.result.upperBoxNumber, outofthe.result.startingAddress, outofthe.result.upperBoxTobaccoWeight, outofthe.result.destinationAddress, outofthe.result.lowerBoxNumber, outofthe.result.cleanMark, outofthe.result.lowerBoxTobaccoWeight, outofthe.result.samplingInspectionMark, outofthe.result.boxesNumber, outofthe.result.faultFree, outofthe.result.deliveryControllerFault, outofthe.result.deviceStatus, outofthe.result.deliveryTimeoutFault, outofthe.result.deliveryAirSwitchFault, outofthe.result.deliveryIsolationSwitchFault, () => { Removeprompt(); UIConveyorpanel.gameObject.SetActive(false); }); UIConveyorpanel.gameObject.SetActive(true); })); } else if (hit.collider.CompareTag("Intothe")) { //Debug.Log(gameObject.name); Consentmark intothes = hit.collider.GetComponent(); // Debug.Log(intothes.ID); string url = Intotheface + intothes.ID; // Debug.Log(url); StartCoroutine(Post1(url, (data) => { //Debug.Log(data); Conveyors intothe = JsonUtility.FromJson(data); //Debug.Log(intothe.result.id); UIConveyorpanel.Getconvey(intothe.result.equipmentPlaneNumber, intothe.result.taskNumber, intothe.result.upperBoxNumber, intothe.result.startingAddress, intothe.result.upperBoxTobaccoWeight, intothe.result.destinationAddress, intothe.result.lowerBoxNumber, intothe.result.cleanMark, intothe.result.lowerBoxTobaccoWeight, intothe.result.samplingInspectionMark, intothe.result.boxesNumber, intothe.result.faultFree, intothe.result.deliveryControllerFault, intothe.result.deviceStatus, intothe.result.deliveryTimeoutFault, intothe.result.deliveryAirSwitchFault, intothe.result.deliveryIsolationSwitchFault, () => { Removeprompt(); UIConveyorpanel.gameObject.SetActive(false); }); UIConveyorpanel.gameObject.SetActive(true); })); } else if (hit.collider.CompareTag("floortype")) { //Debug.Log(gameObject.name); Consentmark floor = hit.collider.gameObject.GetComponent(); //Debug.Log(floor.ID); string url = Floorface + floor.ID; //Debug.Log(url); StartCoroutine(Post1(url, (data) => { //Debug.Log(data); Feequipments feequipments = JsonUtility.FromJson(data); //Debug.Log(feequipments.result.id); UIFloorelevator.Getfloorele(feequipments.result.deviceStatus, feequipments.result.upperInPlace, feequipments.result.ascent, feequipments.result.upperLimitInspection, feequipments.result.lowerInPlace, feequipments.result.descent, feequipments.result.lowerLimitInspection, feequipments.result.overBoundaryInspection1, feequipments.result.overBoundaryInspection2, feequipments.result.faultFree, feequipments.result.liftAirSwitchFault, feequipments.result.liftControllerFault, feequipments.result.liftIsolatingSwitchFault, feequipments.result.upperLimitFault, feequipments.result.lowerLimitFault, feequipments.result.deliveryControllerFault, feequipments.result.deliveryIsolationFault, feequipments.result.deliveryTimeoutFault, feequipments.result.transboundaryFault, () => { Removeprompt(); UIFloorelevator.gameObject.SetActive(false); }); UIFloorelevator.gameObject.SetActive(true); })); } else if (hit.collider.CompareTag("decap")) { //Debug.Log(gameObject.name); Consentmark decaps = hit.collider.gameObject.GetComponent(); //Debug.Log(decaps.ID); string url = Decapface + decaps.ID; //Debug.Log(url); StartCoroutine(Post1(url, (data) => { //Debug.Log(data); Decappingmachine decappingmachine = JsonUtility.FromJson(data); // Debug.Log(decappingmachine.result.id); UICoverremovalmachine.Getdecap(decappingmachine.result.equipmentPlaneNumber, decappingmachine.result.caseLidStatus, decappingmachine.result.frontInPlaceInspection, decappingmachine.result.rearInPlaceInspection, decappingmachine.result.frontDecelerationInspection, decappingmachine.result.rearDecelerationInspection, decappingmachine.result.frontLimitInspection, decappingmachine.result.rearLimitInspection, decappingmachine.result.no1CylinderUpperPositionInspection, decappingmachine.result.no1CylinderLowerPositionInspection, decappingmachine.result.no2CylinderUpperPositionInspection, decappingmachine.result.no2CylinderLowerPositionInspection, decappingmachine.result.no3CylinderUpperPositionInspection, decappingmachine.result.no3CylinderLowerPositionInspection, decappingmachine.result.no4CylinderUpperPositionInspection, decappingmachine.result.no4CylinderLowerPositionInspection, decappingmachine.result.upperInPlace, decappingmachine.result.lowerInPlace, decappingmachine.result.ascendingClampRun, decappingmachine.result.loweringReleasingCoverRun, decappingmachine.result.faultFree, decappingmachine.result.runningEmptyBreakdownFault, decappingmachine.result.runningControllerFault, decappingmachine.result.runningIsolationFault, decappingmachine.result.preRunLimitFault, decappingmachine.result.postRunLimitFault, decappingmachine.result.cylinderRiseTimeoutFault, decappingmachine.result.cylinderLoweringTimeoutFault, () => { Removeprompt(); UICoverremovalmachine.gameObject.SetActive(false); }); UICoverremovalmachine.gameObject.SetActive(true); })); } } } lastClickTime = Time.time; } } /// /// 移除提示亮光 /// private void Removeprompt() { if (OutlineEffect.Instance.outlines.Count > 0) { OutlineEffect.Instance.outlines.Clear(); } } /// /// /// /// public void Popupwindow(string value) { int index = int.Parse(value); if (index > 0 && index < 9) { if (Pages.Count > 0) { for (int i = 0; i < Pages.Count; i++) { if (Pages[i].gameObject) { Pages[i].SetActive(false); } } Removeprompt(); } string url = Carinterface + index; StartCoroutine(Post1(url, (data) => { // Debug.Log(data); Debug.Log("小车返回数据" + data); Cardata cardata = JsonUtility.FromJson(data); string pos = cardata.result.carRow + "行-" + cardata.result.carColumn + "列-" + cardata.result.carLayer + "层"; UIDeviceBaseInfoPanel.Getdata(cardata.result.id, cardata.result.carMode, pos, cardata.result.carPlt, cardata.result.isOnline, cardata.result.boxCode, cardata.result.batCurrent, cardata.result.jobID, cardata.result.error1, cardata.result.batVoltage, cardata.result.carAngle, cardata.result.batTemperature, () => { Removeprompt(); UIDeviceBaseInfoPanel.gameObject.SetActive(false); }); UIDeviceBaseInfoPanel.gameObject.SetActive(true); })); } } }