U3D_TobaccoWarehouseISMDTSy.../Assets/Scripts/YL/Interaction.cs

354 lines
20 KiB
C#

using cakeslice;
using DefaultNamespace;
using System;
using UnityEngine;
using UnityEngine.UI;
using static InterfaceManager;
/// <summary>
/// 判断箱子的状态
/// </summary>
public enum Status
{
Alayer,
Layertwo,
Cutonefloor,
Openbilayer
}
public class Interaction : MonoBehaviour
{
/// <summary>
/// 箱子弹窗
/// </summary>
public Boxdatapanel UIBoxdatapanel;
/// <summary>
/// 小车弹窗
/// </summary>
public DeviceBaseInfoPanel UIDeviceBaseInfoPanel;
/// <summary>
/// 输送机
/// </summary>
public Conveyorpanel UIConveyorpanel;
/// <summary>
/// 提升机窗口
/// </summary>
public Hoister UIHoister;
/// <summary>
/// 码垛机弹窗
/// </summary>
public Palletizer UIPalletizer;
/// <summary>
/// 换电池弹窗
/// </summary>
public Replacebattery UIReplacebattery;
/// <summary>
/// 落地式提升机
/// </summary>
public Floorelevator UIFloorelevator;
/// <summary>
/// 加去盖机
/// </summary>
public Coverremovalmachine UICoverremovalmachine;
/// <summary>
/// 显示隐藏箱子按钮
/// </summary>
public Button boxbtn;
/// <summary>
/// 控制箱子显示隐藏
/// </summary>
public Status status = Status.Alayer;
/// <summary>
/// 计算双击间隔时间
/// </summary>
private float lastClickTime = 0f;
public float doubleClickTime = 0.3f;
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;
}
}
/// <summary>
/// 显示各个设备页面信息
/// </summary>
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<Carinformation>();
////Debug.Log(carinformation.ID);
//string url = Carinterface + carinformation.ID;
//StartCoroutine(Post1(url, (data) =>
//{
// UIDeviceBaseInfoPanel.gameObject.SetActive(true);
// // Debug.Log(data);
// Cardata cardata = JsonUtility.FromJson<Cardata>(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);
// });
//}));
}
if (hit.collider.CompareTag("Box"))
{
Debug.Log(gameObject.name);
if (hit.collider.gameObject.GetComponent<Boxinformation>())
{
Boxinformation boxinformation = hit.collider.gameObject.GetComponent<Boxinformation>();
//if (boxinformation.itemType == "EmptyBox")
//{
// UIBoxdatapanel.Emptydata("空箱子");
//}
//Debug.Log(boxinformation.locationId);
string url = Boxinformationface + boxinformation.locationId;
Debug.Log(url);
StartCoroutine(Post1(url, (data) =>
{
Debug.Log(data);
Cigaretteinformation cigaretteinformation = JsonUtility.FromJson<Cigaretteinformation>(data);
// Debug.Log(cigaretteinformation.time);
for (int i = 0; i < cigaretteinformation.result.Count; i++)
{
if (cigaretteinformation.result[i].lineNum.Equals(1))
{
UIBoxdatapanel.Getdata(cigaretteinformation.result[i].itemDesc, cigaretteinformation.result[i].batch, cigaretteinformation.result[i].palletNum, cigaretteinformation.result[i].weight);
};
if (cigaretteinformation.result[i].lineNum.Equals(2))
{
UIBoxdatapanel.GetDragdown(cigaretteinformation.result[i].palletNum, cigaretteinformation.result[i].weight);
}
}
UIBoxdatapanel.Getoff(() =>
{
UIBoxdatapanel.gameObject.SetActive(false);
});
UIBoxdatapanel.gameObject.SetActive(true);
}));
}
}
if (hit.collider.CompareTag("Hoister"))
{
Debug.Log(gameObject.name);
Consentmark hoistinformation = hit.collider.gameObject.GetComponent<Consentmark>();
// Debug.Log(hoistinformation.ID);
string url = Hoisinterface + hoistinformation.ID;
// Debug.Log(url);
StartCoroutine(Post1(url, (data) =>
{
Debug.Log(data);
Elevatorpopup elevatdata = JsonUtility.FromJson<Elevatorpopup>(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.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);
}));
}
if (hit.collider.CompareTag("Palletizer"))
{
Debug.Log(gameObject.name);
Consentmark palletizerparameters = hit.collider.gameObject.GetComponent<Consentmark>();
// Debug.Log(palletizerparameters.ID);
string url = Palletizerface + palletizerparameters.ID;
//Debug.Log(url);
StartCoroutine(Post1(url, (data) =>
{
Debug.Log(data);
PalletizerMessage palletizer = JsonUtility.FromJson<PalletizerMessage>(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, () =>
{
Removeprompt();
UIPalletizer.gameObject.SetActive(false);
});
UIPalletizer.gameObject.SetActive(true);
}));
}
if (hit.collider.CompareTag("Battery"))
{
Debug.Log(gameObject.name);
Consentmark batterychanger = hit.collider.gameObject.GetComponent<Consentmark>();
//Debug.Log(batterychanger.ID);
string url = Batteryface + batterychanger.ID;
// Debug.Log(url);
StartCoroutine(Post1(url, (data) =>
{
Debug.Log(data);
Batterydata batterydata = JsonUtility.FromJson<Batterydata>(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, () =>
{
Removeprompt();
UIReplacebattery.gameObject.SetActive(false);
});
UIReplacebattery.gameObject.SetActive(true);
}));
}
if (hit.collider.CompareTag("Outofthe"))
{
Debug.Log(gameObject.name);
Consentmark outofthe = hit.collider.GetComponent<Consentmark>();
// Debug.Log(outofthe.ID);
string url = Outoftheface + outofthe.ID;
// Debug.Log(url);
StartCoroutine(Post1(url, (data) =>
{
Debug.Log(data);
Conveyors outofthe = JsonUtility.FromJson<Conveyors>(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, () =>
{
Removeprompt();
UIConveyorpanel.gameObject.SetActive(false);
});
UIConveyorpanel.gameObject.SetActive(true);
}));
}
if (hit.collider.CompareTag("Intothe"))
{
Debug.Log(gameObject.name);
Consentmark intothes = hit.collider.GetComponent<Consentmark>();
// Debug.Log(intothes.ID);
string url = Intotheface + intothes.ID;
// Debug.Log(url);
StartCoroutine(Post1(url, (data) =>
{
Debug.Log(data);
Conveyors intothe = JsonUtility.FromJson<Conveyors>(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, () =>
{
Removeprompt();
UIConveyorpanel.gameObject.SetActive(false);
});
UIConveyorpanel.gameObject.SetActive(true);
}));
}
if (hit.collider.CompareTag("floortype"))
{
Debug.Log(gameObject.name);
Consentmark floor = hit.collider.gameObject.GetComponent<Consentmark>();
//Debug.Log(floor.ID);
string url = Floorface + floor.ID;
//Debug.Log(url);
StartCoroutine(Post1(url, (data) =>
{
Debug.Log(data);
Feequipments feequipments = JsonUtility.FromJson<Feequipments>(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);
}));
}
if (hit.collider.CompareTag("decap"))
{
Debug.Log(gameObject.name);
Consentmark decaps = hit.collider.gameObject.GetComponent<Consentmark>();
//Debug.Log(decaps.ID);
string url = Decapface + decaps.ID;
Debug.Log(url);
StartCoroutine(Post1(url, (data) =>
{
Debug.Log(data);
Decappingmachine decappingmachine = JsonUtility.FromJson<Decappingmachine>(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, () =>
{
Removeprompt();
UICoverremovalmachine.gameObject.SetActive(false);
});
UICoverremovalmachine.gameObject.SetActive(true);
}));
}
}
}
lastClickTime = Time.time;
}
}
/// <summary>
/// 移除提示亮光
/// </summary>
private void Removeprompt()
{
if (OutlineEffect.Instance.outlines.Count > 0)
{
OutlineEffect.Instance.outlines.Clear();
}
}
}