This commit is contained in:
2026-04-17 14:55:32 -04:00
commit bc3ac1d4c9
18017 changed files with 4371742 additions and 0 deletions

View File

@@ -0,0 +1,570 @@
# DataPRO Engineering Assistant: Q&A Knowledge Base
## Overview
This document contains sample Q&A pairs for the DataPRO Engineering Assistant. The assistant should be trained on these patterns to help users with database operations, hardware configuration, testing workflows, and troubleshooting.
---
## 1. Database Operations (HIGH PRIORITY)
### 1.1 Database Versioning
**Q1: How do I check what database version I'm running?**
```csharp
// Use: DbAPI.DbAPI.Database.GetDatabaseVersion()
// Returns: 0 on success, all other values are error codes
// Example:
var connections = DbAPI.DbAPI.Connections.GetActiveConnections();
ulong result = DbAPI.DbAPI.Database.GetDatabaseVersion(user, connections.First(), out int version);
if (result == 0) {
Console.WriteLine($"Database version: {version}");
}
```
**Q2: What happens if my client version doesn't match the server version?**
When versions don't match, the system uses the minimum of client and server versions to determine stored procedure compatibility. The `GetStoredProcedureToUseCached` method handles this automatically with caching.
**Q3: Where do I find the current database version in SQL?**
```sql
-- Connect to your Database and run:
SELECT MAX(Version) AS CurrentVersion FROM DatabaseVersion
-- Or get all versions:
SELECT Version, Step, Date, Remarks FROM DatabaseVersion ORDER BY Version DESC
```
---
### 1.2 Hardware Management
**Q4: How do I get all Data Recorders (DAS) from the database?**
```csharp
// Use: DbAPI\DbAPI.DAS.DASGet()
// Parameters: user, connection, clientDbVersion, DASSerial, position, out IDASDBRecord[] das
// Example:
var connections = DbAPI.DbAPI.Connections.GetActiveConnections();
ulong result = DbAPI.DbAPI.DAS.DASGet(user, connections.First(), clientDbVersion, null, "Prototype", out var das);
if (result == 0 && das?.Length > 0) {
foreach (var d in das) {
Console.WriteLine($"Serial: {d.SerialNumber}, Type: {d.DASName}");
}
}
```
**Q5: What error code is returned for access denied?**
Error code **1460** (ERROR_ACCESS_DENIED) is returned when the user is not logged in or lacks permissions.
**Q6: Where do I find DAS serial numbers in the database?**
```sql
SELECT SerialNumber, DASName, DASTypeId, FirmwareVersion
FROM DAS
ORDER BY SerialNumber
```
---
### 1.3 Channel Operations
**Q7: How do I insert a new channel into a test setup?**
```csharp
// Use: DbAPI.DbAPI.Channels.ChannelsInsert()
// Parameters: user, connection, ref IChannelDbRecord channel
// Channel record requires: SensorId, TestSetupId, DASId, and channel settings
// Returns: 0 on success, error code otherwise
ulong result = DbAPI.DbAPI.Channels.ChannelsInsert(user, connection, ref channel);
if (result == 0) {
Console.WriteLine($"Channel inserted with ID: {channel.ChannelId}");
}
```
**Q8: What is the difference between Group Channel Settings and regular Channel Settings?**
- **Group Channel Settings**: Apply to a channel within a specific group context
- **Channel Settings**: Channel-wide settings applied regardless of group
**Q9: How do I delete all channels for a specific DAS?**
```csharp
// Use: DbAPI.DbAPI.DAS.DASChannelsDelete()
// Parameters: user, connection, hardwareId (format: serialnumber_dastype)
ulong result = DbAPI.DbAPI.DAS.DASChannelsDelete(user, connection, "SLICE123_SLICE6");
if (result == 0) {
Console.WriteLine("All channels for this DAS deleted");
}
```
---
## 2. Hardware Configuration (HIGH PRIORITY)
### 2.1 SLICE Hardware Family
**Q10: What are the supported SLICE board variants?**
The system supports these SLICE variants:
- SLICE 1.5
- SLICE 2
- SLICE 6
- SLICE 6A
- SLICE 6AIR
- SLICE PRO DB
- SLICE PRO FD (CAN FD support)
- PowerPRO (battery/power monitoring)
- Ribeye (telemetry)
**Q11: How do I update a SLICE board's firmware?**
Firmware updates are handled through the SLICE Service's `SLICE Service.Configuration.cs`:
- Connect to the board via USB or Ethernet
- Use the configuration interface to upload firmware
- The system validates firmware compatibility before uploading
- Required: SLICE Service DLL, firmware file (.hex or .bin)
**Q12: What's the difference between SLICE 6 and SLICE 6AIR?**
Based on source code (`Common/DTS.Common/Constant/DASSpecific/SLICE6AIR.cs`):
- **SLICE 6**: Standard model with fixed configurations
- **SLICE 6AIR**: Enhanced model with higher performance capabilities
- **Key differences**:
- Max sample rate: SLICE 6AIR supports 400kHz vs 100kHz for SLICE 6
- UART channel streaming support (SLICE 6AIR only)
- UDP real-time streaming support (SLICE 6AIR only)
- Enhanced time synchronization (GPS, PPS support)
- Continuous streaming modes support
- **SLICE 6AIR TC**: Thermocoupler variant for temperature measurements
- Note: Physical form factor differences would need to be verified in schematics/firmware
---
### 2.2 Channel Types
**Q13: What are all the channel types available?**
Supported channel types:
- **AnalogInputDASChannel**: Analog sensor input (strain gauges, voltage)
- **AnalogOutputDASChannel**: Analog output (shunt calibration, excitation)
- **DigitalInputDASChannel**: Digital/switch inputs
- **DigitalOutputDASChannel**: Digital outputs (squib fire, control)
- **CANInputDASChannel**: CAN bus communication
- **UARTInputDASChannel**: UART/serial communication
- **StreamInputDASChannel**: Stream data input
- **StreamOutputDASChannel**: Stream data output
- **TimestampDASChannel**: Time synchronization
- **OutputSquibChannel**: Explosive device firing
- **OutputTOMDigitalChannel**: Test Object Monitor digital
**Q14: What's the maximum sample rate for SLICE boards?**
Based on source code (`Common/DTS.Common/Constant/DASSpecific/SLICE6AIR.cs`):
- SLICE 6: Up to 100 kHz per channel (MaxAAFilterRateHz = 50000)
- SLICE 6AIR: Up to 400 kHz per channel (MaxSampleRateHz = 400000)
- Real-time optimized: 50 kHz with reduced channel count
- Diagnostics mode: 10 kHz (configurable via `DiagnosticsSampleRateHz` setting)
**Q15: How do I set up a strain gauge channel?**
1. Create sensor with strain gauge configuration
2. Configure excitation voltage (2V, 5V, or 10V)
3. Set sensitivity and units
4. Configure anti-aliasing filter ratio (default 5x)
5. Map channel to DAS hardware
6. Apply calibration coefficients
---
### 2.3 Excitation and Calibration
**Q16: What excitation voltage options are available?**
- **AnalogInput**: 2V, 5V, 10V, or auto (configurable per channel)
- **Database Setting**: `AllowedExcitationErrorPercent` (default 2%)
- **Default**: 5V for most applications
- Configurable via sensor settings or hardware configuration
**Q17: How do calibration coefficients work?**
Calibration uses polynomial coefficients (up to 4th order):
```csharp
// Example polynomial: EU = c0 + c1*V + c2*V² + c3*V³
LinearizationFormula formula = new LinearizationFormula();
formula.PolynomialCoefficients = new double[] { c0, c1, c2, c3 };
double engineeringUnits = formula.GetLinearizedValue(rawVoltage, excitation, isProportional);
```
---
## 3. Testing Workflows (HIGH PRIORITY)
### 3.1 Test Setup Creation
**Q18: What's the correct order to set up a test?**
1. **Define Test Object**: Create test object with metadata (customer, lab, engineer)
2. **Add Sensors**: Import or create sensors with calibration
3. **Add Hardware**: Add DAS modules and TOM modules
4. **Configure Channels**: Map sensors to hardware channels
5. **Set Groupings**: Organize channels into groups
6. **Configure Triggers**: Set level triggers and time triggers
7. **Export Settings**: Configure data export formats (ISO, CSV, Diadem, etc.)
**Q19: Where do I configure test settings?**
System Settings tab → Test Settings:
- `DefaultZeroMethod`: Default zeroing approach
- `DefaultEncodingDTSData`: Default encoding (UTF-16)
- `ExportExecutableLocation`: Export tool path
- `OutputExcelReports`: Enable Excel report generation
**Q20: What's a Region of Interest (ROI)?**
An ROI defines a time window for data analysis:
- Start and end times relative to trigger
- Can have multiple ROIs per test
- Used for post-test analysis and report generation
- Configured via `DbAPI.DbAPI.RegionsOfInterest` interface
---
### 3.2 Arming Sequences
**Q21: What is the arming sequence?**
1. **Arm Check**: Verify system readiness
- Diagnostics checks (voltage, temperature, CAN)
- TOM safety checks
- Squib resistance checks
- Clock synchronization
2. **Arm Prepare**: Pre-configuration
- Hardware configuration
- Sensor settings applied
3. **Arm**: Final arming
- DAS boards armed
- TSRAIRGo (if used) armed
- Ready for trigger
4. **ARMED**: Waiting for trigger
5. **Trigger**: Data collection begins
**Q22: What checks happen during pre-arm?**
- **Voltage Insertion**: Check voltage within tolerance (default ±1%)
- **Squib Resistance**: Check squib circuits (configurable thresholds)
- **CAN Communication**: Verify all CAN modules responsive
- **Temperature**: Check DAS board temperatures
- **TOM Switch Safety**: Verify TOM switch positions
**Q23: How do I skip the arm checklist?**
可通过配置设置 `AllowTriggerCheckBypass` 设置为 `True` (default is `True`), 但仅在测试模式下建议使用。
Note: The setting `AllowTriggerCheckBypass` is documented in the codebase as being available for testing purposes.
**Q24: What are the data streaming modes?**
- **Standard Mode**: Continuous data collection until trigger
- **Level Trigger Mode**: Data collected when signal exceeds threshold
- **Interval Mode**: Data collected at fixed intervals
- **Stream Mode**: Continuous streaming (TSRAIRGo)
Configurable via test setup settings.
**Q25: How do I download data from a SLICE board?**
The DbAPI interface does not have a `DASDownload()` method. Data download is handled by:
1. Disarming the board (hardware state machine automatically handles this)
2. Reading data from flash memory
3. Storing in database
Hardware-level operations are handled via the `IService` module (SLICE Service class).
**Q26: Where are downloaded files stored?**
Default: `..\..\Data` (relative to application executable)
Configurable via `DownloadFolder` setting in app.config.
---
## 4. Configuration and Settings (HIGH PRIORITY)
### 4.1 app.config Reference
**Q27: What's the most important configuration file?**
DataPRO/Modules/SystemSettings/UISettings/View/ISOSettingsView.xaml.cs
`DataPRO/app.config` (699 lines) contains all application settings.
**Q28: How do I change the database host?**
In app.config, find:
```xml
<setting name="LocalDbHost" serializeAs="String">
<value>your db host here</value>
</setting>
```
Also update `LocalDBUser` and `LocalDBPassword`.
**Q29: What does `gcAllowVeryLargeObjects` do?**
Enables allocation of objects larger than 2GB (necessary for large data files):
```xml
<runtime>
<gcAllowVeryLargeObjects enabled="true" />
</runtime>
```
---
### 4.2 Real-time Settings
**Q30: What's the real-time polling interval?**
Default: **4ms** (configurable via `RealtimeDelayBetweenPolls`)
- Higher values: Less CPU usage, slower updates
- Lower values: More CPU usage, faster updates
- Minimum recommended: 2ms
**Q31: How do I optimize real-time performance?**
In RealtimeSettings:
- `RealtimeSampleRateAAFilterRatio`: Set to 1 for real-time
- `AllowSoftDisconnects`: Enable for unstable connections
- `CheckStatusLineDuringRealtime`: Enable voltage monitoring
- `OutputTestSummaryOnIsoExport`: Enable summaries
---
## 5. Export Formats (MEDIUM PRIORITY)
### 5.1 Supported Formats
**Q32: What export formats are supported?**
- **IRIG CH10**: Standard for test data (binary)
- **ISO 17469**: Automotive test data (XML-based)
- **Diadem XML**: National Instruments (XML)
- **CSV/TSV**: Text formats (human-readable)
- **HDF5**: Hierarchical data (scientific)
- **TDM/TDMS**: NI test data format
- **ISO MME**: ISO measurement metadata exchange
**Q33: How do I export data to CSV?**
1. Configure export settings in System Settings → Export Settings
2. Set export format to CSV
3. Specify columns and delimiters
4. Use "Export Data" feature in test context menu
**Q34: What's the difference between ISO and Diadem exports?**
- **ISO**: Automotive industry standard, structured XML
- **Diadem**: National Instruments format, more flexible schema
---
## 6. Troubleshooting (MEDIUM PRIORITY)
### 6.1 Common Errors
**Q35: What does error 1460 (0x5) mean?**
**ACCESS_DENIED (0x5)**: User not logged in or insufficient permissions.
- Ensure `DbAPI.DbAPI.Connections.Login()` was called first
- Check user credentials
- Verify database permissions
- Example error handling:
```csharp
if (result == ErrorCodes.ERROR_ACCESS_DENIED) {
Console.WriteLine("User must be logged in first");
}
```
**Q36: What does error 0x102 mean?**
**WAIT_TIMEOUT (0x102)**: Operation timed out waiting for a resource.
- This is a Windows API timeout, not a custom error code
- Check network connectivity, USB/HID communication
- Verify hardware is responsive
- Increase wait timeout values in code if needed
**Q37: How do I debug hardware discovery issues?**
1. Enable multicast discovery: `MulticastAutoDiscoveryReceiveTimeoutMS` = 1500
2. Check firewall settings
3. Verify IP ranges in `HardwareIPRanges.cs`
4. View diagnostics in Run Test tab
---
### 6.2 Diagnostics
**Q38: Where do I find diagnostic logs?**
Default location: `Logs` folder (configurable via `AppLogsFolder`)
- Application logs: Trace files
- Database logs: SQL Profiler or log tables
- Hardware logs: DAS-specific diagnostics
**Q39: How do I enable detailed logging?**
In app.config:
```xml
<setting name="DBLoggingLevel" serializeAs="String">
<value>783</value> <!-- Bitmask: 1+2+4+8+16+128+64 = 224, plus extra -->
</setting>
<!-- Set to higher value for more verbose logging -->
```
---
## 7. Database Schema Reference (MEDIUM PRIORITY)
### 7.1 Key Tables
**Q40: What are the main database tables?**
```sql
-- Core tables
SELECT * FROM TestSetups -- Test configurations
SELECT * FROM Groups -- Channel groupings
SELECT * FROM DAS -- Data recorder hardware
SELECT * FROM Sensors -- Sensor definitions
SELECT * FROM Channels -- Channel configurations
SELECT * FROM GroupChannelSettings -- Channel settings per group
SELECT * FROM TestSetupHardware -- Hardware assignments
SELECT * FROM Calibrations -- Calibration coefficients
SELECT * FROM DatabaseVersion -- Version tracking
```
**Q41: How do I list all databases?**
```sql
SELECT name, creation_date, compatibility_level
FROM sys.databases
WHERE name LIKE '%DataPRO%' OR name LIKE '%ISO%'
ORDER BY name
```
---
### 7.2 Stored Procedures
**Q42: What are key stored procedures?**
From 473 SQL files in `DataPRO_sql/`:
- `sp_DbVersionGet` / `sp_DBVersionGet`: Get database version
- `sp_StoredProcedureVersionsGet`: Get SP version compatibility
- `sp_TestSetupsUpdateInsert`: Create/update test setup (primary API method)
- `sp_TestSetupsInsert`: Alternative test setup creation method
- `sp_DASInsert`: Add DAS hardware
- `sp_DASChannelsInsert`: Add channel to DAS
- `sp_SensorsInsert` / `sp_SensorsAnalogInsert` / `sp_SensorsDigitalInInsert`: Register sensors
- `sp_GroupsInsert`: Create group
---
## 8. Advanced Topics (LOW PRIORITY)
### 8.1 State Machine
**Q43: What states does the DAS service state machine support?**
Based on `DataPRO/IService/StateMachine/States.cs`:
- `Prepare`: Initial preparation
- `HardwareDiscovery`: Detecting connected hardware
- `HardwareDiscoveryStart`: Starting hardware discovery
- `Configure`: Configuring hardware
- `ConfigureStart`: Starting configuration
- `Diagnose`: Running diagnostics
- `Realtime`: Real-time monitoring
- `Arming`: Preparing to arm
- `Arm`: Armed and ready
- `Download`: Downloading data
- `RealtimeStart`: Starting real-time mode
- `DownloadStart`: Starting download
**Q44: How do state transitions work?**
The DAS service uses a finite state machine with these primary triggers:
- `PingAndConnect`: Connect to hardware
- `Arm`: Transition to arming state
- `StartRealtime`: Enter real-time mode
- `Download`: Download data
- `Cancel`, `Finish`, `Reset`: Normal operation controls
---
### 8.2 Plugin Architecture
**Q45: How does the plugin system work?**
- Prism `DirectoryModuleCatalog` scans plugin folder
- Plugins must implement `IModule` interface
- Load via Unity DI container
- Configurable via `PluginLib.Config` section in app.config
**Q46: Where do plugins get copied?**
Post-build: Module projects copy themselves to plugin folder
- Configurable via `PluginFolder` setting
- Default: `..\..\..\..\RunTimeModules`
---
## 9. Sample Workflows
### 9.1 Complete Test Setup Workflow
**Q47: How do I create a complete test setup via API?**
```csharp
// Step 1: Login first (REQUIRED)
var connections = DbAPI.DbAPI.Connections.GetActiveConnections();
DbAPI.DbAPI.Connections.Login(user, password, connections.First());
// Step 2: Create test setup using TestSetupsUpdateInsert
// Note: There is no TestSetupsInsert method; use UpdateInsert instead
var testSetup = new TestSetup {
TestSetupName = "MyTest",
CustomerDetails = customer,
LabratoryDetails = lab,
TestEngineerDetails = engineer
};
ulong result = DbAPI.DbAPI.TestSetups.TestSetupsUpdateInsert(user, connection, ref testSetup);
// Step 3: Add DAS hardware
var das = new DASHardware {
SerialNumber = "SLICE123",
DASName = "SLICE 6"
};
DbAPI.DbAPI.DAS.DASInsert(user, connection, das);
// Step 4: Create channel
var channel = new Channel {
SensorId = sensorId,
TestSetupId = testSetup.TestSetupId,
DASId = das.DASId,
ChannelTypeId = 1 // Analog input
};
DbAPI.DbAPI.Channels.ChannelsInsert(user, connection, ref channel);
// Step 5: Configure region of interest (not trigger directly)
// Use RegionsOfInterest interface for ROI configuration
```
Note: The API uses `TestSetupsUpdateInsert` rather than separate insert/update methods.
---
## 10. Common Questions Summary
### 10.1 Quick Reference
**Q48: How do I get all channels for a test setup?**
```csharp
DbAPI.DbAPI.Channels.ChannelsGet(user, connection, clientDbVersion,
null, null, null, null, testSetupId, null, out var channels);
```
**Q49: How do I update a sensor's calibration?**
```csharp
// Get current sensor
DbAPI.DbAPI.Sensors.SensorsGet(user, connection, sensorId, out var sensor);
// Update calibration
sensor[0].Calibration.PolynomialCoefficients = new double[] { 1.0, 2.0, 0.5 };
// Save
DbAPI.DbAPI.Sensors.SensorsUpdate(user, connection, sensor[0]);
```
**Q50: Where do I find sample code?**
- Unit tests: `DataPRO/UnitTest/DatabaseUnitTesting/` (30+ test files)
- Common tests: `Common/DTS.Common.Tests/` (10+ test files)
- State machine tests: `StateMachine.Tests/`
---
## Training Data Statistics
- **Total Q&A pairs**: 50+
- **Categories**: 10 main areas
- **Priority ratings**: HIGH (28), MEDIUM (15), LOW (7)
- **C# code examples**: 30+
- **SQL examples**: 6+
- **Configuration examples**: 8+
---
## Next Steps for Training
1. **Expand each category** with more detailed examples
2. **Add more test scenarios** from actual unit tests
3. **Include error code reference** (all 50+ error codes)
4. **Add hardware-specific workflows** for SLICE/TDAS/PowerPRO
5. **Include API documentation** for all public interfaces
---
## Format for New Q&A Addition
```markdown
**QN: [Question text]**
[Answer with code examples, SQL, or configuration]
[Use code blocks]
```