//-------------------------------------------------------------------------- // Inventory //-------------------------------------------------------------------------- partial void inventorySwitch_ValueChanged(UISwitch sender) { if (inventorySwitch.On) { selectedTag = null; UgiRfidConfiguration config = UgiRfidConfiguration.ConfigWithInventoryType(inventoryType); Ugi.Singleton().StartInventory(this, config); batteryButton.Enabled = false; configureButton.Enabled = false; commissionButton.Hidden = false; readButton.Hidden = false; writeButton.Hidden = false; commissionButton.Enabled = false; readButton.Enabled = false; writeButton.Enabled = false; tableView.ReloadData(); } else { Ugi.Singleton().ActiveInventory.StopInventory(() => { batteryButton.Enabled = true; configureButton.Enabled = true; commissionButton.Hidden = true; readButton.Hidden = true; writeButton.Hidden = true; }); } }
partial void writeButton_TouchUpInside(UIButton sender) { Ugi.Singleton().ActiveInventory.ReadTag(this.selectedTag.Epc, UgiRfidConfiguration.MemoryBank.User, READ_WRITE_OFFSET, READ_WRITE_MIN_BYTES, READ_WRITE_MAX_BYTES, (UgiTag tag, byte[] data, UgiInventory.TagAccessReturnValues result) => { if (result == UgiInventory.TagAccessReturnValues.Ok) { byte[] newData = new byte[data.Length]; for (int i = 0; i < data.Length; i++) { newData [i] = (byte)(data [i] + 0x11); } Ugi.Singleton().ActiveInventory.WriteTag(this.selectedTag.Epc, UgiRfidConfiguration.MemoryBank.User, READ_WRITE_OFFSET, newData, data, UgiInventory.NO_PASSWORD, (UgiTag tag2, UgiInventory.TagAccessReturnValues result2) => { if (result2 == UgiInventory.TagAccessReturnValues.Ok) { ShowOkCancel("write", "Success, data = " + BitConverter.ToString(newData).Replace("-", ""), "", null, null, null); } else { ShowOkCancel("write", "Failure: " + result2, "", null, null, null); } }); } else { ShowOkCancel("write", "Failure reading: " + result, "", null, null, null); } }); }
public void doBattery(View v) { Ugi.BatteryInfo info = Ugi.Singleton().GetBatteryInfo(); String message; if (info != null) { if (info.ExternalPowerIsConnected) { if (info.IsCharging) { message = @"Charging"; } else { message = @"Fully Charged"; } } else { message = info.PercentRemaining + "%"; } } else { message = "Can't read battery level"; } ShowOkCancel("Battery Level", message, "", null, null, null); }
partial void batteryButton_TouchUpInside(UIButton sender) { Ugi.BatteryInfo info = Ugi.Singleton().GetBatteryInfo(); String message; if (info != null) { if (info.ExternalPowerIsConnected) { if (info.IsCharging) { message = @"Charging"; } else { message = @"Fully Charged"; } } else { message = info.PercentRemaining + "%"; } } else { message = "Can't read battery level"; } ShowOkCancel("Battery Level", message, "", null, null, null); }
public override void OnCreate() { base.OnCreate(); Ugi.CreateSingleton(this); //Ugi.Singleton().LoggingStatus = Ugi.LoggingTypes.State | Ugi.LoggingTypes.Inventory; Ugi.Singleton().OpenConnection(); }
//-------------------------------------------------------------------------- // Inventory //-------------------------------------------------------------------------- void doStartStopInventory(object sender, EventArgs e) { ToggleButton tb = FindViewById <ToggleButton> (Resource.Id.inventoryToggleButton); if (tb.Checked) { UgiRfidConfiguration config = UgiRfidConfiguration.ConfigWithInventoryType(inventoryType); Ugi.Singleton().StartInventory(this, config); this.selectedTag = null; FindViewById <Button> (Resource.Id.batteryButton).Enabled = false; FindViewById <Button> (Resource.Id.configureButton).Enabled = false; FindViewById <Button> (Resource.Id.audioReconfigureButton).Enabled = false; FindViewById <View>(Resource.Id.line4).Visibility = ViewStates.Visible; FindViewById <Button> (Resource.Id.commissionButton).Enabled = false; FindViewById <Button> (Resource.Id.readTagButton).Enabled = false; FindViewById <Button> (Resource.Id.writeTagButton).Enabled = false; UpdateTable(); } else { Ugi.Singleton().ActiveInventory.StopInventory(() => { FindViewById <View>(Resource.Id.line4).Visibility = ViewStates.Invisible; FindViewById <Button> (Resource.Id.batteryButton).Enabled = true; FindViewById <View>(Resource.Id.configureButton).Enabled = true; FindViewById <View>(Resource.Id.audioReconfigureButton).Enabled = true; }); } }
//-------------------------------------------------------------------------- // Connection state //-------------------------------------------------------------------------- void ConnectionStateHandler(Ugi.ConnectionStates state) { if (Ugi.Singleton().IsConnected) { FindViewById <Button> (Resource.Id.batteryButton).Visibility = ViewStates.Visible; FindViewById <Button> (Resource.Id.configureButton).Visibility = ViewStates.Visible; FindViewById <Button> (Resource.Id.audioReconfigureButton).Visibility = ViewStates.Visible; FindViewById <TextView> (Resource.Id.disconnectedTextView).Visibility = ViewStates.Invisible; } else { FindViewById <Button> (Resource.Id.batteryButton).Visibility = ViewStates.Invisible; FindViewById <Button> (Resource.Id.configureButton).Visibility = ViewStates.Invisible; FindViewById <Button> (Resource.Id.audioReconfigureButton).Visibility = ViewStates.Invisible; FindViewById <TextView> (Resource.Id.disconnectedTextView).Visibility = ViewStates.Visible; TextView tv = FindViewById <TextView> (Resource.Id.disconnectedTextView); if (Ugi.Singleton().ConnectionState == Ugi.ConnectionStates.NotConnected) { tv.Text = "Not Connected"; } else { tv.Text = "Connecting"; } } }
public void doInfo(View v) { String message = "SDK " + Ugi.Singleton().SdkVersionMajor + "." + Ugi.Singleton().SdkVersionMinor + "." + Ugi.Singleton().SdkVersionBuild + "\n" + Ugi.Singleton().SdkVersionDateTime + "\n" + Ugi.Singleton().ReaderDescription; ShowOkCancel("Info", message, "", null, null, null); }
public override void ViewDidLoad() { base.ViewDidLoad(); tableView.DataSource = this; tableView.Delegate = this; commissionButton.Hidden = true; readButton.Hidden = true; writeButton.Hidden = true; ConnectionStateHandler(Ugi.ConnectionStates.NotConnected); Ugi.Singleton().ConnectionStateChanged += ConnectionStateHandler; }
public void RowSelected(UITableView tableView, NSIndexPath indexPath) { List <UgiTag> tags = Ugi.Singleton().ActiveInventory.Tags; if (indexPath.Row < tags.Count) { selectedTag = tags [indexPath.Row]; commissionButton.Enabled = true; readButton.Enabled = true; writeButton.Enabled = true; } }
//-------------------------------------------------------------------------- // Alerts //-------------------------------------------------------------------------- partial void InfoButton_TouchUpInside(UIButton sender) { String grokker = "Not Connected"; if (Ugi.Singleton().IsConnected) { grokker = Ugi.Singleton().ReaderDescription; } String message = "SDK " + Ugi.Singleton().SdkVersionMajor + "." + Ugi.Singleton().SdkVersionMinor + "." + Ugi.Singleton().SdkVersionBuild + "\n" + grokker; ShowOkCancel("Info", message, "", null, null, null); }
public void doInfo(View v) { String grokker = "Not Connected"; if (Ugi.Singleton().IsConnected) { grokker = Ugi.Singleton().ReaderDescription; } String message = "SDK " + Ugi.Singleton().SdkVersionMajor + "." + Ugi.Singleton().SdkVersionMinor + "." + Ugi.Singleton().SdkVersionBuild + "\n" + grokker; ShowOkCancel("Info", message, "", null, null, null); }
partial void readButton_TouchUpInside(UIButton sender) { Ugi.Singleton().ActiveInventory.ReadTag(this.selectedTag.Epc, UgiRfidConfiguration.MemoryBank.User, READ_WRITE_OFFSET, READ_WRITE_MIN_BYTES, READ_WRITE_MAX_BYTES, (UgiTag tag, byte[] data, UgiInventory.TagAccessReturnValues result) => { if (result == UgiInventory.TagAccessReturnValues.Ok) { ShowOkCancel("read", "Success, data = " + BitConverter.ToString(data).Replace("-", ""), "", null, null, null); } else { ShowOkCancel("read", "Failure: " + result, "", null, null, null); } }); }
override public View GetView(int position, View convertView, ViewGroup parent) { UgiInventory inventory = Ugi.Singleton().ActiveInventory; if (inventory == null) { return(convertView); } UgiRfidConfiguration config = inventory.Configuration; if (convertView == null) { convertView = mainActivity.LayoutInflater.Inflate(config.ReportSubsequentFinds ? Resource.Layout.list_item : Resource.Layout.list_item_no_history, null); convertView.Click += (object sender, EventArgs e) => { // }; } ListView lv = mainActivity.FindViewById <ListView>(Resource.Id.tagList); if (lv.CheckedItemPositions.Get(position)) { convertView.SetBackgroundColor(Color.ParseColor("#888888")); } else { convertView.SetBackgroundColor(Color.ParseColor("#222222")); } TextView tv = convertView.FindViewById <TextView>(Resource.Id.listItemText); tv.Text = "Item " + position; List <UgiTag> tags = Ugi.Singleton().ActiveInventory.Tags; if (position < tags.Count) { UgiTag tag = tags[position]; tv.Text = tag.Epc.ToString(); if (config.ReportSubsequentFinds) { tv = convertView.FindViewById <TextView>(Resource.Id.listItemDetail); tv.Text = tag.ReadState.ReadHistoryString; } } return(convertView); }
public void doLocateTag(View v) { // // This is a demonstration of how to optimize locating a single tag // in a tagdense environment by passing the EPC as the select mask. // UgiEpc epc = this.selectedTag.Epc; Ugi.Singleton().ActiveInventory.StopInventory(() => { UgiRfidConfiguration config = UgiRfidConfiguration.ConfigWithInventoryType(inventoryType); config.SelectMask = epc.Bytes; config.SelectMaskBitLength = epc.Bytes.Length * 8; config.SelectOffset = 32; config.SelectBank = UgiRfidConfiguration.MemoryBank.Epc; Ugi.Singleton().StartInventory(this, config, epc); }); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Ugi.Singleton().ActivityOnCreate(this, true); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); ListView tagListView = FindViewById <ListView>(Resource.Id.tagList); listAdapter = new OurListAdapter(this); tagListView.Adapter = listAdapter; tagListView.ItemClick += tagListView_ItemClick; ToggleButton tv = FindViewById <ToggleButton> (Resource.Id.inventoryToggleButton); tv.Click += doStartStopInventory; ConnectionStateHandler(Ugi.ConnectionStates.NotConnected); Ugi.Singleton().ConnectionStateChanged += ConnectionStateHandler; }
partial void commissionButton_TouchUpInside(UIButton sender) { byte[] b = this.selectedTag.Epc.Bytes; for (int i = 0; i < b.Length; i++) { b [i] = (byte)(b [i] + 0x11); } UgiEpc newEpc = UgiEpc.FromBytes(b); Ugi.Singleton().ActiveInventory.ProgramTag(this.selectedTag.Epc, newEpc, UgiInventory.NO_PASSWORD, (UgiTag tag, UgiInventory.TagAccessReturnValues result) => { if (result == UgiInventory.TagAccessReturnValues.Ok) { ShowOkCancel("commission", "Success, new Epc = " + newEpc, "", null, null, null); } else { ShowOkCancel("commission", "Failure: " + result, "", null, null, null); } }); }
public UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { UgiInventory inventory = Ugi.Singleton().ActiveInventory; if (inventory == null) { UITableViewCell cell = tableView.DequeueReusableCell("InventoryCell"); if (cell == null) { cell = new UITableViewCell(UITableViewCellStyle.Default, "InventoryCell"); } return(cell); } else { UgiRfidConfiguration config = inventory.Configuration; string cellIdentifier = config.ReportSubsequentFinds ? "LocateCell" : "InventoryCell"; UITableViewCell cell = tableView.DequeueReusableCell(cellIdentifier); if (cell == null) { cell = new UITableViewCell(UITableViewCellStyle.Default, cellIdentifier); } List <UgiTag> tags = Ugi.Singleton().ActiveInventory.Tags; if (indexPath.Row < tags.Count) { UgiTag tag = tags [indexPath.Row]; cell.TextLabel.Text = tag.Epc.ToString(); if (config.ReportSubsequentFinds) { cell.DetailTextLabel.Text = tag.ReadState.ReadHistoryString; } } else { cell.TextLabel.Text = "Item #" + indexPath.Row; } return(cell); } }
//-------------------------------------------------------------------------- // Connection state //-------------------------------------------------------------------------- void ConnectionStateHandler(Ugi.ConnectionStates state) { if (Ugi.Singleton().IsConnected) { batteryButton.Hidden = false; configureButton.Hidden = false; connectionStateLabel.Hidden = true; } else { batteryButton.Hidden = true; configureButton.Hidden = true; connectionStateLabel.Hidden = false; if (Ugi.Singleton().ConnectionState == Ugi.ConnectionStates.NotConnected) { connectionStateLabel.Text = "Not Connected"; } else { connectionStateLabel.Text = "Connecting"; } } }
// This method is called when the application is about to terminate. Save data, if needed. public override void WillTerminate(UIApplication application) { Ugi.Singleton().CloseConnection(); }
// class-level declarations public AppDelegate() : base() { Ugi.CreateSingleton(); //Ugi.Singleton().LoggingStatus = Ugi.LoggingTypes.State | Ugi.LoggingTypes.Inventory; Ugi.Singleton().OpenConnection(); }
public override UgiTag this[int position] { get { List <UgiTag> tags = Ugi.Singleton().ActiveInventory.Tags; return(position < tags.Count ? tags [position] : null); } }
public void doAudio(View v) { Ugi.Singleton().InvokeAudioReconfiguration(); }
public void doJack(View v) { Ugi.Singleton().InvokeAudioJackLocation(); }
protected override void OnDestroy() { base.OnDestroy(); Ugi.Singleton().ConnectionStateChanged -= ConnectionStateHandler; Ugi.Singleton().ActivityOnDestroy(this); }
protected override void OnPause() { base.OnDestroy(); Ugi.Singleton().ActivityOnPause(this); }
//-------------------------------------------------------------------------- // Table view //-------------------------------------------------------------------------- public nint RowsInSection(UITableView tableview, nint section) { UgiInventory inventory = Ugi.Singleton().ActiveInventory; return(inventory != null ? inventory.Tags.Count : 0); }