ReaderLibrary.MyTag.GetAccel C# (CSharp) Method

GetAccel() public method

public GetAccel ( string channel ) : double
channel string
return double
        public double GetAccel(string channel)
        {
            channel = channel.ToLower();

            double value = GetRawAccel(channel);

            // check data
            if (value < 0 || value > 4096) value = 0;

            // Scale 0 to 100 %
            value = 100.0 * value / 4096.0;

            // flip x,y by default
            if (channel == "x" || channel == "y") value = 100 - value;

            // WISP ID: "0D" and "0B" use different sampling methods
            // 0D lets the accel settle fully
            // 0B uses partial settling - the value is slighly higher than reported value.
            //    z channel of adxl330 has different resistance - that's why its scalar is different.
            string id = epcID.ToString().Substring(0, 2);
            if (id.ToLower() == "0b")
            {
                if (channel == "x") value = value * MyTag.quickAccelCorrectionX;
                if (channel == "y") value = value * MyTag.quickAccelCorrectionY;
                if (channel == "z") value = value * MyTag.quickAccelCorrectionZ;
            }

            return value;
        }

Usage Example

Example #1
0
        private string WriteSensorData(MyTag tag)
        {
            string temp = "";
            switch (tag.GetTagType())
            {
                case TagType.WISP_ACCELEROMETER:
                    temp = temp + "";
                    temp = temp + tag.GetAccel("x");

                    temp = temp + "\t";
                    temp = temp + tag.GetAccel("y");

                    temp = temp + "\t";
                    temp = temp + tag.GetAccel("z");

                    break;
                case TagType.WISP_TEMPERATURE:

                    temp = temp + "Temp= ";
                    temp = temp + tag.GetTemperature();

                    break;
                case TagType.WISP_SOC:
                    if (tag.GetAccessResultData().Length > 0)
                    {
                        int[] data = tag.GetSOCData();
                        for (int i = 0; i < data.Length; i++)
                        {
                            temp = temp + "ADC,";
                            temp = temp + data[i] + ",";

                            temp = temp + "temp,";
                            temp = temp + tag.socFilteredTemperature + ",";
                        }
                    }

                    break;
                default:
                    // no action for now...
                    // this could be commercial tags, etc.
                    break;
            }
            return temp;
        }
All Usage Examples Of ReaderLibrary.MyTag::GetAccel