Esempio n. 1
0
        override public void writeToFile(StreamWriter fp)
        {
            if (fp == null)
            {
                return;
            }

            fp.WriteLine("\t\t\t" + ConUtils.getConLineString(ConUtils.CON_FEEDBACK_START) + " linear");

            fp.WriteLine("\t\t\t\t" + ConUtils.getConLineString(ConUtils.CON_FEEDBACK_PROJECTION_AXIS) + " " + feedbackProjectionAxis.x + " " + feedbackProjectionAxis.y + " " + feedbackProjectionAxis.z);
            fp.WriteLine("\t\t\t\t" + ConUtils.getConLineString(ConUtils.CON_CD) + " " + cd);
            fp.WriteLine("\t\t\t\t" + ConUtils.getConLineString(ConUtils.CON_CV) + " " + cv);
            fp.WriteLine("\t\t\t\t" + ConUtils.getConLineString(ConUtils.CON_REVERSEDCD) + " " + ((reversedCD)?"true":"false"));
            fp.WriteLine("\t\t\t\t" + ConUtils.getConLineString(ConUtils.CON_REVERSEDCV) + " " + ((reversedCV)?"true":"false"));
            if (dMin > -100)
            {
                fp.WriteLine("\t\t\t\t" + ConUtils.getConLineString(ConUtils.CON_D_MIN) + " " + dMin);
            }
            if (dMax < 100)
            {
                fp.WriteLine("\t\t\t\t" + ConUtils.getConLineString(ConUtils.CON_D_MAX) + " " + dMax);
            }
            if (vMin > -100)
            {
                fp.WriteLine("\t\t\t\t" + ConUtils.getConLineString(ConUtils.CON_V_MIN) + " " + vMin);
            }
            if (vMax < 100)
            {
                fp.WriteLine("\t\t\t\t" + ConUtils.getConLineString(ConUtils.CON_V_MAX) + " " + vMax);
            }

            fp.WriteLine("\t\t\t" + ConUtils.getConLineString(ConUtils.CON_FEEDBACK_END));
        }
Esempio n. 2
0
        override public void writeToFile(StreamWriter fp)
        {
            if (fp == null)
            {
                return;
            }
            fp.WriteLine("\t\t\t" + ConUtils.getConLineString(ConUtils.CON_FEEDBACK_START) + " COM_SupportCenterFeedback");

            fp.WriteLine("Not yet implemented...");

            fp.WriteLine("\t\t\t" + ConUtils.getConLineString(ConUtils.CON_FEEDBACK_END));
        }
Esempio n. 3
0
        /**
         *      This method loads all the pertinent information regarding the simbicon controller from a file.
         */
        public void loadFromFile(string data)
        {
            if (data == null)
            {
                return;
            }
            //throwError("NULL file name provided.");
            StringReader f = new StringReader(data);

            if (f == null)
            {
                return;
            }
            //throwError("Could not open file: %s", data);

            //UnityThreadHelper.CreateThread(()=>
            //{
            //to be able to load multiple controllers from multiple files,
            //we will use this offset to make sure that the state numbers
            //mentioned in each input file are updated correctly
            int           stateOffset = this.states.Count;
            SimBiConState tempState;
            int           tempStateNr = -1;

            //have a temporary buffer used to read the file line by line...
            string buffer = f.ReadLine();

            while (buffer != null)
            {
                if (buffer.Length > 195)
                {
                    break;
                }

                string   line     = buffer.Trim();
                int      lineType = ConUtils.getConLineType(line);
                string[] nrParams = line.Split(new char[] { ' ' }, System.StringSplitOptions.RemoveEmptyEntries);
                switch (lineType)
                {
                case ConUtils.CON_STATE_START:
                    tempState   = new SimBiConState();
                    tempStateNr = int.Parse(nrParams[1]);
                    states.Add(tempState);
                    tempState.readState(f, stateOffset);
                    //now we have to resolve all the joint names (i.e. figure out which joints they apply to).
                    resolveJoints(tempState);
                    //UnityThreadHelper.Dispatcher.Dispatch(() => onDataLoadProcess(tempStateNr + 1));
                    break;

                case ConUtils.CON_NOT_IMPORTANT:
                    break;

                default:
                    break;
                }
                buffer = f.ReadLine();
            }
            f.Close();

            onDataLoadFinished(states.Count);
            //UnityThreadHelper.Dispatcher.Dispatch(() => onDataLoadFinished(states.Count));
            //});
        }
Esempio n. 4
0
        override public void loadFromFile(StringReader fp)
        {
            if (fp == null)
            {
                return;
            }
            //throwError("File pointer is NULL - cannot read gain coefficients!!");

            //have a temporary buffer used to read the file line by line...
            string buffer = fp.ReadLine();

            //this is where it happens.
            while (buffer != null)
            {
                //get a line from the file...
                if (buffer.Length > 195)
                {
                    break;
                }
                //throwError("The input file contains a line that is longer than ~200 characters - not allowed");
                string   line     = buffer.Trim();
                int      lineType = ConUtils.getConLineType(line);
                string[] nrParams = line.Split(new char[] { ' ' }, System.StringSplitOptions.RemoveEmptyEntries);
                switch (lineType)
                {
                case ConUtils.CON_FEEDBACK_END:
                    //we're done...
                    return;

                case ConUtils.CON_COMMENT:
                    break;

                case ConUtils.CON_D_MIN:
                    this.dMin = float.Parse(nrParams[1]);
                    break;

                case ConUtils.CON_D_MAX:
                    this.dMax = float.Parse(nrParams[1]);
                    break;

                case ConUtils.CON_V_MIN:
                    this.vMin = float.Parse(nrParams[1]);
                    break;

                case ConUtils.CON_V_MAX:
                    this.vMax = float.Parse(nrParams[1]);
                    break;

                case ConUtils.CON_CV:
                    this.cv = float.Parse(nrParams[1]);
                    break;

                case ConUtils.CON_CD:
                    this.cd = float.Parse(nrParams[1]);
                    break;

                case ConUtils.CON_MIN_FEEDBACK:
                    this.minFeedbackValue = float.Parse(nrParams[1]);
                    break;

                case ConUtils.CON_MAX_FEEDBACK:
                    this.maxFeedbackValue = float.Parse(nrParams[1]);
                    break;

                case ConUtils.CON_FEEDBACK_PROJECTION_AXIS:
                    feedbackProjectionAxis = new Vector3(float.Parse(nrParams[1]), float.Parse(nrParams[2]), float.Parse(nrParams[3]));
                    feedbackProjectionAxis.Normalize();
                    break;

                case ConUtils.CON_NOT_IMPORTANT:
                    break;

                default:
                    break;
                    //throwError("Incorrect SIMBICON input file: \'%s\' - unexpected line.", buffer);
                }
                buffer = fp.ReadLine();
            }
            //throwError("Incorrect SIMBICON input file: No \'/jointTrajectory\' found ", buffer);
        }