本文整理汇总了C#中SensorData类的典型用法代码示例。如果您正苦于以下问题:C# SensorData类的具体用法?C# SensorData怎么用?C# SensorData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SensorData类属于命名空间,在下文中一共展示了SensorData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAverageBySensor
private static double[] GetAverageBySensor(SensorData[] resultParse)
{
int counterFirstSensor = 0;
int counterSecondSensor = 0;
int counterThirdSensor = 0;
int sumFirstSensor = 0;
int sumSecondSensor = 0;
int sumThirdSensor = 0;
for (int i = 0; i < resultParse.Length; i++)
{
switch (resultParse[i].codeSensor)
{
case 1:
counterFirstSensor++;
sumFirstSensor += resultParse[i].valueSensor;
break;
case 2:
counterSecondSensor++;
sumSecondSensor += resultParse[i].valueSensor;
break;
case 3:
counterThirdSensor++;
sumThirdSensor += resultParse[i].valueSensor;
break;
default:
break;
}
}
double[] AverageBySensor = { (sumFirstSensor / counterFirstSensor), (sumSecondSensor / counterSecondSensor), (sumThirdSensor / counterThirdSensor) };
return AverageBySensor;
}
示例2: GetParse
private static SensorData[] GetParse(ushort[] dataSensors)
{
SensorData[] resultParse = new SensorData[dataSensors.Length];
uint firstMask = 0x1;
uint secondMask = 0x1FFE;
for (int i = 0; i < dataSensors.Length; i++)
{
int counter = 0;
int dataResult = dataSensors[i];
while (dataResult > 0)
{
dataResult = dataResult >> 1;
counter++;
}
int amountOfBits = counter - 1;
int cod = dataSensors[i] >> 13;
uint controlBit = dataSensors[i] & firstMask;
uint val = (dataSensors[i] & secondMask) >> 1;
if ((amountOfBits % 2 == 0 && controlBit == 0) || (amountOfBits % 2 != 0 && controlBit == 1))
{
resultParse[i] = new SensorData(Convert.ToUInt16(cod), Convert.ToUInt16(val), Convert.ToUInt16(controlBit));
}
else
{
Console.WriteLine("Данные {0} со счетчика {1} повреждены", dataSensors[i], cod);
}
}
return resultParse;
}
示例3: SensorClientData
public SensorClientData(SensorInfo ci, SensorData sd)
{
this.SensorId = ci.SensorId.ToString();
this.Lat = ci.Lat;
this.Lng = ci.Lng;
this.Name = ci.Name;
this.Organization = ci.Organization;
this.Humidity = sd.Humidity;
this.Temperature = sd.Temperature;
}
示例4: getMessage
private void getMessage()
{
while (true) {
NetworkStream stream = _clientSocket.GetStream ();
BinaryFormatter formatter = new BinaryFormatter ();
object obj = formatter.Deserialize (stream);
SensorData data = (SensorData)obj;
//Console.WriteLine (data.BottomLeft + " - " + data.BottomoRight + " - " + data.TopLeft + " - " + data.TopRight);
_data = (SensorData)obj;
}
}
示例5: SquaredDistanceFrom
public override double SquaredDistanceFrom(SensorData other)
{
other.GetType();
var otherSensor = other as WlanSensorData;
if (!BusinessEquals(otherSensor, false))
return 1d;
Debug.Assert(otherSensor != null, "otherSensor != null");
return Math.Pow(SignalStrength - otherSensor.SignalStrength, 2);
}
示例6: UpdateUI
private void UpdateUI(SensorData.Vector reading)
{
ScenarioOutput_X.Text = String.Format("{0,5:0.00}", reading.X);
ScenarioOutput_Y.Text = String.Format("{0,5:0.00}", reading.Y);
ScenarioOutput_Z.Text = String.Format("{0,5:0.00}", reading.Z);
// Show the values graphically
xLine.X2 = xLine.X1 + reading.X * 100;
yLine.Y2 = yLine.Y1 - reading.Y * 100;
zLine.X2 = zLine.X1 - reading.Z * 50;
zLine.Y2 = zLine.Y1 + reading.Z * 50;
}
示例7: OnWeatherData
public async Task OnWeatherData(SensorData data)
{
if (this.SensorInfo == null) return;
var o = new SensorClientData(this.SensorInfo, data);
//Tell monitors about the new data (not the sensors)
await this.InvokeTo<Monitor>(p => p.ClientType == ClientType.Monitor && p.TempThreshold < o.Temperature, o, "wd");
await this.ScaleOut(o, "swd");
//Store data on Azure Storage
await this.StorageSet(o.SensorId, o);
}
示例8: UpdateUI
private void UpdateUI(SensorData.Vector reading)
{
statusTextBlock.Text = "Receiving data from accelerometer...";
// Show the numeric values
xTextBlock.Text = "X: " + reading.X.ToString("0.00");
yTextBlock.Text = "Y: " + reading.Y.ToString("0.00");
zTextBlock.Text = "Z: " + reading.Z.ToString("0.00");
// Show the values graphically
xLine.X2 = xLine.X1 + reading.X * 100;
yLine.Y2 = yLine.Y1 - reading.Y * 100;
zLine.X2 = zLine.X1 - reading.Z * 50;
zLine.Y2 = zLine.Y1 + reading.Z * 50;
}
示例9: test
/// <summary>
/// Tests for the lineparser format. Additionally it looks for the header row and
/// trys to determine the third value seperated by semicolom.
/// </summary>
/// <param name="line">The line to parse</param>
/// <returns>True is successful</returns>
/// <exception cref="LineparserException">If no linematcher is set</exception>
public override bool test(string line)
{
// Is header line?
if (line.IndexOf("Date;Time;") != -1)
{
// Split header line by semicolom.
String[] splits = line.Split(';');
if (splits.Length != 3)
{
return false;
}
// set additional value
SensorData tValue = (SensorData)Enum.Parse(typeof(SensorData), splits[splits.Length - 1]);
this.extraValue = tValue;
// set supported values
SensorData[] t = { SensorData.Date, tValue };
this.SupportedValues = t;
}
// run the actual test
return base.test(line);
}
示例10: GetForegroundAlphaFrame
private static bool GetForegroundAlphaFrame(SensorData sensorData, bool bLimitedUsers, ICollection<int> alTrackedIndexes, ref byte[] fgAlphaFrame)
{
if (sensorData == null || sensorData.bodyIndexImage == null)
return false;
CvMat cvAlphaMap = new CvMat(sensorData.depthImageHeight, sensorData.depthImageWidth, MatrixType.U8C1);
System.IntPtr rawPtrAlpha;
cvAlphaMap.GetRawData(out rawPtrAlpha);
if (sensorData.selectedBodyIndex != 255 || bLimitedUsers)
{
// copy body-index selectively
byte btSelBI = sensorData.selectedBodyIndex;
int iBodyIndexLength = sensorData.bodyIndexImage.Length;
for (int i = 0; i < iBodyIndexLength; i++)
{
byte btBufBI = sensorData.bodyIndexImage[i];
bool bUserTracked = btSelBI != 255 ? btSelBI == btBufBI :
(btBufBI != 255 ? alTrackedIndexes.Contains((int)btBufBI) : false);
if (bUserTracked)
{
cvAlphaMap.Set1D(i, btBufBI);
}
else
{
cvAlphaMap.Set1D(i, 255);
}
}
}
else
{
// copy the entire body-index buffer
Marshal.Copy(sensorData.bodyIndexImage, 0, rawPtrAlpha, sensorData.bodyIndexImage.Length);
}
// make the image b&w
cvAlphaMap.Threshold(cvAlphaMap, 254, 255, ThresholdType.BinaryInv);
// apply erode, dilate and blur
cvAlphaMap.Erode(cvAlphaMap);
cvAlphaMap.Dilate(cvAlphaMap);
cvAlphaMap.Smooth(cvAlphaMap, SmoothType.Blur, 5, 5);
//cvAlphaMap.Smooth(cvAlphaMap, SmoothType.Median, 7);
// get the foreground image
Marshal.Copy(rawPtrAlpha, fgAlphaFrame, 0, fgAlphaFrame.Length);
return true;
}
示例11: CloseSensor
// closes opened readers and closes the sensor
public static void CloseSensor(SensorData sensorData)
{
if (sensorData != null && sensorData.sensorInterface != null)
{
sensorData.sensorInterface.CloseSensor(sensorData);
}
if (sensorData.bodyIndexBuffer != null)
{
sensorData.bodyIndexBuffer.Release();
sensorData.bodyIndexBuffer = null;
}
if (sensorData.depthImageBuffer != null)
{
sensorData.depthImageBuffer.Release();
sensorData.depthImageBuffer = null;
}
if (sensorData.depthHistBuffer != null)
{
sensorData.depthHistBuffer.Release();
sensorData.depthHistBuffer = null;
}
if (sensorData.depth2ColorBuffer != null)
{
sensorData.depth2ColorBuffer.Release();
sensorData.depth2ColorBuffer = null;
}
}
示例12: MapDepthFrameToColorCoords
// estimates color-map coordinates for the current depth frame
public static bool MapDepthFrameToColorCoords(SensorData sensorData, ref Vector2[] vColorCoords)
{
bool bResult = false;
if(sensorData.sensorInterface != null)
{
bResult = sensorData.sensorInterface.MapDepthFrameToColorCoords(sensorData, ref vColorCoords);
}
return bResult;
}
示例13: MapDepthPointToColorCoords
// returns color-map coordinates for the given depth point
public static Vector2 MapDepthPointToColorCoords(SensorData sensorData, Vector2 depthPos, ushort depthVal)
{
Vector2 vPoint = Vector2.zero;
if(sensorData.sensorInterface != null)
{
vPoint = sensorData.sensorInterface.MapDepthPointToColorCoords(sensorData, depthPos, depthVal);
}
return vPoint;
}
示例14: GetForegroundFrameRect
// returns the foregound frame rectangle, as to the required resolution
public static Rect GetForegroundFrameRect(SensorData sensorData, bool isHiResPrefered)
{
if (isHiResPrefered && sensorData != null && sensorData.sensorInterface != null)
{
if (sensorData.sensorInterface.IsBRHiResSupported() && sensorData.colorImage != null)
{
return new Rect(0f, 0f, sensorData.colorImageWidth, sensorData.colorImageHeight);
}
}
return sensorData != null ? new Rect(0f, 0f, sensorData.depthImageWidth, sensorData.depthImageHeight) : new Rect();
}
示例15: OnMeasurementCompleteEvent
// public static EventHandler<SensorData> MeasurementComplete;
/// <summary>
/// Raises the <see cref="MeasurementComplete"/> event.
/// </summary>
/// <param name="sender">The object that raised the event.</param>
/// <param name="sensorData">The <see cref="SensorData"/> object that contains the results of the measurement.</param>
public void OnMeasurementCompleteEvent(Magnetometer sender, SensorData sensorData)
{
if (_OnMeasurementComplete == null)
_OnMeasurementComplete = OnMeasurementCompleteEvent;
}