public void MachineButtonOnClick()
    {
        // do the reading — you might want to attempt to read less often than you draw on the screen for performance sake
        try
        {
            IBarcodeReader barcodeReader = new BarcodeReader();
            // decode the current frame
            var result = barcodeReader.Decode(backCamera.GetPixels32(), backCamera.width, backCamera.height);

            if (result != null)
            {
                Debug.Log("DECODED TEXT FROM QR: " + result.Text);
            }

            QrResult = result.Text;
            JsonEntity jsonEntity = new JsonEntity();
            jsonEntity.JsonFlag   = "MachineQR";
            jsonEntity.JsonObject = QrResult;
            string jsonString = JsonUtility.ToJson(jsonEntity);
            MachineQrCommunication qrCommunication = new MachineQrCommunication();
            qrCommunication.SendDataToServer(jsonString);

            //LoadScene which displays OptimisedRootList of Machines
            SceneManager.LoadScene("OperationScene");
        }
        catch (Exception ex)
        {
            Debug.LogWarning(ex.Message);
            //QrResult = "";
        }
    }
Пример #2
0
    // Use this for initialization
    void Start()
    {
        MachineQrCommunication machineQrCommunication = new MachineQrCommunication();
        string ServerResponse = machineQrCommunication.ReceiveDataFromServer();

        //Receive the CAD file and save to Resources or local of the client machine
        MachineEntity machine = JsonUtility.FromJson <MachineEntity>(ServerResponse);

        instructionsEntity.operationId = machine.operationToDo;
        instructionsEntity.operationInstructionListId = machine.operationInstructionListId;
        instructionsEntity.operationInstructionList   = machine.operationInstructionList;

        //Iterprete CAD Filename
        string CadFilenameAbsolute = machine.machineCADFile;

        string[] file        = CadFilenameAbsolute.Split('/');
        int      counter     = file.Length;
        string   CadFilename = file[counter - 1]; //Exact Filename => example.obj

        //string CadFilename = "gokart_main_assy.obj";
        //This filepath can be changed according to device
        string FilePath = "C:/ARClient/ARTeamcenterClient/Assets/Resources/" + CadFilename;

        byte[] FileBuffer = machineQrCommunication.ReceiveCADFileFromServer();

        // create a file in local and write to file
        BinaryWriter bWrite = new System.IO.BinaryWriter(File.Open(FilePath, FileMode.Create));

        bWrite.Write(FileBuffer);
        bWrite.Flush();
        bWrite.Close();

        //Load CAD model to the scene
        CADImage = OBJLoader.LoadOBJFile(FilePath); //I hope this will work


        //Display first step of the operation on the screen
        InstructionList = machine.operationInstructionList;
        size            = InstructionList.Count;
        NextInformationButton.GetComponentInChildren <Text>().text = "Start";
        InformationText.text = "You will see the instructions here!" +
                               "If you feel you need more information, click the button below!";

        //Highlight the part which will be changed
    }