Private Class ParametersAndCommands
Public Property Description As String
Public Property Unit As CommandData.ParameterUnit
Public Property MinimumCommand As Byte
Public Property MinimumValue As Decimal
Public Property MinimumAccess As Command.AccessLevel
Public Property DefaultCommand As Byte
Public Property DefaultValue As Decimal
Public Property DefaultAccess As Command.AccessLevel
Public Property MaximumCommand As Byte
Public Property MaximumValue As Byte
Public Property MaximumAccess As Command.AccessLevel
End Class
Dim PacQuery = From p In WorkingProduct.Parameters _
Join c In WorkingProfile.Commands _
On p.DefaultCommand Equals c.Code _
Select New ParametersAndCommands With _
{.Description = p.Description, .Unit = p.Unit, _
.MinimumCommand = p.MinimumCommand, _
.DefaultCommand = p.DefaultCommand, _
.DefaultValue = c.Value, _
.DefaultAccess = c.Access, _
.MaximumCommand = p.MaximumCommand}
Dim Pacs As BindingList(Of ParametersAndCommands) = New BindingList(Of ParametersAndCommands)(PacQuery.ToList)
For Each pac As ParametersAndCommands In Pacs
Dim q As ParametersAndCommands = pac
Dim MaxCommand As Command
Dim MinCommand As Command
If q.MinimumCommand <> 0 Then
MinCommand = (From c In WorkingProfile.Commands _
Where c.Code = q.MinimumCommand _
Select c).First
If MinCommand IsNot Nothing Then
pac.MinimumValue = MinCommand.Value
pac.MinimumAccess = MinCommand.Access
End If
End If
If q.MaximumCommand <> 0 Then
MaxCommand = (From c In WorkingProfile.Commands _
Where c.Code = q.MaximumCommand _
Select c).First
If MaxCommand IsNot Nothing Then
pac.MaximumValue = MaxCommand.Value
pac.MaximumAccess = MaxCommand.Access
End If
End If
Next