public void setLatestFrameJointForceResult(frameJointForce resultObject)
    {
        latestFrameJointForceResult = resultObject;
        frameJointForceHistory.Insert(0, resultObject);
        if (frameJointForceHistory.Count > resultHistorySlots)
        {
            frameJointForceHistory.RemoveAt(frameJointForceHistory.Count - 1);
        }
        string debugMessage = "set latest FrameJointForce result: \n" + resultObject.ToString();

        Debug.Log(debugMessage);

        int numResults = resultObject.numberResults;
    }
    public void sendString(string message)
    {
        if (pipeStreamString == null)
        {
            Debug.Log("Tried to send message \"" + message + "\" to SAPTranslator, but SAPTranslator has not connected to pipe.");
            return;
        }
        else
        {
            string pipeContent = pipeStreamString.ReadString();
            if (pipeContent != null)
            {
                Debug.Log(pipeContent);
            }
            if (pipeContent.Equals("SAPTranslator to VRE: awaiting command"))
            {
                Debug.Log(message);
                pipeStreamString.WriteString(message);
                pipeServer.WaitForPipeDrain();

                if (message.Contains("resultsFrameJointForce"))
                {
                    frameJointForce frameJointForceObject = readResponseResultsFrameJointForce();
                    myAnalysisController.setLatestFrameJointForceResult(frameJointForceObject);
                }
                else if (message.Contains("resultsFrameForce"))
                {
                    frameForce frameForceObject = readResponseResultsFrameForce();
                    myAnalysisController.setLatestFrameForceResult(frameForceObject);
                }
                else if (message.Contains("resultsJointDispl") || message.Contains("customResultsGetFrameSpecialPointDispl"))
                {
                    jointDispl jointDisplObject = readResponseResultsJointDispl();
                    myAnalysisController.setLatestJointDisplResult(jointDisplObject);
                }
            }
        }
    }
    private frameJointForce readResponseResultsFrameJointForce()
    {
        string[] results = new string[16];
        for (int i = 0; i < results.Length; i++)
        {
            results[i] = pipeStreamString.ReadString();
        }

        //Debug:
        string resultsAsOneString = String.Join("\n", results);

        Debug.Log(resultsAsOneString);
        string messageHeader = results[0];
        string name          = results[1];
        string itemType      = results[2];
        int    numberResults;

        try
        {
            numberResults = int.Parse(results[3], System.Globalization.NumberStyles.Integer);
        }
        catch (FormatException)
        {
            numberResults = 2;
        }
        string[] obj      = results[4].Split('`');
        string[] elm      = results[5].Split('`');
        string[] pointElm = results[6].Split('`');
        string[] loadCase = results[7].Split('`');
        string[] stepType = results[8].Split('`');

        string[] stepNumStrings = results[9].Split('`');
        string[] f1Strings      = results[10].Split('`');
        string[] f2Strings      = results[11].Split('`');
        string[] f3Strings      = results[12].Split('`');
        string[] m1Strings      = results[13].Split('`');
        string[] m2Strings      = results[14].Split('`');
        string[] m3Strings      = results[15].Split('`');

        double[] stepNum = new double[numberResults];
        double[] f1      = new double[numberResults];
        double[] f2      = new double[numberResults];
        double[] f3      = new double[numberResults];
        double[] m1      = new double[numberResults];
        double[] m2      = new double[numberResults];
        double[] m3      = new double[numberResults];

        for (int i = 0; i < numberResults; i++)
        {
            stepNum[i] = Double.Parse(stepNumStrings[i]);
            f1[i]      = Double.Parse(f1Strings[i]);
            f2[i]      = Double.Parse(f2Strings[i]);
            f3[i]      = Double.Parse(f3Strings[i]);
            m1[i]      = Double.Parse(m1Strings[i]);
            m2[i]      = Double.Parse(m2Strings[i]);
            m3[i]      = Double.Parse(m3Strings[i]);
        }

        frameJointForce result = new frameJointForce(name,
                                                     itemType, numberResults, obj, elm, pointElm,
                                                     loadCase, stepType, stepNum, f1, f2, f3, m1, m2, m3);

        return(result);
    }