using DefaultNamespace; using System; 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; void Start() { boxbtn.onClick.AddListener(Tests); } private 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)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { Debug.Log(gameObject.tag); 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); Cardata cardata = JsonUtility.FromJson(data); UIDeviceBaseInfoPanel.Getdata(cardata.type, cardata.time, cardata.result.id, cardata.result.boxCode, cardata.result.car_Layer, cardata.result.car_X, cardata.result.car_Y, cardata.result.carPLT, cardata.result.error1, cardata.result.error2, cardata.result.error3, cardata.result.error4, cardata.result.error5, "参数不够", () => { UIDeviceBaseInfoPanel.gameObject.SetActive(false); }); UIDeviceBaseInfoPanel.gameObject.SetActive(true); })); } if (hit.collider.CompareTag("Box")) { Boxinformation boxinformation = hit.collider.gameObject.GetComponent(); Debug.Log(boxinformation.locationId); string url = Boxinformationface + boxinformation.locationId; StartCoroutine(Post1(url, (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(10)) { UIBoxdatapanel.Getdata(cigaretteinformation.result[i].itemDesc, cigaretteinformation.result[i].batch, cigaretteinformation.result[i].palletNum, cigaretteinformation.result[i].weight + "Kg"); }; if (cigaretteinformation.result[i].lineNum.Equals(20)) { UIBoxdatapanel.GetDragdown(cigaretteinformation.result[i].palletNum, cigaretteinformation.result[i].weight + "Kg"); } } UIBoxdatapanel.Getoff(() => { UIBoxdatapanel.gameObject.SetActive(false); }); UIBoxdatapanel.gameObject.SetActive(true); })); } if (hit.collider.CompareTag("Hoister")) { 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.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.fauleFree, elevatdata.result.carRGVInspection1, elevatdata.result.liftAirSwitchFault, elevatdata.result.carRGVInspection2, elevatdata.result.deliveryControllerFault, elevatdata.result.deliveryIsolationSwitchFault, elevatdata.result.liftAirSwitchFault, () => { UIHoister.gameObject.SetActive(false); }); UIHoister.gameObject.SetActive(true); })); } if (hit.collider.CompareTag("Palletizer")) { 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.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, () => { UIPalletizer.gameObject.SetActive(false); }); UIPalletizer.gameObject.SetActive(true); })); } if (hit.collider.CompareTag("Battery")) { 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.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, () => { UIReplacebattery.gameObject.SetActive(false); }); UIReplacebattery.gameObject.SetActive(true); })); } if (hit.collider.CompareTag("Outofthe")) { 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.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, () => { UIConveyorpanel.gameObject.SetActive(false); }); UIConveyorpanel.gameObject.SetActive(true); })); } if (hit.collider.CompareTag("Intothe")) { 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.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, () => { UIConveyorpanel.gameObject.SetActive(false); }); UIConveyorpanel.gameObject.SetActive(true); })); } if (hit.collider.CompareTag("floortype")) { 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, () => { UIFloorelevator.gameObject.SetActive(false); }); UIFloorelevator.gameObject.SetActive(true); })); } if (hit.collider.CompareTag("decap")) { 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.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, () => { UICoverremovalmachine.gameObject.SetActive(false); }); UICoverremovalmachine.gameObject.SetActive(true); })); } } } } }