public static ForceProviderCalibration FromFile(string calibrationFilePath)
        {
            if (!File.Exists(calibrationFilePath))
            {
                throw new FileNotFoundException("File not found:" + calibrationFilePath);
            }

            ForceProviderCalibration calibration = new ForceProviderCalibration();

            var xdocument = XDocument.Load(calibrationFilePath);

            ParseSettings(calibration, xdocument);

            return(calibration);
        }
        public static void ParseSettings(ForceProviderCalibration calibration, XDocument xdocument)
        {
            //--read individual configurations
            var curveNode  = xdocument.Descendants(CurveElement).First();
            var tareNode   = xdocument.Descendants(TareElement).First();
            var originNode = xdocument.Descendants(OriginElement).First();

            //--get sensor values
            var topLeftNode     = curveNode.Descendants(TLElement).First();
            var topRightNode    = curveNode.Descendants(TRElement).First();
            var bottomLeftNode  = curveNode.Descendants(BLElement).First();
            var bottomRightNode = curveNode.Descendants(BRElement).First();

            calibration.TL = ProcessSensorCalibration(topLeftNode);
            calibration.TR = ProcessSensorCalibration(topRightNode);
            calibration.BL = ProcessSensorCalibration(bottomLeftNode);
            calibration.BR = ProcessSensorCalibration(bottomRightNode);

            calibration.Origin = ProcessOrigin(originNode);

            calibration.Tare = Double.Parse(tareNode.Attributes(WeightAttribute).First().Value.ToString());
        }
Example #3
0
 public bool Calibrate(string calibrationFilePath)
 {
     this.Calibration = ForceProviderCalibration.FromFile(calibrationFilePath);
     return(true);
 }
Example #4
0
 public ForceProvider()
 {
     observers        = new List <IObserver <IForceFrame> >();
     this.Calibration = ForceProviderCalibration.Default();
 }