Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
6adae82
Merge pull request #27 from Z-bit-Systems-LLC/main
bytedreamer Apr 7, 2025
c48974a
Add comprehensive unit tests for DeviceManagementService
bytedreamer Apr 19, 2025
383bdb5
Update refactoring opportunities in CLAUDE.md
bytedreamer Apr 19, 2025
5f44ccc
Merge pull request #28 from Z-bit-Systems-LLC/feature/device-manageme…
bytedreamer Apr 19, 2025
2af7a88
Cleanup code
bytedreamer Apr 19, 2025
ec3c164
Refactor ConnectViewModel for improved maintainability
bytedreamer Apr 19, 2025
4fc2026
Update CLAUDE.md to mark completed ConnectViewModel refactoring
bytedreamer Apr 19, 2025
02f15d2
Merge pull request #29 from Z-bit-Systems-LLC/feature/refactor-connec…
bytedreamer Apr 19, 2025
2d4b794
Cleanup code inspection warnings
bytedreamer Apr 19, 2025
603642d
Refactor ManageViewModel ExecuteDeviceAction method
bytedreamer Apr 19, 2025
93ed5ed
Update CLAUDE.md to mark ManageViewModel refactoring as completed
bytedreamer Apr 19, 2025
074a31d
Add OSDP.Net source code reference to CLAUDE.md
bytedreamer Apr 19, 2025
cc86a90
Improve ManageViewModel test coverage for reset device action
bytedreamer Apr 19, 2025
f2353f1
Fix code inspection issues
bytedreamer Apr 19, 2025
fc8594c
Consolidate monitoring actions into a unified class
bytedreamer Apr 19, 2025
cf889d8
Merge pull request #30 from Z-bit-Systems-LLC/feature/consolidate-mon…
bytedreamer Apr 19, 2025
1aa018e
Fixed code inspection warnings
bytedreamer Apr 19, 2025
da8ea05
Improve test quality and coverage
bytedreamer Apr 19, 2025
8acb615
Merge pull request #31 from Z-bit-Systems-LLC/feature/test-improvements
bytedreamer Apr 19, 2025
eb6749b
Fix code inspection warnnings
bytedreamer Apr 20, 2025
168045f
Remove uneeded actions
bytedreamer Apr 20, 2025
3b32e23
Complete remaining refactoring opportunities
bytedreamer Apr 20, 2025
b3d61d4
Merge pull request #32 from Z-bit-Systems-LLC/feature/complete-refact…
bytedreamer Apr 20, 2025
320c39a
Add release script for automating the release process
bytedreamer Apr 20, 2025
f51b62f
Add Monitor Page
bytedreamer May 16, 2025
d1884fc
Add action controls
bytedreamer May 17, 2025
77adc18
Fix vulnerbilities
bytedreamer May 18, 2025
3ba11a5
Default to Not Ready status when no USB Serial Port is detected
bytedreamer May 25, 2025
0a76f5e
Merge pull request #34 from Z-bit-Systems-LLC/my-local-changes
bytedreamer May 25, 2025
47c8130
Show connect info on Monitor page
bytedreamer May 27, 2025
c81edb4
Add reconnect logic
bytedreamer Jun 1, 2025
ce47ce1
Fix issues with changes from Maui UI updates
bytedreamer Jun 12, 2025
a95172e
Add disconnect button
bytedreamer Jun 19, 2025
352a9b2
Add USB automatic USB detection logic
bytedreamer Jun 20, 2025
7bd9562
Replace CardExpander
bytedreamer Jun 20, 2025
b1e77c4
Localization infrastructure setup
bytedreamer Jun 20, 2025
bf126ec
String extraction
bytedreamer Jun 20, 2025
707ff3a
Finish localization implementation
bytedreamer Jun 20, 2025
35e0979
Allow for selection of languages
bytedreamer Jun 20, 2025
53ca99d
Fix non-determinstic testing issues when initializing
bytedreamer Jun 21, 2025
bfb83f9
Add documentation
bytedreamer Jun 21, 2025
a93bb3b
Update Crowdin configuration file
bytedreamer Jun 22, 2025
ef9528a
Update Crowdin configuration file
bytedreamer Jun 22, 2025
5cc6bd9
New translations resources.resx (French)
bytedreamer Jun 22, 2025
3ddb66f
New translations resources.resx (Spanish)
bytedreamer Jun 22, 2025
6b94dfd
New translations resources.resx (Spanish)
bytedreamer Jun 22, 2025
ac140aa
Merge pull request #35 from Z-bit-Systems-LLC/l10n_develop
bytedreamer Jun 22, 2025
5fc6214
New translations resources.resx (French)
bytedreamer Jun 24, 2025
481cf81
New translations resources.resx (German)
bytedreamer Jun 24, 2025
6518592
New translations resources.resx (Japanese)
bytedreamer Jun 24, 2025
dca6881
New translations resources.resx (Chinese Simplified)
bytedreamer Jun 24, 2025
0f0b2ac
Minor fixups
bytedreamer Jun 24, 2025
8e98702
New translations resources.resx (Chinese Simplified)
bytedreamer Jun 24, 2025
77d3561
Merge pull request #36 from Z-bit-Systems-LLC/l10n_develop
bytedreamer Jun 27, 2025
4848cae
Fix translation related behavior issues
bytedreamer Jun 27, 2025
89cb8e0
Rest of changes
bytedreamer Jun 27, 2025
001e4d9
Add Monitor page translations
bytedreamer Jun 27, 2025
b01518d
Fixed up the selection behavior
bytedreamer Jun 27, 2025
1b67160
New translations resources.resx (French)
bytedreamer Jun 27, 2025
1dea3f8
New translations resources.resx (Spanish)
bytedreamer Jun 27, 2025
f1f3708
New translations resources.resx (German)
bytedreamer Jun 27, 2025
b5450cf
New translations resources.resx (Japanese)
bytedreamer Jun 27, 2025
74419aa
New translations resources.resx (Chinese Simplified)
bytedreamer Jun 27, 2025
fbc9e12
Update more pages to use localization
bytedreamer Jun 27, 2025
5264b42
A plan for migrating to a uniformed styling
bytedreamer Jun 27, 2025
ad658a8
New translations resources.resx (French)
bytedreamer Jun 27, 2025
91b9361
New translations resources.resx (Spanish)
bytedreamer Jun 27, 2025
1e1134e
New translations resources.resx (German)
bytedreamer Jun 27, 2025
b81d7c4
New translations resources.resx (Japanese)
bytedreamer Jun 27, 2025
16c17e8
New translations resources.resx (Chinese Simplified)
bytedreamer Jun 27, 2025
cb86181
Start moving to standard styling
bytedreamer Jun 28, 2025
c7fcf93
Fix styling for InfoPage
bytedreamer Jun 28, 2025
b066734
Update the MonitorPage styling
bytedreamer Jun 28, 2025
6f1c2fa
Update the ManagePage styling
bytedreamer Jun 28, 2025
6eeae72
Update the FileTransferControl to use style
bytedreamer Jun 28, 2025
31b67bc
More style updates for FileTransferControl.xaml
bytedreamer Jun 28, 2025
2c7426e
Update Style documentation
bytedreamer Jun 28, 2025
67f792c
Include UI style guidelines
bytedreamer Jun 28, 2025
5d00b84
Update the Connection Page UI layout
bytedreamer Jun 28, 2025
c34d76a
New translations resources.resx (French)
bytedreamer Jun 28, 2025
a602fcd
New translations resources.resx (Spanish)
bytedreamer Jun 28, 2025
0ee6b7e
New translations resources.resx (German)
bytedreamer Jun 28, 2025
7b01813
New translations resources.resx (Japanese)
bytedreamer Jun 28, 2025
667b529
New translations resources.resx (Chinese Simplified)
bytedreamer Jun 28, 2025
92f0da6
Fix activity blinking when connected as secure channel
bytedreamer Jun 28, 2025
3f0a2d2
Merge pull request #37 from Z-bit-Systems-LLC/l10n_develop
bytedreamer Jun 28, 2025
9589ccb
New translations resources.resx (French)
bytedreamer Jun 29, 2025
655d08d
New translations resources.resx (Spanish)
bytedreamer Jun 29, 2025
82493ec
New translations resources.resx (German)
bytedreamer Jun 29, 2025
7e0fa12
New translations resources.resx (Japanese)
bytedreamer Jun 29, 2025
c4022d2
New translations resources.resx (Chinese Simplified)
bytedreamer Jun 29, 2025
5a9399c
Merge pull request #39 from Z-bit-Systems-LLC/l10n_develop
bytedreamer Jun 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ _UpgradeReport_Files/
AppPackages/
BundleArtifacts/
/src/UI/WinUI (Package)/WinUI (Package).assets.cache

.claude
6 changes: 6 additions & 0 deletions OSDP-Bench.sln
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Windows", "src\UI\Windows\W
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core", "src\Core\Core.csproj", "{79C7EB0F-A75B-4DA7-BDDF-12C9714B48DF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docs", "Docs", "{ED2EC291-3353-442C-AD2C-3D3438798EF0}"
ProjectSection(SolutionItems) = preProject
README.md = README.md
docs\CLAUDE.md = docs\CLAUDE.md
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
99 changes: 94 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,97 @@
# OSDP Bench #
Tool for configuring and troubleshooting OSDP devices.
# OSDP Bench

Phyisical access to spaces is typically granted using readers and badges. The readers are usually low powered end point devices that depends on a control panel to determine if the card credential is authroized to gain access. The communication between the reader and control panel is done via the Open Supervised Device Protocol (OSDP). Current access control panels can lack good tools to manage their connected OSDP devices. The goal of this project is to fill this gap with the necessary tools needed for technicians who are working with OSDP.
A professional tool for configuring and troubleshooting OSDP devices.

Core functionality is under an open source license to help increase the adoption rate of OSDP. A fully functional OSDP Bench tool can be compiled under this license at no cost. We encourage OSDP hardware vendors to utilize this project to accelerate the development of thier own OSDP releated tools.
[![.NET](https://img.shields.io/badge/.NET-8.0-blue)](https://dotnet.microsoft.com/)
[![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](LICENSE)
[![Platform](https://img.shields.io/badge/Platform-Windows-lightgrey)](https://docs.microsoft.com/en-us/windows/)

Contact [Z-bit Systems, LLC](https://z-bitco.com) for inquires regarding this project.
## About

Physical access to spaces is typically granted using readers and badges. The readers are usually low-powered end point devices that depend on a control panel to determine if the card credential is authorized to gain access. The communication between the reader and control panel is done via the Open Supervised Device Protocol (OSDP). Current access control panels can lack good tools to manage their connected OSDP devices. The goal of this project is to fill this gap with the necessary tools needed for technicians who are working with OSDP.

Core functionality is under an open source license to help increase the adoption rate of OSDP. A fully functional OSDP Bench tool can be compiled under this license at no cost. We encourage OSDP hardware vendors to utilize this project to speed up the development of their own OSDP related tools.

## Features

- **Device Discovery** - Automatically discover OSDP devices on serial connections
- **Real-time Monitoring** - Monitor card reads, keypad entries, and device status
- **Device Configuration** - Configure LEDs, buzzers, and communication parameters
- **Packet Tracing** - View detailed OSDP communication packets
- **Multi-language Support** - Available in multiple languages
- **Cross-platform** - Built on .NET 8.0 for modern compatibility

## Getting Started

### Prerequisites

- .NET 8.0 SDK or later
- Windows 10/11 (for WinUI version)
- Serial port access for device communication

### Installation

1. Clone the repository:
```bash
git clone https://github.com/bytedreamer/OSDP-Bench.git
cd OSDP-Bench
```

2. Build the solution:
```bash
dotnet build OSDP-Bench.sln
```

3. Run the application:
```bash
dotnet run --project src/UI/Windows
```

### Quick Start

1. Launch OSDP Bench
2. Select your serial port from the dropdown
3. Choose "Discover" to automatically find devices or "Manual" to connect directly
4. Begin monitoring device activity or configure device settings

## Documentation

### Project Documentation
- **[Developer Guidelines](docs/CLAUDE.md)** - Development guidelines and build commands
- **[UI Style Guide](src/UI/Windows/Styles/StyleGuide.md)** - Comprehensive design system and styling guidelines

### Architecture Plans
- **[Connection Plugin Architecture](docs/CONNECTION_PLUGIN_ARCHITECTURE.md)** - Plan for implementing pluggable connection types (Serial, Bluetooth, Network)

### Localization
- **[Localization Plan](docs/LOCALIZATION_PLAN.md)** - Multi-language support implementation
- **[Language Switching](docs/LANGUAGE_SWITCHING_DEMO.md)** - Language switching functionality
- **[Language Fixes](docs/LANGUAGE_SWITCHING_FIX.md)** - Language switching issue fixes

## Contributing

We welcome contributions! Please follow these guidelines:

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

For documentation contributions:
1. Place new documentation in the `docs/` directory
2. Use descriptive filenames with `.md` extension
3. Update this README to include the new file
4. Follow the existing documentation style and structure

## License

This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.

## Contact

Contact [Z-bit Systems, LLC](https://z-bitco.com) for inquiries regarding this project.

## Related Projects

- [OSDP.Net](https://github.com/bytedreamer/OSDP.Net) - The core OSDP communication library
76 changes: 76 additions & 0 deletions ci/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/bin/bash

# OSDP-Bench Release Script
# Merges develop into main to trigger CI version bump and release

echo "OSDP-Bench Release Process"
echo "=========================="
echo ""

# Ensure we have latest changes
echo "Fetching latest changes..."
git fetch --all

# Check if there are uncommitted changes
if [[ -n $(git status -s) ]]; then
echo "Error: You have uncommitted changes. Please commit or stash them before releasing."
exit 1
fi

# Ensure we're on develop branch
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ "$CURRENT_BRANCH" != "develop" ]]; then
echo "Error: You must be on the develop branch to release. Currently on: $CURRENT_BRANCH"
exit 1
fi

# Pull latest develop
echo "Updating develop branch..."
git pull origin develop

# Check if develop is ahead of main
AHEAD_COUNT=$(git rev-list --count origin/main..origin/develop)
if [[ "$AHEAD_COUNT" -eq 0 ]]; then
echo "Error: develop branch is not ahead of main. Nothing to release."
exit 1
fi

echo ""
echo "Changes to be released:"
git log --oneline --no-merges origin/main..origin/develop

echo ""
read -p "Do you want to proceed with the release? (y/n) " CONFIRM
if [[ "$CONFIRM" != "y" ]]; then
echo "Release cancelled."
exit 0
fi

# Checkout main
echo "Checking out main branch..."
git checkout main

# Pull latest main
echo "Updating main branch..."
git pull origin main

# Merge develop
echo "Merging develop into main..."
git merge --no-ff develop -m "Release: Merge develop into main for automated release"

# Push to remote
echo "Pushing to remote..."
git push origin main

# Switch back to develop
echo "Switching back to develop branch..."
git checkout develop

echo ""
echo "Release process completed successfully!"
echo "The CI pipeline will automatically:"
echo "1. Run tests"
echo "2. Bump version number"
echo "3. Create a tagged release"
echo ""
echo "You can monitor the release progress in Azure DevOps."
3 changes: 3 additions & 0 deletions crowdin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
files:
- source: /src/Core/Resources/Resources.resx
translation: /src/Core/Resources/Resources.%two_letters_code%.resx
71 changes: 71 additions & 0 deletions docs/ASYNC_INITIALIZATION_PATTERN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Async Initialization Pattern in ConnectViewModel

## Problem
The `ConnectViewModel` performs asynchronous initialization of serial ports in its constructor using `Task.Run`. This created testing challenges because:
- Tests had to use unreliable `Task.Delay` to wait for initialization
- No way to know when initialization completed
- Race conditions could cause flaky tests

## Solution
We implemented a `TaskCompletionSource` pattern to track initialization completion:

### 1. Added Initialization Tracking
```csharp
private readonly TaskCompletionSource<bool> _initializationComplete = new();

/// <summary>
/// Gets a task that completes when the initial serial port scan is finished.
/// </summary>
public Task InitializationComplete => _initializationComplete.Task;
```

### 2. Signal Completion in InitializeSerialPorts
```csharp
private async Task InitializeSerialPorts()
{
try
{
// ... initialization logic ...
_initializationComplete.SetResult(true);
}
catch (Exception ex)
{
// ... error handling ...
_initializationComplete.SetException(ex);
}
}
```

### 3. Use in Tests
```csharp
[Test]
public async Task ConnectViewModel_InitializesSerialPortsOnStartup()
{
// Arrange
var availablePorts = CreateTestSerialPorts();
SetupSerialPortMockWithPorts(availablePorts);

// Act
var newViewModel = new ConnectViewModel(...);

// Wait for initialization to complete
await newViewModel.InitializationComplete;

// Assert
Assert.That(newViewModel.AvailableSerialPorts.Count, Is.GreaterThan(0));
}
```

## Benefits
1. **Deterministic**: Tests wait exactly as long as needed
2. **Reliable**: No race conditions or timing issues
3. **Fast**: No unnecessary delays
4. **Error handling**: Exceptions during initialization are properly propagated
5. **Testable**: Different initialization scenarios can be tested (success, failure, no ports)

## Alternative Patterns Considered
1. **Factory pattern with async initialization**: Would require changing how ViewModels are created
2. **Lazy initialization**: Would complicate the ViewModel usage
3. **Synchronous initialization**: Would block the UI thread

The `TaskCompletionSource` pattern provides the best balance of simplicity, testability, and maintaining the existing architecture.
44 changes: 14 additions & 30 deletions CLAUDE.md → docs/CLAUDE.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# OSDP-Bench Development Guidelines

## References
- OSDP.Net source code: https://github.com/bytedreamer/OSDP.Net

## Build Commands
- Build solution: `dotnet build OSDP-Bench.sln`
- Build specific project: `dotnet build src/Core/Core.csproj`
- Build a specific project: `dotnet build src/Core/Core.csproj`
- Build release version: `dotnet build -c Release OSDP-Bench.sln`

## Test Commands
Expand All @@ -13,43 +16,24 @@

## Code Style Guidelines
- Use C# 8.0+ features with async/await patterns for asynchronous operations
- Follow MVVM design pattern for view models with ObservableObject and RelayCommand
- Follow the MVVM design pattern for view models with ObservableObject and RelayCommand
- Use dependency injection for services
- Include XML documentation for public interfaces and methods
- Use PascalCase for class, method, and public property names
- Use _camelCase for private fields with underscore prefix
- Use _camelCase for private fields with an underscore prefix
- Implement defensive programming with null checks for constructor parameters
- Use standard exception handling with try/catch blocks around external operations
- Prefer async/await over direct Task management
- Organize files into clear namespaces (Core, Models, Services, ViewModels, etc.)
- Use meaningful variable names that reflect their purpose
- Keep methods focused and small with a single responsibility

## Refactoring Opportunities

1. DeviceManagementService.cs:
- Extract duplicate event raising patterns into helper methods
- Improve error handling in empty catch blocks
- Split long class (374 lines) into focused components

2. ConnectViewModel.cs:
- Extract large switch statement in DiscoverDevice method
- Split ScanSerialPorts method with multiple responsibilities
- Simplify nested logic in ConnectDevice

3. ManageViewModel.cs:
- Refactor 57-line ExecuteDeviceAction method
- Extract special handling for ResetCypressDeviceAction

4. Consolidate nearly identical implementations:
- MonitorCardReads.cs and MonitorKeyPadReads.cs

5. Test improvements:
- Remove duplicated setup code in ConnectViewModelTests.cs
- Increase test coverage beyond just ConnectViewModel
## UI Style Guidelines
- **Always use standard styles** - Apply predefined styles from the design system instead of inline properties
- **Use design tokens for spacing** - Reference `{StaticResource Margin.Card}` instead of hardcoding values
- **Apply semantic colors** - Use `{StaticResource Brush.Error}` instead of hardcoded colors like "Red"
- **Follow the style hierarchy** - Check ComponentStyles.xaml and LayoutTemplates.xaml before creating custom styles
- **Update existing code** - When modifying files, replace inline styling with standard styles
- **Create reusable patterns** - If you find yourself repeating XAML structures, consider adding a new style or template

6. Cross-cutting concerns:
- Standardize inconsistent error handling approaches
- Reduce ViewModels coupling to DeviceManagementService
- Fix naming inconsistencies (MonitorKeypadReads vs MonitorKeyPadReads)
- Convert hardcoded values (BaudRates, timeouts) to constants
For detailed UI styling guidelines and examples, see: `src/UI/Windows/Styles/StyleGuide.md`
Loading