public void setLatestFrameForceResult(frameForce resultObject)
    {
        latestFrameForceResult = resultObject;
        frameForceHistory.Insert(0, resultObject);
        if (frameForceHistory.Count > resultHistorySlots)
        {
            frameForceHistory.RemoveAt(frameForceHistory.Count - 1);
        }
        string debugMessage = "set latest FrameForce 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 frameForce readResponseResultsFrameForce()
    {
        string[] results = new string[17];
        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 = 9;
        }
        string[] obj            = results[4].Split('`');
        string[] objStaStrings  = results[5].Split('`');
        string[] elm            = results[6].Split('`');
        string[] elmStaStrings  = results[7].Split('`');
        string[] loadCase       = results[8].Split('`');
        string[] stepType       = results[9].Split('`');
        string[] stepNumStrings = results[10].Split('`');
        string[] pStrings       = results[11].Split('`');
        string[] v2Strings      = results[12].Split('`');
        string[] v3Strings      = results[13].Split('`');
        string[] tStrings       = results[14].Split('`');
        string[] m2Strings      = results[15].Split('`');
        string[] m3Strings      = results[16].Split('`');

        double[] objSta  = new double[numberResults];
        double[] elmSta  = new double[numberResults];
        double[] stepNum = new double[numberResults];
        double[] p       = new double[numberResults];
        double[] v2      = new double[numberResults];
        double[] v3      = new double[numberResults];
        double[] t       = new double[numberResults];
        double[] m2      = new double[numberResults];
        double[] m3      = new double[numberResults];

        for (int i = 0; i < numberResults; i++)
        {
            objSta[i]  = Double.Parse(objStaStrings[i]);
            elmSta[i]  = Double.Parse(elmStaStrings[i]);
            stepNum[i] = Double.Parse(stepNumStrings[i]);
            p[i]       = Double.Parse(pStrings[i]);
            v2[i]      = Double.Parse(v2Strings[i]);
            v3[i]      = Double.Parse(v3Strings[i]);
            t[i]       = Double.Parse(tStrings[i]);
            m2[i]      = Double.Parse(m2Strings[i]);
            m3[i]      = Double.Parse(m3Strings[i]);
        }

        frameForce result = new frameForce(name,
                                           itemType, numberResults, obj, objSta, elm, elmSta,
                                           loadCase, stepType, stepNum, p, v2, v3, t, m2, m3);

        return(result);
    }