public GpsReader(CommunicationTask cTask, CancellationToken ct, int si) : base("GpsReader", cTask, ct, si) { FixType = GpsFixTypes.None; Altitude = null; Start(); }
public AnalogSensor(CommunicationTask cTask, CancellationToken ct, int si, AnalogPinId p, int vct) : base("AnalogSensor", cTask, ct, si) { pin = p; valueChangedThreshold = vct; Start(); }
public DifferentialMotorController(CommunicationTask cTask, CancellationToken ct, int si) : base("DifferentialMotorController", cTask, ct, si) { Start(); }
public int Yaw { get; set; } // -180..+180 public MotionPlug(CommunicationTask cTask, CancellationToken ct, int si) : base("MotionPlug", cTask, ct, si) { Start(); }
public OdometryReader(CommunicationTask cTask, CancellationToken ct, int si) : base("OdometryReader", cTask, ct, si) { Start(); }
public void CommandEventHandler(object sender, CommunicationTask.CommandEventArgs e) { byte[] decodedBinaryCode; if (e.CommandString.StartsWith(mWriteWIFIAddressCmdCode[0].ToString("x2"), StringComparison.InvariantCultureIgnoreCase)) { decodedBinaryCode = ASCIIRepresentor.String2ByteArray(e.CommandString); } else { decodedBinaryCode = null; } //binary process if (decodedBinaryCode != null && decodedBinaryCode[0] == mWriteWIFIAddressCmdCode[0]) { bool isWriteWIFIAddressCmd = true; for (int i = 0; i < mWriteWIFIAddressCmdCode.Length; i++) { if (decodedBinaryCode[i] != mWriteWIFIAddressCmdCode[i]) { isWriteWIFIAddressCmd = false; break; } } bool isReadWIFIAddressCmd = true; for (int i = 0; i < mReadWIFIAddressCmdCode.Length; i++) { if (decodedBinaryCode[i] != mReadWIFIAddressCmdCode[i]) { isReadWIFIAddressCmd = false; break; } } if (!isWriteWIFIAddressCmd && !isReadWIFIAddressCmd) { //no, I'm not interesting with the command return; } if (isWriteWIFIAddressCmd) { byte[] wifiAddress = new byte[mWIFIAddressLength]; Array.Copy(decodedBinaryCode, mWriteWIFIAddressCmdCode.Length, wifiAddress, 0, mWIFIAddressLength); string commandString = string.Format("write wifi address {0};", ASCIIRepresentor.ASCIIByteArray2String(wifiAddress)); e.CommandString = commandString; CommandEventHandler(sender, e); e.CommandResult = new byte[mWriteWIFIAddressCmdCode.Length + 1]; //command.Result[0] = Convert.ToByte(mWriteBTAddressResponseFormat[0, 2]); Array.Copy(mWriteWIFIAddressCmdCode, 0, e.CommandResult, 1, mWriteWIFIAddressCmdCode.Length); e.CommandResult[mWriteWIFIAddressCmdCode.Length] = 0x00; } else if(isReadWIFIAddressCmd) { e.CommandString="read wifi address;"; CommandEventHandler(sender,e); byte[] tempResult=new byte[12]; Array.Copy(mReadWIFIAddressCmdCode, 0, tempResult, 0, mReadWIFIAddressCmdCode.Length); if (e.CommandResult != null) { tempResult[mReadWIFIAddressCmdCode.Length] = 0x00; Array.Copy(e.CommandResult, 0, tempResult, mReadWIFIAddressCmdCode.Length + 1, mWIFIAddressLength); } else { tempResult[mReadWIFIAddressCmdCode.Length] = 0x01; Array.Clear(tempResult, mReadWIFIAddressCmdCode.Length + 1, mWIFIAddressLength); } e.CommandResult = tempResult; } } //literals process else if(mInterestedPattern.IsMatch(e.CommandString)) { //I'm interesting now, pass me the code bool isWriteWIFICmd = mWriteWIFIAddressPattern.IsMatch(e.CommandString); bool isReadWIFICmd = mReadWIFIAddressPattern.IsMatch(e.CommandString); if (isWriteWIFICmd) { Match match = mWriteWIFIAddressPattern.Match(e.CommandString); if (mExecuter == null) { mExecuter = ResolveExecuter(match.Groups[1].Value); } mExecuter.Write(match.Groups[2].Value); } else if (isReadWIFICmd) { Match match=mReadWIFIAddressPattern.Match(e.CommandString); if(mExecuter==null) { mExecuter=ResolveExecuter(match.Groups[1].Value); } var result=mExecuter.Read(null); e.CommandResult=result as byte[]; } } }
private void Initialize() { commTask = new CommunicationTask(this); }
public ParkingSonar(CommunicationTask cTask, CancellationToken ct, int uf) : base("ParkingSonar", cTask, ct, uf) { Start(); }
} // -180..+180 public MotionPlug(CommunicationTask cTask, CancellationToken ct, int si) : base("MotionPlug", cTask, ct, si) { Start(); }