github.com/blueinnovationsgroup/can-go@v0.0.0-20230518195432-d0567cda0028/testdata/gen/go/example/example.dbc.go (about) 1 // Package examplecan provides primitives for encoding and decoding example CAN messages. 2 // 3 // Source: testdata/dbc/example/example.dbc 4 package examplecan 5 6 import ( 7 "context" 8 "fmt" 9 "net" 10 "net/http" 11 "sync" 12 "time" 13 14 "github.com/blueinnovationsgroup/can-go" 15 "github.com/blueinnovationsgroup/can-go/pkg/candebug" 16 "github.com/blueinnovationsgroup/can-go/pkg/canrunner" 17 "github.com/blueinnovationsgroup/can-go/pkg/cantext" 18 "github.com/blueinnovationsgroup/can-go/pkg/descriptor" 19 "github.com/blueinnovationsgroup/can-go/pkg/generated" 20 "github.com/blueinnovationsgroup/can-go/pkg/socketcan" 21 ) 22 23 // prevent unused imports 24 var ( 25 _ = context.Background 26 _ = fmt.Print 27 _ = net.Dial 28 _ = http.Error 29 _ = sync.Mutex{} 30 _ = time.Now 31 _ = socketcan.Dial 32 _ = candebug.ServeMessagesHTTP 33 _ = canrunner.Run 34 ) 35 36 // Generated code. DO NOT EDIT. 37 // EmptyMessageReader provides read access to a EmptyMessage message. 38 type EmptyMessageReader interface { 39 } 40 41 // EmptyMessageWriter provides write access to a EmptyMessage message. 42 type EmptyMessageWriter interface { 43 // CopyFrom copies all values from EmptyMessageReader. 44 CopyFrom(EmptyMessageReader) *EmptyMessage 45 } 46 47 type EmptyMessage struct { 48 } 49 50 func NewEmptyMessage() *EmptyMessage { 51 m := &EmptyMessage{} 52 m.Reset() 53 return m 54 } 55 56 func (m *EmptyMessage) Reset() { 57 } 58 59 func (m *EmptyMessage) CopyFrom(o EmptyMessageReader) *EmptyMessage { 60 return m 61 } 62 63 // Descriptor returns the EmptyMessage descriptor. 64 func (m *EmptyMessage) Descriptor() *descriptor.Message { 65 return Messages().EmptyMessage.Message 66 } 67 68 // String returns a compact string representation of the message. 69 func (m *EmptyMessage) String() string { 70 return cantext.MessageString(m) 71 } 72 73 // Frame returns a CAN frame representing the message. 74 func (m *EmptyMessage) Frame() can.Frame { 75 md := Messages().EmptyMessage 76 f := can.Frame{ID: md.ID, IsExtended: md.IsExtended, Length: md.Length} 77 return f 78 } 79 80 // MarshalFrame encodes the message as a CAN frame. 81 func (m *EmptyMessage) MarshalFrame() (can.Frame, error) { 82 return m.Frame(), nil 83 } 84 85 // UnmarshalFrame decodes the message from a CAN frame. 86 func (m *EmptyMessage) UnmarshalFrame(f can.Frame) error { 87 md := Messages().EmptyMessage 88 switch { 89 case f.ID != md.ID: 90 return fmt.Errorf( 91 "unmarshal EmptyMessage: expects ID 1 (got %s with ID %d)", f.String(), f.ID, 92 ) 93 case f.Length != md.Length: 94 return fmt.Errorf( 95 "unmarshal EmptyMessage: expects length 0 (got %s with length %d)", f.String(), f.Length, 96 ) 97 case f.IsRemote: 98 return fmt.Errorf( 99 "unmarshal EmptyMessage: expects non-remote frame (got remote frame %s)", f.String(), 100 ) 101 case f.IsExtended != md.IsExtended: 102 return fmt.Errorf( 103 "unmarshal EmptyMessage: expects standard ID (got %s with extended ID)", f.String(), 104 ) 105 } 106 return nil 107 } 108 109 // DriverHeartbeatReader provides read access to a DriverHeartbeat message. 110 type DriverHeartbeatReader interface { 111 // Command returns the value of the Command signal. 112 Command() DriverHeartbeat_Command 113 } 114 115 // DriverHeartbeatWriter provides write access to a DriverHeartbeat message. 116 type DriverHeartbeatWriter interface { 117 // CopyFrom copies all values from DriverHeartbeatReader. 118 CopyFrom(DriverHeartbeatReader) *DriverHeartbeat 119 // SetCommand sets the value of the Command signal. 120 SetCommand(DriverHeartbeat_Command) *DriverHeartbeat 121 } 122 123 type DriverHeartbeat struct { 124 xxx_Command DriverHeartbeat_Command 125 } 126 127 func NewDriverHeartbeat() *DriverHeartbeat { 128 m := &DriverHeartbeat{} 129 m.Reset() 130 return m 131 } 132 133 func (m *DriverHeartbeat) Reset() { 134 m.xxx_Command = 0 135 } 136 137 func (m *DriverHeartbeat) CopyFrom(o DriverHeartbeatReader) *DriverHeartbeat { 138 m.xxx_Command = o.Command() 139 return m 140 } 141 142 // Descriptor returns the DriverHeartbeat descriptor. 143 func (m *DriverHeartbeat) Descriptor() *descriptor.Message { 144 return Messages().DriverHeartbeat.Message 145 } 146 147 // String returns a compact string representation of the message. 148 func (m *DriverHeartbeat) String() string { 149 return cantext.MessageString(m) 150 } 151 152 func (m *DriverHeartbeat) Command() DriverHeartbeat_Command { 153 return m.xxx_Command 154 } 155 156 func (m *DriverHeartbeat) SetCommand(v DriverHeartbeat_Command) *DriverHeartbeat { 157 m.xxx_Command = DriverHeartbeat_Command(Messages().DriverHeartbeat.Command.SaturatedCastUnsigned(uint64(v))) 158 return m 159 } 160 161 // DriverHeartbeat_Command models the Command signal of the DriverHeartbeat message. 162 type DriverHeartbeat_Command uint8 163 164 // Value descriptions for the Command signal of the DriverHeartbeat message. 165 const ( 166 DriverHeartbeat_Command_None DriverHeartbeat_Command = 0 167 DriverHeartbeat_Command_Sync DriverHeartbeat_Command = 1 168 DriverHeartbeat_Command_Reboot DriverHeartbeat_Command = 2 169 DriverHeartbeat_Command_HeadlightsOn DriverHeartbeat_Command = 3 170 ) 171 172 func (v DriverHeartbeat_Command) String() string { 173 switch v { 174 case 0: 175 return "None" 176 case 1: 177 return "Sync" 178 case 2: 179 return "Reboot" 180 case 3: 181 return "Headlights On" 182 default: 183 return fmt.Sprintf("DriverHeartbeat_Command(%d)", v) 184 } 185 } 186 187 // Frame returns a CAN frame representing the message. 188 func (m *DriverHeartbeat) Frame() can.Frame { 189 md := Messages().DriverHeartbeat 190 f := can.Frame{ID: md.ID, IsExtended: md.IsExtended, Length: md.Length} 191 md.Command.MarshalUnsigned(&f.Data, uint64(m.xxx_Command)) 192 return f 193 } 194 195 // MarshalFrame encodes the message as a CAN frame. 196 func (m *DriverHeartbeat) MarshalFrame() (can.Frame, error) { 197 return m.Frame(), nil 198 } 199 200 // UnmarshalFrame decodes the message from a CAN frame. 201 func (m *DriverHeartbeat) UnmarshalFrame(f can.Frame) error { 202 md := Messages().DriverHeartbeat 203 switch { 204 case f.ID != md.ID: 205 return fmt.Errorf( 206 "unmarshal DriverHeartbeat: expects ID 100 (got %s with ID %d)", f.String(), f.ID, 207 ) 208 case f.Length != md.Length: 209 return fmt.Errorf( 210 "unmarshal DriverHeartbeat: expects length 1 (got %s with length %d)", f.String(), f.Length, 211 ) 212 case f.IsRemote: 213 return fmt.Errorf( 214 "unmarshal DriverHeartbeat: expects non-remote frame (got remote frame %s)", f.String(), 215 ) 216 case f.IsExtended != md.IsExtended: 217 return fmt.Errorf( 218 "unmarshal DriverHeartbeat: expects standard ID (got %s with extended ID)", f.String(), 219 ) 220 } 221 m.xxx_Command = DriverHeartbeat_Command(md.Command.UnmarshalUnsigned(f.Data)) 222 return nil 223 } 224 225 // MotorCommandReader provides read access to a MotorCommand message. 226 type MotorCommandReader interface { 227 // Steer returns the physical value of the Steer signal. 228 Steer() float64 229 // Drive returns the physical value of the Drive signal. 230 Drive() float64 231 } 232 233 // MotorCommandWriter provides write access to a MotorCommand message. 234 type MotorCommandWriter interface { 235 // CopyFrom copies all values from MotorCommandReader. 236 CopyFrom(MotorCommandReader) *MotorCommand 237 // SetSteer sets the physical value of the Steer signal. 238 SetSteer(float64) *MotorCommand 239 // SetDrive sets the physical value of the Drive signal. 240 SetDrive(float64) *MotorCommand 241 } 242 243 type MotorCommand struct { 244 xxx_Steer int8 245 xxx_Drive uint8 246 } 247 248 func NewMotorCommand() *MotorCommand { 249 m := &MotorCommand{} 250 m.Reset() 251 return m 252 } 253 254 func (m *MotorCommand) Reset() { 255 m.xxx_Steer = 0 256 m.xxx_Drive = 0 257 } 258 259 func (m *MotorCommand) CopyFrom(o MotorCommandReader) *MotorCommand { 260 m.SetSteer(o.Steer()) 261 m.SetDrive(o.Drive()) 262 return m 263 } 264 265 // Descriptor returns the MotorCommand descriptor. 266 func (m *MotorCommand) Descriptor() *descriptor.Message { 267 return Messages().MotorCommand.Message 268 } 269 270 // String returns a compact string representation of the message. 271 func (m *MotorCommand) String() string { 272 return cantext.MessageString(m) 273 } 274 275 func (m *MotorCommand) Steer() float64 { 276 return Messages().MotorCommand.Steer.ToPhysical(float64(m.xxx_Steer)) 277 } 278 279 func (m *MotorCommand) SetSteer(v float64) *MotorCommand { 280 m.xxx_Steer = int8(Messages().MotorCommand.Steer.FromPhysical(v)) 281 return m 282 } 283 284 func (m *MotorCommand) Drive() float64 { 285 return Messages().MotorCommand.Drive.ToPhysical(float64(m.xxx_Drive)) 286 } 287 288 func (m *MotorCommand) SetDrive(v float64) *MotorCommand { 289 m.xxx_Drive = uint8(Messages().MotorCommand.Drive.FromPhysical(v)) 290 return m 291 } 292 293 // Frame returns a CAN frame representing the message. 294 func (m *MotorCommand) Frame() can.Frame { 295 md := Messages().MotorCommand 296 f := can.Frame{ID: md.ID, IsExtended: md.IsExtended, Length: md.Length} 297 md.Steer.MarshalSigned(&f.Data, int64(m.xxx_Steer)) 298 md.Drive.MarshalUnsigned(&f.Data, uint64(m.xxx_Drive)) 299 return f 300 } 301 302 // MarshalFrame encodes the message as a CAN frame. 303 func (m *MotorCommand) MarshalFrame() (can.Frame, error) { 304 return m.Frame(), nil 305 } 306 307 // UnmarshalFrame decodes the message from a CAN frame. 308 func (m *MotorCommand) UnmarshalFrame(f can.Frame) error { 309 md := Messages().MotorCommand 310 switch { 311 case f.ID != md.ID: 312 return fmt.Errorf( 313 "unmarshal MotorCommand: expects ID 101 (got %s with ID %d)", f.String(), f.ID, 314 ) 315 case f.Length != md.Length: 316 return fmt.Errorf( 317 "unmarshal MotorCommand: expects length 1 (got %s with length %d)", f.String(), f.Length, 318 ) 319 case f.IsRemote: 320 return fmt.Errorf( 321 "unmarshal MotorCommand: expects non-remote frame (got remote frame %s)", f.String(), 322 ) 323 case f.IsExtended != md.IsExtended: 324 return fmt.Errorf( 325 "unmarshal MotorCommand: expects standard ID (got %s with extended ID)", f.String(), 326 ) 327 } 328 m.xxx_Steer = int8(md.Steer.UnmarshalSigned(f.Data)) 329 m.xxx_Drive = uint8(md.Drive.UnmarshalUnsigned(f.Data)) 330 return nil 331 } 332 333 // SensorSonarsReader provides read access to a SensorSonars message. 334 type SensorSonarsReader interface { 335 // Mux returns the value of the Mux signal. 336 Mux() uint8 337 // ErrCount returns the value of the ErrCount signal. 338 ErrCount() uint16 339 // Left returns the physical value of the Left signal. 340 Left() float64 341 // NoFiltLeft returns the physical value of the NoFiltLeft signal. 342 NoFiltLeft() float64 343 // Middle returns the physical value of the Middle signal. 344 Middle() float64 345 // NoFiltMiddle returns the physical value of the NoFiltMiddle signal. 346 NoFiltMiddle() float64 347 // Right returns the physical value of the Right signal. 348 Right() float64 349 // NoFiltRight returns the physical value of the NoFiltRight signal. 350 NoFiltRight() float64 351 // Rear returns the physical value of the Rear signal. 352 Rear() float64 353 // NoFiltRear returns the physical value of the NoFiltRear signal. 354 NoFiltRear() float64 355 } 356 357 // SensorSonarsWriter provides write access to a SensorSonars message. 358 type SensorSonarsWriter interface { 359 // CopyFrom copies all values from SensorSonarsReader. 360 CopyFrom(SensorSonarsReader) *SensorSonars 361 // SetMux sets the value of the Mux signal. 362 SetMux(uint8) *SensorSonars 363 // SetErrCount sets the value of the ErrCount signal. 364 SetErrCount(uint16) *SensorSonars 365 // SetLeft sets the physical value of the Left signal. 366 SetLeft(float64) *SensorSonars 367 // SetNoFiltLeft sets the physical value of the NoFiltLeft signal. 368 SetNoFiltLeft(float64) *SensorSonars 369 // SetMiddle sets the physical value of the Middle signal. 370 SetMiddle(float64) *SensorSonars 371 // SetNoFiltMiddle sets the physical value of the NoFiltMiddle signal. 372 SetNoFiltMiddle(float64) *SensorSonars 373 // SetRight sets the physical value of the Right signal. 374 SetRight(float64) *SensorSonars 375 // SetNoFiltRight sets the physical value of the NoFiltRight signal. 376 SetNoFiltRight(float64) *SensorSonars 377 // SetRear sets the physical value of the Rear signal. 378 SetRear(float64) *SensorSonars 379 // SetNoFiltRear sets the physical value of the NoFiltRear signal. 380 SetNoFiltRear(float64) *SensorSonars 381 } 382 383 type SensorSonars struct { 384 xxx_Mux uint8 385 xxx_ErrCount uint16 386 xxx_Left uint16 387 xxx_NoFiltLeft uint16 388 xxx_Middle uint16 389 xxx_NoFiltMiddle uint16 390 xxx_Right uint16 391 xxx_NoFiltRight uint16 392 xxx_Rear uint16 393 xxx_NoFiltRear uint16 394 } 395 396 func NewSensorSonars() *SensorSonars { 397 m := &SensorSonars{} 398 m.Reset() 399 return m 400 } 401 402 func (m *SensorSonars) Reset() { 403 m.xxx_Mux = 0 404 m.xxx_ErrCount = 0 405 m.xxx_Left = 0 406 m.xxx_NoFiltLeft = 0 407 m.xxx_Middle = 0 408 m.xxx_NoFiltMiddle = 0 409 m.xxx_Right = 0 410 m.xxx_NoFiltRight = 0 411 m.xxx_Rear = 0 412 m.xxx_NoFiltRear = 0 413 } 414 415 func (m *SensorSonars) CopyFrom(o SensorSonarsReader) *SensorSonars { 416 m.xxx_Mux = o.Mux() 417 m.xxx_ErrCount = o.ErrCount() 418 m.SetLeft(o.Left()) 419 m.SetNoFiltLeft(o.NoFiltLeft()) 420 m.SetMiddle(o.Middle()) 421 m.SetNoFiltMiddle(o.NoFiltMiddle()) 422 m.SetRight(o.Right()) 423 m.SetNoFiltRight(o.NoFiltRight()) 424 m.SetRear(o.Rear()) 425 m.SetNoFiltRear(o.NoFiltRear()) 426 return m 427 } 428 429 // Descriptor returns the SensorSonars descriptor. 430 func (m *SensorSonars) Descriptor() *descriptor.Message { 431 return Messages().SensorSonars.Message 432 } 433 434 // String returns a compact string representation of the message. 435 func (m *SensorSonars) String() string { 436 return cantext.MessageString(m) 437 } 438 439 func (m *SensorSonars) Mux() uint8 { 440 return m.xxx_Mux 441 } 442 443 func (m *SensorSonars) SetMux(v uint8) *SensorSonars { 444 m.xxx_Mux = uint8(Messages().SensorSonars.Mux.SaturatedCastUnsigned(uint64(v))) 445 return m 446 } 447 448 func (m *SensorSonars) ErrCount() uint16 { 449 return m.xxx_ErrCount 450 } 451 452 func (m *SensorSonars) SetErrCount(v uint16) *SensorSonars { 453 m.xxx_ErrCount = uint16(Messages().SensorSonars.ErrCount.SaturatedCastUnsigned(uint64(v))) 454 return m 455 } 456 457 func (m *SensorSonars) Left() float64 { 458 return Messages().SensorSonars.Left.ToPhysical(float64(m.xxx_Left)) 459 } 460 461 func (m *SensorSonars) SetLeft(v float64) *SensorSonars { 462 m.xxx_Left = uint16(Messages().SensorSonars.Left.FromPhysical(v)) 463 return m 464 } 465 466 func (m *SensorSonars) NoFiltLeft() float64 { 467 return Messages().SensorSonars.NoFiltLeft.ToPhysical(float64(m.xxx_NoFiltLeft)) 468 } 469 470 func (m *SensorSonars) SetNoFiltLeft(v float64) *SensorSonars { 471 m.xxx_NoFiltLeft = uint16(Messages().SensorSonars.NoFiltLeft.FromPhysical(v)) 472 return m 473 } 474 475 func (m *SensorSonars) Middle() float64 { 476 return Messages().SensorSonars.Middle.ToPhysical(float64(m.xxx_Middle)) 477 } 478 479 func (m *SensorSonars) SetMiddle(v float64) *SensorSonars { 480 m.xxx_Middle = uint16(Messages().SensorSonars.Middle.FromPhysical(v)) 481 return m 482 } 483 484 func (m *SensorSonars) NoFiltMiddle() float64 { 485 return Messages().SensorSonars.NoFiltMiddle.ToPhysical(float64(m.xxx_NoFiltMiddle)) 486 } 487 488 func (m *SensorSonars) SetNoFiltMiddle(v float64) *SensorSonars { 489 m.xxx_NoFiltMiddle = uint16(Messages().SensorSonars.NoFiltMiddle.FromPhysical(v)) 490 return m 491 } 492 493 func (m *SensorSonars) Right() float64 { 494 return Messages().SensorSonars.Right.ToPhysical(float64(m.xxx_Right)) 495 } 496 497 func (m *SensorSonars) SetRight(v float64) *SensorSonars { 498 m.xxx_Right = uint16(Messages().SensorSonars.Right.FromPhysical(v)) 499 return m 500 } 501 502 func (m *SensorSonars) NoFiltRight() float64 { 503 return Messages().SensorSonars.NoFiltRight.ToPhysical(float64(m.xxx_NoFiltRight)) 504 } 505 506 func (m *SensorSonars) SetNoFiltRight(v float64) *SensorSonars { 507 m.xxx_NoFiltRight = uint16(Messages().SensorSonars.NoFiltRight.FromPhysical(v)) 508 return m 509 } 510 511 func (m *SensorSonars) Rear() float64 { 512 return Messages().SensorSonars.Rear.ToPhysical(float64(m.xxx_Rear)) 513 } 514 515 func (m *SensorSonars) SetRear(v float64) *SensorSonars { 516 m.xxx_Rear = uint16(Messages().SensorSonars.Rear.FromPhysical(v)) 517 return m 518 } 519 520 func (m *SensorSonars) NoFiltRear() float64 { 521 return Messages().SensorSonars.NoFiltRear.ToPhysical(float64(m.xxx_NoFiltRear)) 522 } 523 524 func (m *SensorSonars) SetNoFiltRear(v float64) *SensorSonars { 525 m.xxx_NoFiltRear = uint16(Messages().SensorSonars.NoFiltRear.FromPhysical(v)) 526 return m 527 } 528 529 // Frame returns a CAN frame representing the message. 530 func (m *SensorSonars) Frame() can.Frame { 531 md := Messages().SensorSonars 532 f := can.Frame{ID: md.ID, IsExtended: md.IsExtended, Length: md.Length} 533 md.Mux.MarshalUnsigned(&f.Data, uint64(m.xxx_Mux)) 534 md.ErrCount.MarshalUnsigned(&f.Data, uint64(m.xxx_ErrCount)) 535 if m.xxx_Mux == 0 { 536 md.Left.MarshalUnsigned(&f.Data, uint64(m.xxx_Left)) 537 } 538 if m.xxx_Mux == 1 { 539 md.NoFiltLeft.MarshalUnsigned(&f.Data, uint64(m.xxx_NoFiltLeft)) 540 } 541 if m.xxx_Mux == 0 { 542 md.Middle.MarshalUnsigned(&f.Data, uint64(m.xxx_Middle)) 543 } 544 if m.xxx_Mux == 1 { 545 md.NoFiltMiddle.MarshalUnsigned(&f.Data, uint64(m.xxx_NoFiltMiddle)) 546 } 547 if m.xxx_Mux == 0 { 548 md.Right.MarshalUnsigned(&f.Data, uint64(m.xxx_Right)) 549 } 550 if m.xxx_Mux == 1 { 551 md.NoFiltRight.MarshalUnsigned(&f.Data, uint64(m.xxx_NoFiltRight)) 552 } 553 if m.xxx_Mux == 0 { 554 md.Rear.MarshalUnsigned(&f.Data, uint64(m.xxx_Rear)) 555 } 556 if m.xxx_Mux == 1 { 557 md.NoFiltRear.MarshalUnsigned(&f.Data, uint64(m.xxx_NoFiltRear)) 558 } 559 return f 560 } 561 562 // MarshalFrame encodes the message as a CAN frame. 563 func (m *SensorSonars) MarshalFrame() (can.Frame, error) { 564 return m.Frame(), nil 565 } 566 567 // UnmarshalFrame decodes the message from a CAN frame. 568 func (m *SensorSonars) UnmarshalFrame(f can.Frame) error { 569 md := Messages().SensorSonars 570 switch { 571 case f.ID != md.ID: 572 return fmt.Errorf( 573 "unmarshal SensorSonars: expects ID 200 (got %s with ID %d)", f.String(), f.ID, 574 ) 575 case f.Length != md.Length: 576 return fmt.Errorf( 577 "unmarshal SensorSonars: expects length 8 (got %s with length %d)", f.String(), f.Length, 578 ) 579 case f.IsRemote: 580 return fmt.Errorf( 581 "unmarshal SensorSonars: expects non-remote frame (got remote frame %s)", f.String(), 582 ) 583 case f.IsExtended != md.IsExtended: 584 return fmt.Errorf( 585 "unmarshal SensorSonars: expects standard ID (got %s with extended ID)", f.String(), 586 ) 587 } 588 m.xxx_Mux = uint8(md.Mux.UnmarshalUnsigned(f.Data)) 589 m.xxx_ErrCount = uint16(md.ErrCount.UnmarshalUnsigned(f.Data)) 590 if m.xxx_Mux == 0 { 591 m.xxx_Left = uint16(md.Left.UnmarshalUnsigned(f.Data)) 592 } 593 if m.xxx_Mux == 1 { 594 m.xxx_NoFiltLeft = uint16(md.NoFiltLeft.UnmarshalUnsigned(f.Data)) 595 } 596 if m.xxx_Mux == 0 { 597 m.xxx_Middle = uint16(md.Middle.UnmarshalUnsigned(f.Data)) 598 } 599 if m.xxx_Mux == 1 { 600 m.xxx_NoFiltMiddle = uint16(md.NoFiltMiddle.UnmarshalUnsigned(f.Data)) 601 } 602 if m.xxx_Mux == 0 { 603 m.xxx_Right = uint16(md.Right.UnmarshalUnsigned(f.Data)) 604 } 605 if m.xxx_Mux == 1 { 606 m.xxx_NoFiltRight = uint16(md.NoFiltRight.UnmarshalUnsigned(f.Data)) 607 } 608 if m.xxx_Mux == 0 { 609 m.xxx_Rear = uint16(md.Rear.UnmarshalUnsigned(f.Data)) 610 } 611 if m.xxx_Mux == 1 { 612 m.xxx_NoFiltRear = uint16(md.NoFiltRear.UnmarshalUnsigned(f.Data)) 613 } 614 return nil 615 } 616 617 // MotorStatusReader provides read access to a MotorStatus message. 618 type MotorStatusReader interface { 619 // WheelError returns the value of the WheelError signal. 620 WheelError() bool 621 // SpeedKph returns the physical value of the SpeedKph signal. 622 SpeedKph() float64 623 } 624 625 // MotorStatusWriter provides write access to a MotorStatus message. 626 type MotorStatusWriter interface { 627 // CopyFrom copies all values from MotorStatusReader. 628 CopyFrom(MotorStatusReader) *MotorStatus 629 // SetWheelError sets the value of the WheelError signal. 630 SetWheelError(bool) *MotorStatus 631 // SetSpeedKph sets the physical value of the SpeedKph signal. 632 SetSpeedKph(float64) *MotorStatus 633 } 634 635 type MotorStatus struct { 636 xxx_WheelError bool 637 xxx_SpeedKph uint16 638 } 639 640 func NewMotorStatus() *MotorStatus { 641 m := &MotorStatus{} 642 m.Reset() 643 return m 644 } 645 646 func (m *MotorStatus) Reset() { 647 m.xxx_WheelError = false 648 m.xxx_SpeedKph = 0 649 } 650 651 func (m *MotorStatus) CopyFrom(o MotorStatusReader) *MotorStatus { 652 m.xxx_WheelError = o.WheelError() 653 m.SetSpeedKph(o.SpeedKph()) 654 return m 655 } 656 657 // Descriptor returns the MotorStatus descriptor. 658 func (m *MotorStatus) Descriptor() *descriptor.Message { 659 return Messages().MotorStatus.Message 660 } 661 662 // String returns a compact string representation of the message. 663 func (m *MotorStatus) String() string { 664 return cantext.MessageString(m) 665 } 666 667 func (m *MotorStatus) WheelError() bool { 668 return m.xxx_WheelError 669 } 670 671 func (m *MotorStatus) SetWheelError(v bool) *MotorStatus { 672 m.xxx_WheelError = v 673 return m 674 } 675 676 func (m *MotorStatus) SpeedKph() float64 { 677 return Messages().MotorStatus.SpeedKph.ToPhysical(float64(m.xxx_SpeedKph)) 678 } 679 680 func (m *MotorStatus) SetSpeedKph(v float64) *MotorStatus { 681 m.xxx_SpeedKph = uint16(Messages().MotorStatus.SpeedKph.FromPhysical(v)) 682 return m 683 } 684 685 // Frame returns a CAN frame representing the message. 686 func (m *MotorStatus) Frame() can.Frame { 687 md := Messages().MotorStatus 688 f := can.Frame{ID: md.ID, IsExtended: md.IsExtended, Length: md.Length} 689 md.WheelError.MarshalBool(&f.Data, bool(m.xxx_WheelError)) 690 md.SpeedKph.MarshalUnsigned(&f.Data, uint64(m.xxx_SpeedKph)) 691 return f 692 } 693 694 // MarshalFrame encodes the message as a CAN frame. 695 func (m *MotorStatus) MarshalFrame() (can.Frame, error) { 696 return m.Frame(), nil 697 } 698 699 // UnmarshalFrame decodes the message from a CAN frame. 700 func (m *MotorStatus) UnmarshalFrame(f can.Frame) error { 701 md := Messages().MotorStatus 702 switch { 703 case f.ID != md.ID: 704 return fmt.Errorf( 705 "unmarshal MotorStatus: expects ID 400 (got %s with ID %d)", f.String(), f.ID, 706 ) 707 case f.Length != md.Length: 708 return fmt.Errorf( 709 "unmarshal MotorStatus: expects length 3 (got %s with length %d)", f.String(), f.Length, 710 ) 711 case f.IsRemote: 712 return fmt.Errorf( 713 "unmarshal MotorStatus: expects non-remote frame (got remote frame %s)", f.String(), 714 ) 715 case f.IsExtended != md.IsExtended: 716 return fmt.Errorf( 717 "unmarshal MotorStatus: expects standard ID (got %s with extended ID)", f.String(), 718 ) 719 } 720 m.xxx_WheelError = bool(md.WheelError.UnmarshalBool(f.Data)) 721 m.xxx_SpeedKph = uint16(md.SpeedKph.UnmarshalUnsigned(f.Data)) 722 return nil 723 } 724 725 // IODebugReader provides read access to a IODebug message. 726 type IODebugReader interface { 727 // TestUnsigned returns the value of the TestUnsigned signal. 728 TestUnsigned() uint8 729 // TestEnum returns the value of the TestEnum signal. 730 TestEnum() IODebug_TestEnum 731 // TestSigned returns the value of the TestSigned signal. 732 TestSigned() int8 733 // TestFloat returns the physical value of the TestFloat signal. 734 TestFloat() float64 735 // TestBoolEnum returns the value of the TestBoolEnum signal. 736 TestBoolEnum() IODebug_TestBoolEnum 737 // TestScaledEnum returns the physical value of the TestScaledEnum signal. 738 TestScaledEnum() float64 739 740 // TestScaledEnum returns the raw (encoded) value of the TestScaledEnum signal. 741 RawTestScaledEnum() IODebug_TestScaledEnum 742 } 743 744 // IODebugWriter provides write access to a IODebug message. 745 type IODebugWriter interface { 746 // CopyFrom copies all values from IODebugReader. 747 CopyFrom(IODebugReader) *IODebug 748 // SetTestUnsigned sets the value of the TestUnsigned signal. 749 SetTestUnsigned(uint8) *IODebug 750 // SetTestEnum sets the value of the TestEnum signal. 751 SetTestEnum(IODebug_TestEnum) *IODebug 752 // SetTestSigned sets the value of the TestSigned signal. 753 SetTestSigned(int8) *IODebug 754 // SetTestFloat sets the physical value of the TestFloat signal. 755 SetTestFloat(float64) *IODebug 756 // SetTestBoolEnum sets the value of the TestBoolEnum signal. 757 SetTestBoolEnum(IODebug_TestBoolEnum) *IODebug 758 // SetTestScaledEnum sets the physical value of the TestScaledEnum signal. 759 SetTestScaledEnum(float64) *IODebug 760 761 // SetRawTestScaledEnum sets the raw (encoded) value of the TestScaledEnum signal. 762 SetRawTestScaledEnum(IODebug_TestScaledEnum) *IODebug 763 } 764 765 type IODebug struct { 766 xxx_TestUnsigned uint8 767 xxx_TestEnum IODebug_TestEnum 768 xxx_TestSigned int8 769 xxx_TestFloat uint8 770 xxx_TestBoolEnum IODebug_TestBoolEnum 771 xxx_TestScaledEnum IODebug_TestScaledEnum 772 } 773 774 func NewIODebug() *IODebug { 775 m := &IODebug{} 776 m.Reset() 777 return m 778 } 779 780 func (m *IODebug) Reset() { 781 m.xxx_TestUnsigned = 0 782 m.xxx_TestEnum = 2 783 m.xxx_TestSigned = 0 784 m.xxx_TestFloat = 0 785 m.xxx_TestBoolEnum = false 786 m.xxx_TestScaledEnum = 0 787 } 788 789 func (m *IODebug) CopyFrom(o IODebugReader) *IODebug { 790 m.xxx_TestUnsigned = o.TestUnsigned() 791 m.xxx_TestEnum = o.TestEnum() 792 m.xxx_TestSigned = o.TestSigned() 793 m.SetTestFloat(o.TestFloat()) 794 m.xxx_TestBoolEnum = o.TestBoolEnum() 795 m.SetTestScaledEnum(o.TestScaledEnum()) 796 return m 797 } 798 799 // Descriptor returns the IODebug descriptor. 800 func (m *IODebug) Descriptor() *descriptor.Message { 801 return Messages().IODebug.Message 802 } 803 804 // String returns a compact string representation of the message. 805 func (m *IODebug) String() string { 806 return cantext.MessageString(m) 807 } 808 809 func (m *IODebug) TestUnsigned() uint8 { 810 return m.xxx_TestUnsigned 811 } 812 813 func (m *IODebug) SetTestUnsigned(v uint8) *IODebug { 814 m.xxx_TestUnsigned = uint8(Messages().IODebug.TestUnsigned.SaturatedCastUnsigned(uint64(v))) 815 return m 816 } 817 818 func (m *IODebug) TestEnum() IODebug_TestEnum { 819 return m.xxx_TestEnum 820 } 821 822 func (m *IODebug) SetTestEnum(v IODebug_TestEnum) *IODebug { 823 m.xxx_TestEnum = IODebug_TestEnum(Messages().IODebug.TestEnum.SaturatedCastUnsigned(uint64(v))) 824 return m 825 } 826 827 func (m *IODebug) TestSigned() int8 { 828 return m.xxx_TestSigned 829 } 830 831 func (m *IODebug) SetTestSigned(v int8) *IODebug { 832 m.xxx_TestSigned = int8(Messages().IODebug.TestSigned.SaturatedCastSigned(int64(v))) 833 return m 834 } 835 836 func (m *IODebug) TestFloat() float64 { 837 return Messages().IODebug.TestFloat.ToPhysical(float64(m.xxx_TestFloat)) 838 } 839 840 func (m *IODebug) SetTestFloat(v float64) *IODebug { 841 m.xxx_TestFloat = uint8(Messages().IODebug.TestFloat.FromPhysical(v)) 842 return m 843 } 844 845 func (m *IODebug) TestBoolEnum() IODebug_TestBoolEnum { 846 return m.xxx_TestBoolEnum 847 } 848 849 func (m *IODebug) SetTestBoolEnum(v IODebug_TestBoolEnum) *IODebug { 850 m.xxx_TestBoolEnum = v 851 return m 852 } 853 854 func (m *IODebug) TestScaledEnum() float64 { 855 return Messages().IODebug.TestScaledEnum.ToPhysical(float64(m.xxx_TestScaledEnum)) 856 } 857 858 func (m *IODebug) SetTestScaledEnum(v float64) *IODebug { 859 m.xxx_TestScaledEnum = IODebug_TestScaledEnum(Messages().IODebug.TestScaledEnum.FromPhysical(v)) 860 return m 861 } 862 863 func (m *IODebug) RawTestScaledEnum() IODebug_TestScaledEnum { 864 return m.xxx_TestScaledEnum 865 } 866 867 func (m *IODebug) SetRawTestScaledEnum(v IODebug_TestScaledEnum) *IODebug { 868 m.xxx_TestScaledEnum = IODebug_TestScaledEnum(Messages().IODebug.TestScaledEnum.SaturatedCastUnsigned(uint64(v))) 869 return m 870 } 871 872 // IODebug_TestEnum models the TestEnum signal of the IODebug message. 873 type IODebug_TestEnum uint8 874 875 // Value descriptions for the TestEnum signal of the IODebug message. 876 const ( 877 IODebug_TestEnum_One IODebug_TestEnum = 1 878 IODebug_TestEnum_Two IODebug_TestEnum = 2 879 ) 880 881 func (v IODebug_TestEnum) String() string { 882 switch v { 883 case 1: 884 return "One" 885 case 2: 886 return "Two" 887 default: 888 return fmt.Sprintf("IODebug_TestEnum(%d)", v) 889 } 890 } 891 892 // IODebug_TestBoolEnum models the TestBoolEnum signal of the IODebug message. 893 type IODebug_TestBoolEnum bool 894 895 // Value descriptions for the TestBoolEnum signal of the IODebug message. 896 const ( 897 IODebug_TestBoolEnum_Zero IODebug_TestBoolEnum = false 898 IODebug_TestBoolEnum_One IODebug_TestBoolEnum = true 899 ) 900 901 func (v IODebug_TestBoolEnum) String() string { 902 switch bool(v) { 903 case false: 904 return "Zero" 905 case true: 906 return "One" 907 } 908 return fmt.Sprintf("IODebug_TestBoolEnum(%t)", v) 909 } 910 911 // IODebug_TestScaledEnum models the TestScaledEnum signal of the IODebug message. 912 type IODebug_TestScaledEnum uint8 913 914 // Value descriptions for the TestScaledEnum signal of the IODebug message. 915 const ( 916 IODebug_TestScaledEnum_Zero IODebug_TestScaledEnum = 0 917 IODebug_TestScaledEnum_Two IODebug_TestScaledEnum = 1 918 IODebug_TestScaledEnum_Four IODebug_TestScaledEnum = 2 919 IODebug_TestScaledEnum_Six IODebug_TestScaledEnum = 3 920 ) 921 922 func (v IODebug_TestScaledEnum) String() string { 923 switch v { 924 case 0: 925 return "Zero" 926 case 1: 927 return "Two" 928 case 2: 929 return "Four" 930 case 3: 931 return "Six" 932 default: 933 return fmt.Sprintf("IODebug_TestScaledEnum(%d)", v) 934 } 935 } 936 937 // Frame returns a CAN frame representing the message. 938 func (m *IODebug) Frame() can.Frame { 939 md := Messages().IODebug 940 f := can.Frame{ID: md.ID, IsExtended: md.IsExtended, Length: md.Length} 941 md.TestUnsigned.MarshalUnsigned(&f.Data, uint64(m.xxx_TestUnsigned)) 942 md.TestEnum.MarshalUnsigned(&f.Data, uint64(m.xxx_TestEnum)) 943 md.TestSigned.MarshalSigned(&f.Data, int64(m.xxx_TestSigned)) 944 md.TestFloat.MarshalUnsigned(&f.Data, uint64(m.xxx_TestFloat)) 945 md.TestBoolEnum.MarshalBool(&f.Data, bool(m.xxx_TestBoolEnum)) 946 md.TestScaledEnum.MarshalUnsigned(&f.Data, uint64(m.xxx_TestScaledEnum)) 947 return f 948 } 949 950 // MarshalFrame encodes the message as a CAN frame. 951 func (m *IODebug) MarshalFrame() (can.Frame, error) { 952 return m.Frame(), nil 953 } 954 955 // UnmarshalFrame decodes the message from a CAN frame. 956 func (m *IODebug) UnmarshalFrame(f can.Frame) error { 957 md := Messages().IODebug 958 switch { 959 case f.ID != md.ID: 960 return fmt.Errorf( 961 "unmarshal IODebug: expects ID 500 (got %s with ID %d)", f.String(), f.ID, 962 ) 963 case f.Length != md.Length: 964 return fmt.Errorf( 965 "unmarshal IODebug: expects length 6 (got %s with length %d)", f.String(), f.Length, 966 ) 967 case f.IsRemote: 968 return fmt.Errorf( 969 "unmarshal IODebug: expects non-remote frame (got remote frame %s)", f.String(), 970 ) 971 case f.IsExtended != md.IsExtended: 972 return fmt.Errorf( 973 "unmarshal IODebug: expects standard ID (got %s with extended ID)", f.String(), 974 ) 975 } 976 m.xxx_TestUnsigned = uint8(md.TestUnsigned.UnmarshalUnsigned(f.Data)) 977 m.xxx_TestEnum = IODebug_TestEnum(md.TestEnum.UnmarshalUnsigned(f.Data)) 978 m.xxx_TestSigned = int8(md.TestSigned.UnmarshalSigned(f.Data)) 979 m.xxx_TestFloat = uint8(md.TestFloat.UnmarshalUnsigned(f.Data)) 980 m.xxx_TestBoolEnum = IODebug_TestBoolEnum(md.TestBoolEnum.UnmarshalBool(f.Data)) 981 m.xxx_TestScaledEnum = IODebug_TestScaledEnum(md.TestScaledEnum.UnmarshalUnsigned(f.Data)) 982 return nil 983 } 984 985 type DBG interface { 986 sync.Locker 987 Tx() DBG_Tx 988 Rx() DBG_Rx 989 Run(ctx context.Context) error 990 } 991 992 type DBG_Rx interface { 993 http.Handler // for debugging 994 SensorSonars() DBG_Rx_SensorSonars 995 IODebug() DBG_Rx_IODebug 996 } 997 998 type DBG_Tx interface { 999 http.Handler // for debugging 1000 } 1001 1002 type DBG_Rx_SensorSonars interface { 1003 SensorSonarsReader 1004 ReceiveTime() time.Time 1005 SetAfterReceiveHook(h func(context.Context) error) 1006 } 1007 1008 type DBG_Rx_IODebug interface { 1009 IODebugReader 1010 ReceiveTime() time.Time 1011 SetAfterReceiveHook(h func(context.Context) error) 1012 } 1013 1014 type xxx_DBG struct { 1015 sync.Mutex // protects all node state 1016 network string 1017 address string 1018 rx xxx_DBG_Rx 1019 tx xxx_DBG_Tx 1020 } 1021 1022 var _ DBG = &xxx_DBG{} 1023 var _ canrunner.Node = &xxx_DBG{} 1024 1025 func NewDBG(network, address string) DBG { 1026 n := &xxx_DBG{network: network, address: address} 1027 n.rx.parentMutex = &n.Mutex 1028 n.tx.parentMutex = &n.Mutex 1029 n.rx.xxx_SensorSonars.init() 1030 n.rx.xxx_SensorSonars.Reset() 1031 n.rx.xxx_IODebug.init() 1032 n.rx.xxx_IODebug.Reset() 1033 return n 1034 } 1035 1036 func (n *xxx_DBG) Run(ctx context.Context) error { 1037 return canrunner.Run(ctx, n) 1038 } 1039 1040 func (n *xxx_DBG) Rx() DBG_Rx { 1041 return &n.rx 1042 } 1043 1044 func (n *xxx_DBG) Tx() DBG_Tx { 1045 return &n.tx 1046 } 1047 1048 type xxx_DBG_Rx struct { 1049 parentMutex *sync.Mutex 1050 xxx_SensorSonars xxx_DBG_Rx_SensorSonars 1051 xxx_IODebug xxx_DBG_Rx_IODebug 1052 } 1053 1054 var _ DBG_Rx = &xxx_DBG_Rx{} 1055 1056 func (rx *xxx_DBG_Rx) ServeHTTP(w http.ResponseWriter, r *http.Request) { 1057 rx.parentMutex.Lock() 1058 defer rx.parentMutex.Unlock() 1059 candebug.ServeMessagesHTTP(w, r, []generated.Message{ 1060 &rx.xxx_SensorSonars, 1061 &rx.xxx_IODebug, 1062 }) 1063 } 1064 1065 func (rx *xxx_DBG_Rx) SensorSonars() DBG_Rx_SensorSonars { 1066 return &rx.xxx_SensorSonars 1067 } 1068 1069 func (rx *xxx_DBG_Rx) IODebug() DBG_Rx_IODebug { 1070 return &rx.xxx_IODebug 1071 } 1072 1073 type xxx_DBG_Tx struct { 1074 parentMutex *sync.Mutex 1075 } 1076 1077 var _ DBG_Tx = &xxx_DBG_Tx{} 1078 1079 func (tx *xxx_DBG_Tx) ServeHTTP(w http.ResponseWriter, r *http.Request) { 1080 tx.parentMutex.Lock() 1081 defer tx.parentMutex.Unlock() 1082 candebug.ServeMessagesHTTP(w, r, []generated.Message{}) 1083 } 1084 1085 func (n *xxx_DBG) Descriptor() *descriptor.Node { 1086 return Nodes().DBG 1087 } 1088 1089 func (n *xxx_DBG) Connect() (net.Conn, error) { 1090 return socketcan.Dial(n.network, n.address) 1091 } 1092 1093 func (n *xxx_DBG) ReceivedMessage(id uint32) (canrunner.ReceivedMessage, bool) { 1094 switch id { 1095 case 200: 1096 return &n.rx.xxx_SensorSonars, true 1097 case 500: 1098 return &n.rx.xxx_IODebug, true 1099 default: 1100 return nil, false 1101 } 1102 } 1103 1104 func (n *xxx_DBG) TransmittedMessages() []canrunner.TransmittedMessage { 1105 return []canrunner.TransmittedMessage{} 1106 } 1107 1108 type xxx_DBG_Rx_SensorSonars struct { 1109 SensorSonars 1110 receiveTime time.Time 1111 afterReceiveHook func(context.Context) error 1112 } 1113 1114 func (m *xxx_DBG_Rx_SensorSonars) init() { 1115 m.afterReceiveHook = func(context.Context) error { return nil } 1116 } 1117 1118 func (m *xxx_DBG_Rx_SensorSonars) SetAfterReceiveHook(h func(context.Context) error) { 1119 m.afterReceiveHook = h 1120 } 1121 1122 func (m *xxx_DBG_Rx_SensorSonars) AfterReceiveHook() func(context.Context) error { 1123 return m.afterReceiveHook 1124 } 1125 1126 func (m *xxx_DBG_Rx_SensorSonars) ReceiveTime() time.Time { 1127 return m.receiveTime 1128 } 1129 1130 func (m *xxx_DBG_Rx_SensorSonars) SetReceiveTime(t time.Time) { 1131 m.receiveTime = t 1132 } 1133 1134 var _ canrunner.ReceivedMessage = &xxx_DBG_Rx_SensorSonars{} 1135 1136 type xxx_DBG_Rx_IODebug struct { 1137 IODebug 1138 receiveTime time.Time 1139 afterReceiveHook func(context.Context) error 1140 } 1141 1142 func (m *xxx_DBG_Rx_IODebug) init() { 1143 m.afterReceiveHook = func(context.Context) error { return nil } 1144 } 1145 1146 func (m *xxx_DBG_Rx_IODebug) SetAfterReceiveHook(h func(context.Context) error) { 1147 m.afterReceiveHook = h 1148 } 1149 1150 func (m *xxx_DBG_Rx_IODebug) AfterReceiveHook() func(context.Context) error { 1151 return m.afterReceiveHook 1152 } 1153 1154 func (m *xxx_DBG_Rx_IODebug) ReceiveTime() time.Time { 1155 return m.receiveTime 1156 } 1157 1158 func (m *xxx_DBG_Rx_IODebug) SetReceiveTime(t time.Time) { 1159 m.receiveTime = t 1160 } 1161 1162 var _ canrunner.ReceivedMessage = &xxx_DBG_Rx_IODebug{} 1163 1164 type DRIVER interface { 1165 sync.Locker 1166 Tx() DRIVER_Tx 1167 Rx() DRIVER_Rx 1168 Run(ctx context.Context) error 1169 } 1170 1171 type DRIVER_Rx interface { 1172 http.Handler // for debugging 1173 SensorSonars() DRIVER_Rx_SensorSonars 1174 MotorStatus() DRIVER_Rx_MotorStatus 1175 } 1176 1177 type DRIVER_Tx interface { 1178 http.Handler // for debugging 1179 DriverHeartbeat() DRIVER_Tx_DriverHeartbeat 1180 MotorCommand() DRIVER_Tx_MotorCommand 1181 } 1182 1183 type DRIVER_Rx_SensorSonars interface { 1184 SensorSonarsReader 1185 ReceiveTime() time.Time 1186 SetAfterReceiveHook(h func(context.Context) error) 1187 } 1188 1189 type DRIVER_Rx_MotorStatus interface { 1190 MotorStatusReader 1191 ReceiveTime() time.Time 1192 SetAfterReceiveHook(h func(context.Context) error) 1193 } 1194 1195 type DRIVER_Tx_DriverHeartbeat interface { 1196 DriverHeartbeatReader 1197 DriverHeartbeatWriter 1198 TransmitTime() time.Time 1199 Transmit(ctx context.Context) error 1200 SetBeforeTransmitHook(h func(context.Context) error) 1201 // SetCyclicTransmissionEnabled enables/disables cyclic transmission. 1202 SetCyclicTransmissionEnabled(bool) 1203 // IsCyclicTransmissionEnabled returns whether cyclic transmission is enabled/disabled. 1204 IsCyclicTransmissionEnabled() bool 1205 } 1206 1207 type DRIVER_Tx_MotorCommand interface { 1208 MotorCommandReader 1209 MotorCommandWriter 1210 TransmitTime() time.Time 1211 Transmit(ctx context.Context) error 1212 SetBeforeTransmitHook(h func(context.Context) error) 1213 // SetCyclicTransmissionEnabled enables/disables cyclic transmission. 1214 SetCyclicTransmissionEnabled(bool) 1215 // IsCyclicTransmissionEnabled returns whether cyclic transmission is enabled/disabled. 1216 IsCyclicTransmissionEnabled() bool 1217 } 1218 1219 type xxx_DRIVER struct { 1220 sync.Mutex // protects all node state 1221 network string 1222 address string 1223 rx xxx_DRIVER_Rx 1224 tx xxx_DRIVER_Tx 1225 } 1226 1227 var _ DRIVER = &xxx_DRIVER{} 1228 var _ canrunner.Node = &xxx_DRIVER{} 1229 1230 func NewDRIVER(network, address string) DRIVER { 1231 n := &xxx_DRIVER{network: network, address: address} 1232 n.rx.parentMutex = &n.Mutex 1233 n.tx.parentMutex = &n.Mutex 1234 n.rx.xxx_SensorSonars.init() 1235 n.rx.xxx_SensorSonars.Reset() 1236 n.rx.xxx_MotorStatus.init() 1237 n.rx.xxx_MotorStatus.Reset() 1238 n.tx.xxx_DriverHeartbeat.init() 1239 n.tx.xxx_DriverHeartbeat.Reset() 1240 n.tx.xxx_MotorCommand.init() 1241 n.tx.xxx_MotorCommand.Reset() 1242 return n 1243 } 1244 1245 func (n *xxx_DRIVER) Run(ctx context.Context) error { 1246 return canrunner.Run(ctx, n) 1247 } 1248 1249 func (n *xxx_DRIVER) Rx() DRIVER_Rx { 1250 return &n.rx 1251 } 1252 1253 func (n *xxx_DRIVER) Tx() DRIVER_Tx { 1254 return &n.tx 1255 } 1256 1257 type xxx_DRIVER_Rx struct { 1258 parentMutex *sync.Mutex 1259 xxx_SensorSonars xxx_DRIVER_Rx_SensorSonars 1260 xxx_MotorStatus xxx_DRIVER_Rx_MotorStatus 1261 } 1262 1263 var _ DRIVER_Rx = &xxx_DRIVER_Rx{} 1264 1265 func (rx *xxx_DRIVER_Rx) ServeHTTP(w http.ResponseWriter, r *http.Request) { 1266 rx.parentMutex.Lock() 1267 defer rx.parentMutex.Unlock() 1268 candebug.ServeMessagesHTTP(w, r, []generated.Message{ 1269 &rx.xxx_SensorSonars, 1270 &rx.xxx_MotorStatus, 1271 }) 1272 } 1273 1274 func (rx *xxx_DRIVER_Rx) SensorSonars() DRIVER_Rx_SensorSonars { 1275 return &rx.xxx_SensorSonars 1276 } 1277 1278 func (rx *xxx_DRIVER_Rx) MotorStatus() DRIVER_Rx_MotorStatus { 1279 return &rx.xxx_MotorStatus 1280 } 1281 1282 type xxx_DRIVER_Tx struct { 1283 parentMutex *sync.Mutex 1284 xxx_DriverHeartbeat xxx_DRIVER_Tx_DriverHeartbeat 1285 xxx_MotorCommand xxx_DRIVER_Tx_MotorCommand 1286 } 1287 1288 var _ DRIVER_Tx = &xxx_DRIVER_Tx{} 1289 1290 func (tx *xxx_DRIVER_Tx) ServeHTTP(w http.ResponseWriter, r *http.Request) { 1291 tx.parentMutex.Lock() 1292 defer tx.parentMutex.Unlock() 1293 candebug.ServeMessagesHTTP(w, r, []generated.Message{ 1294 &tx.xxx_DriverHeartbeat, 1295 &tx.xxx_MotorCommand, 1296 }) 1297 } 1298 1299 func (tx *xxx_DRIVER_Tx) DriverHeartbeat() DRIVER_Tx_DriverHeartbeat { 1300 return &tx.xxx_DriverHeartbeat 1301 } 1302 1303 func (tx *xxx_DRIVER_Tx) MotorCommand() DRIVER_Tx_MotorCommand { 1304 return &tx.xxx_MotorCommand 1305 } 1306 1307 func (n *xxx_DRIVER) Descriptor() *descriptor.Node { 1308 return Nodes().DRIVER 1309 } 1310 1311 func (n *xxx_DRIVER) Connect() (net.Conn, error) { 1312 return socketcan.Dial(n.network, n.address) 1313 } 1314 1315 func (n *xxx_DRIVER) ReceivedMessage(id uint32) (canrunner.ReceivedMessage, bool) { 1316 switch id { 1317 case 200: 1318 return &n.rx.xxx_SensorSonars, true 1319 case 400: 1320 return &n.rx.xxx_MotorStatus, true 1321 default: 1322 return nil, false 1323 } 1324 } 1325 1326 func (n *xxx_DRIVER) TransmittedMessages() []canrunner.TransmittedMessage { 1327 return []canrunner.TransmittedMessage{ 1328 &n.tx.xxx_DriverHeartbeat, 1329 &n.tx.xxx_MotorCommand, 1330 } 1331 } 1332 1333 type xxx_DRIVER_Rx_SensorSonars struct { 1334 SensorSonars 1335 receiveTime time.Time 1336 afterReceiveHook func(context.Context) error 1337 } 1338 1339 func (m *xxx_DRIVER_Rx_SensorSonars) init() { 1340 m.afterReceiveHook = func(context.Context) error { return nil } 1341 } 1342 1343 func (m *xxx_DRIVER_Rx_SensorSonars) SetAfterReceiveHook(h func(context.Context) error) { 1344 m.afterReceiveHook = h 1345 } 1346 1347 func (m *xxx_DRIVER_Rx_SensorSonars) AfterReceiveHook() func(context.Context) error { 1348 return m.afterReceiveHook 1349 } 1350 1351 func (m *xxx_DRIVER_Rx_SensorSonars) ReceiveTime() time.Time { 1352 return m.receiveTime 1353 } 1354 1355 func (m *xxx_DRIVER_Rx_SensorSonars) SetReceiveTime(t time.Time) { 1356 m.receiveTime = t 1357 } 1358 1359 var _ canrunner.ReceivedMessage = &xxx_DRIVER_Rx_SensorSonars{} 1360 1361 type xxx_DRIVER_Rx_MotorStatus struct { 1362 MotorStatus 1363 receiveTime time.Time 1364 afterReceiveHook func(context.Context) error 1365 } 1366 1367 func (m *xxx_DRIVER_Rx_MotorStatus) init() { 1368 m.afterReceiveHook = func(context.Context) error { return nil } 1369 } 1370 1371 func (m *xxx_DRIVER_Rx_MotorStatus) SetAfterReceiveHook(h func(context.Context) error) { 1372 m.afterReceiveHook = h 1373 } 1374 1375 func (m *xxx_DRIVER_Rx_MotorStatus) AfterReceiveHook() func(context.Context) error { 1376 return m.afterReceiveHook 1377 } 1378 1379 func (m *xxx_DRIVER_Rx_MotorStatus) ReceiveTime() time.Time { 1380 return m.receiveTime 1381 } 1382 1383 func (m *xxx_DRIVER_Rx_MotorStatus) SetReceiveTime(t time.Time) { 1384 m.receiveTime = t 1385 } 1386 1387 var _ canrunner.ReceivedMessage = &xxx_DRIVER_Rx_MotorStatus{} 1388 1389 type xxx_DRIVER_Tx_DriverHeartbeat struct { 1390 DriverHeartbeat 1391 transmitTime time.Time 1392 beforeTransmitHook func(context.Context) error 1393 isCyclicEnabled bool 1394 wakeUpChan chan struct{} 1395 transmitEventChan chan struct{} 1396 } 1397 1398 var _ DRIVER_Tx_DriverHeartbeat = &xxx_DRIVER_Tx_DriverHeartbeat{} 1399 var _ canrunner.TransmittedMessage = &xxx_DRIVER_Tx_DriverHeartbeat{} 1400 1401 func (m *xxx_DRIVER_Tx_DriverHeartbeat) init() { 1402 m.beforeTransmitHook = func(context.Context) error { return nil } 1403 m.wakeUpChan = make(chan struct{}, 1) 1404 m.transmitEventChan = make(chan struct{}) 1405 } 1406 1407 func (m *xxx_DRIVER_Tx_DriverHeartbeat) SetBeforeTransmitHook(h func(context.Context) error) { 1408 m.beforeTransmitHook = h 1409 } 1410 1411 func (m *xxx_DRIVER_Tx_DriverHeartbeat) BeforeTransmitHook() func(context.Context) error { 1412 return m.beforeTransmitHook 1413 } 1414 1415 func (m *xxx_DRIVER_Tx_DriverHeartbeat) TransmitTime() time.Time { 1416 return m.transmitTime 1417 } 1418 1419 func (m *xxx_DRIVER_Tx_DriverHeartbeat) SetTransmitTime(t time.Time) { 1420 m.transmitTime = t 1421 } 1422 1423 func (m *xxx_DRIVER_Tx_DriverHeartbeat) IsCyclicTransmissionEnabled() bool { 1424 return m.isCyclicEnabled 1425 } 1426 1427 func (m *xxx_DRIVER_Tx_DriverHeartbeat) SetCyclicTransmissionEnabled(b bool) { 1428 m.isCyclicEnabled = b 1429 select { 1430 case m.wakeUpChan <- struct{}{}: 1431 default: 1432 } 1433 } 1434 1435 func (m *xxx_DRIVER_Tx_DriverHeartbeat) WakeUpChan() <-chan struct{} { 1436 return m.wakeUpChan 1437 } 1438 1439 func (m *xxx_DRIVER_Tx_DriverHeartbeat) Transmit(ctx context.Context) error { 1440 select { 1441 case m.transmitEventChan <- struct{}{}: 1442 return nil 1443 case <-ctx.Done(): 1444 return fmt.Errorf("event-triggered transmit of DriverHeartbeat: %w", ctx.Err()) 1445 } 1446 } 1447 1448 func (m *xxx_DRIVER_Tx_DriverHeartbeat) TransmitEventChan() <-chan struct{} { 1449 return m.transmitEventChan 1450 } 1451 1452 var _ canrunner.TransmittedMessage = &xxx_DRIVER_Tx_DriverHeartbeat{} 1453 1454 type xxx_DRIVER_Tx_MotorCommand struct { 1455 MotorCommand 1456 transmitTime time.Time 1457 beforeTransmitHook func(context.Context) error 1458 isCyclicEnabled bool 1459 wakeUpChan chan struct{} 1460 transmitEventChan chan struct{} 1461 } 1462 1463 var _ DRIVER_Tx_MotorCommand = &xxx_DRIVER_Tx_MotorCommand{} 1464 var _ canrunner.TransmittedMessage = &xxx_DRIVER_Tx_MotorCommand{} 1465 1466 func (m *xxx_DRIVER_Tx_MotorCommand) init() { 1467 m.beforeTransmitHook = func(context.Context) error { return nil } 1468 m.wakeUpChan = make(chan struct{}, 1) 1469 m.transmitEventChan = make(chan struct{}) 1470 } 1471 1472 func (m *xxx_DRIVER_Tx_MotorCommand) SetBeforeTransmitHook(h func(context.Context) error) { 1473 m.beforeTransmitHook = h 1474 } 1475 1476 func (m *xxx_DRIVER_Tx_MotorCommand) BeforeTransmitHook() func(context.Context) error { 1477 return m.beforeTransmitHook 1478 } 1479 1480 func (m *xxx_DRIVER_Tx_MotorCommand) TransmitTime() time.Time { 1481 return m.transmitTime 1482 } 1483 1484 func (m *xxx_DRIVER_Tx_MotorCommand) SetTransmitTime(t time.Time) { 1485 m.transmitTime = t 1486 } 1487 1488 func (m *xxx_DRIVER_Tx_MotorCommand) IsCyclicTransmissionEnabled() bool { 1489 return m.isCyclicEnabled 1490 } 1491 1492 func (m *xxx_DRIVER_Tx_MotorCommand) SetCyclicTransmissionEnabled(b bool) { 1493 m.isCyclicEnabled = b 1494 select { 1495 case m.wakeUpChan <- struct{}{}: 1496 default: 1497 } 1498 } 1499 1500 func (m *xxx_DRIVER_Tx_MotorCommand) WakeUpChan() <-chan struct{} { 1501 return m.wakeUpChan 1502 } 1503 1504 func (m *xxx_DRIVER_Tx_MotorCommand) Transmit(ctx context.Context) error { 1505 select { 1506 case m.transmitEventChan <- struct{}{}: 1507 return nil 1508 case <-ctx.Done(): 1509 return fmt.Errorf("event-triggered transmit of MotorCommand: %w", ctx.Err()) 1510 } 1511 } 1512 1513 func (m *xxx_DRIVER_Tx_MotorCommand) TransmitEventChan() <-chan struct{} { 1514 return m.transmitEventChan 1515 } 1516 1517 var _ canrunner.TransmittedMessage = &xxx_DRIVER_Tx_MotorCommand{} 1518 1519 type IO interface { 1520 sync.Locker 1521 Tx() IO_Tx 1522 Rx() IO_Rx 1523 Run(ctx context.Context) error 1524 } 1525 1526 type IO_Rx interface { 1527 http.Handler // for debugging 1528 SensorSonars() IO_Rx_SensorSonars 1529 MotorStatus() IO_Rx_MotorStatus 1530 } 1531 1532 type IO_Tx interface { 1533 http.Handler // for debugging 1534 IODebug() IO_Tx_IODebug 1535 } 1536 1537 type IO_Rx_SensorSonars interface { 1538 SensorSonarsReader 1539 ReceiveTime() time.Time 1540 SetAfterReceiveHook(h func(context.Context) error) 1541 } 1542 1543 type IO_Rx_MotorStatus interface { 1544 MotorStatusReader 1545 ReceiveTime() time.Time 1546 SetAfterReceiveHook(h func(context.Context) error) 1547 } 1548 1549 type IO_Tx_IODebug interface { 1550 IODebugReader 1551 IODebugWriter 1552 TransmitTime() time.Time 1553 Transmit(ctx context.Context) error 1554 SetBeforeTransmitHook(h func(context.Context) error) 1555 } 1556 1557 type xxx_IO struct { 1558 sync.Mutex // protects all node state 1559 network string 1560 address string 1561 rx xxx_IO_Rx 1562 tx xxx_IO_Tx 1563 } 1564 1565 var _ IO = &xxx_IO{} 1566 var _ canrunner.Node = &xxx_IO{} 1567 1568 func NewIO(network, address string) IO { 1569 n := &xxx_IO{network: network, address: address} 1570 n.rx.parentMutex = &n.Mutex 1571 n.tx.parentMutex = &n.Mutex 1572 n.rx.xxx_SensorSonars.init() 1573 n.rx.xxx_SensorSonars.Reset() 1574 n.rx.xxx_MotorStatus.init() 1575 n.rx.xxx_MotorStatus.Reset() 1576 n.tx.xxx_IODebug.init() 1577 n.tx.xxx_IODebug.Reset() 1578 return n 1579 } 1580 1581 func (n *xxx_IO) Run(ctx context.Context) error { 1582 return canrunner.Run(ctx, n) 1583 } 1584 1585 func (n *xxx_IO) Rx() IO_Rx { 1586 return &n.rx 1587 } 1588 1589 func (n *xxx_IO) Tx() IO_Tx { 1590 return &n.tx 1591 } 1592 1593 type xxx_IO_Rx struct { 1594 parentMutex *sync.Mutex 1595 xxx_SensorSonars xxx_IO_Rx_SensorSonars 1596 xxx_MotorStatus xxx_IO_Rx_MotorStatus 1597 } 1598 1599 var _ IO_Rx = &xxx_IO_Rx{} 1600 1601 func (rx *xxx_IO_Rx) ServeHTTP(w http.ResponseWriter, r *http.Request) { 1602 rx.parentMutex.Lock() 1603 defer rx.parentMutex.Unlock() 1604 candebug.ServeMessagesHTTP(w, r, []generated.Message{ 1605 &rx.xxx_SensorSonars, 1606 &rx.xxx_MotorStatus, 1607 }) 1608 } 1609 1610 func (rx *xxx_IO_Rx) SensorSonars() IO_Rx_SensorSonars { 1611 return &rx.xxx_SensorSonars 1612 } 1613 1614 func (rx *xxx_IO_Rx) MotorStatus() IO_Rx_MotorStatus { 1615 return &rx.xxx_MotorStatus 1616 } 1617 1618 type xxx_IO_Tx struct { 1619 parentMutex *sync.Mutex 1620 xxx_IODebug xxx_IO_Tx_IODebug 1621 } 1622 1623 var _ IO_Tx = &xxx_IO_Tx{} 1624 1625 func (tx *xxx_IO_Tx) ServeHTTP(w http.ResponseWriter, r *http.Request) { 1626 tx.parentMutex.Lock() 1627 defer tx.parentMutex.Unlock() 1628 candebug.ServeMessagesHTTP(w, r, []generated.Message{ 1629 &tx.xxx_IODebug, 1630 }) 1631 } 1632 1633 func (tx *xxx_IO_Tx) IODebug() IO_Tx_IODebug { 1634 return &tx.xxx_IODebug 1635 } 1636 1637 func (n *xxx_IO) Descriptor() *descriptor.Node { 1638 return Nodes().IO 1639 } 1640 1641 func (n *xxx_IO) Connect() (net.Conn, error) { 1642 return socketcan.Dial(n.network, n.address) 1643 } 1644 1645 func (n *xxx_IO) ReceivedMessage(id uint32) (canrunner.ReceivedMessage, bool) { 1646 switch id { 1647 case 200: 1648 return &n.rx.xxx_SensorSonars, true 1649 case 400: 1650 return &n.rx.xxx_MotorStatus, true 1651 default: 1652 return nil, false 1653 } 1654 } 1655 1656 func (n *xxx_IO) TransmittedMessages() []canrunner.TransmittedMessage { 1657 return []canrunner.TransmittedMessage{ 1658 &n.tx.xxx_IODebug, 1659 } 1660 } 1661 1662 type xxx_IO_Rx_SensorSonars struct { 1663 SensorSonars 1664 receiveTime time.Time 1665 afterReceiveHook func(context.Context) error 1666 } 1667 1668 func (m *xxx_IO_Rx_SensorSonars) init() { 1669 m.afterReceiveHook = func(context.Context) error { return nil } 1670 } 1671 1672 func (m *xxx_IO_Rx_SensorSonars) SetAfterReceiveHook(h func(context.Context) error) { 1673 m.afterReceiveHook = h 1674 } 1675 1676 func (m *xxx_IO_Rx_SensorSonars) AfterReceiveHook() func(context.Context) error { 1677 return m.afterReceiveHook 1678 } 1679 1680 func (m *xxx_IO_Rx_SensorSonars) ReceiveTime() time.Time { 1681 return m.receiveTime 1682 } 1683 1684 func (m *xxx_IO_Rx_SensorSonars) SetReceiveTime(t time.Time) { 1685 m.receiveTime = t 1686 } 1687 1688 var _ canrunner.ReceivedMessage = &xxx_IO_Rx_SensorSonars{} 1689 1690 type xxx_IO_Rx_MotorStatus struct { 1691 MotorStatus 1692 receiveTime time.Time 1693 afterReceiveHook func(context.Context) error 1694 } 1695 1696 func (m *xxx_IO_Rx_MotorStatus) init() { 1697 m.afterReceiveHook = func(context.Context) error { return nil } 1698 } 1699 1700 func (m *xxx_IO_Rx_MotorStatus) SetAfterReceiveHook(h func(context.Context) error) { 1701 m.afterReceiveHook = h 1702 } 1703 1704 func (m *xxx_IO_Rx_MotorStatus) AfterReceiveHook() func(context.Context) error { 1705 return m.afterReceiveHook 1706 } 1707 1708 func (m *xxx_IO_Rx_MotorStatus) ReceiveTime() time.Time { 1709 return m.receiveTime 1710 } 1711 1712 func (m *xxx_IO_Rx_MotorStatus) SetReceiveTime(t time.Time) { 1713 m.receiveTime = t 1714 } 1715 1716 var _ canrunner.ReceivedMessage = &xxx_IO_Rx_MotorStatus{} 1717 1718 type xxx_IO_Tx_IODebug struct { 1719 IODebug 1720 transmitTime time.Time 1721 beforeTransmitHook func(context.Context) error 1722 isCyclicEnabled bool 1723 wakeUpChan chan struct{} 1724 transmitEventChan chan struct{} 1725 } 1726 1727 var _ IO_Tx_IODebug = &xxx_IO_Tx_IODebug{} 1728 var _ canrunner.TransmittedMessage = &xxx_IO_Tx_IODebug{} 1729 1730 func (m *xxx_IO_Tx_IODebug) init() { 1731 m.beforeTransmitHook = func(context.Context) error { return nil } 1732 m.wakeUpChan = make(chan struct{}, 1) 1733 m.transmitEventChan = make(chan struct{}) 1734 } 1735 1736 func (m *xxx_IO_Tx_IODebug) SetBeforeTransmitHook(h func(context.Context) error) { 1737 m.beforeTransmitHook = h 1738 } 1739 1740 func (m *xxx_IO_Tx_IODebug) BeforeTransmitHook() func(context.Context) error { 1741 return m.beforeTransmitHook 1742 } 1743 1744 func (m *xxx_IO_Tx_IODebug) TransmitTime() time.Time { 1745 return m.transmitTime 1746 } 1747 1748 func (m *xxx_IO_Tx_IODebug) SetTransmitTime(t time.Time) { 1749 m.transmitTime = t 1750 } 1751 1752 func (m *xxx_IO_Tx_IODebug) IsCyclicTransmissionEnabled() bool { 1753 return m.isCyclicEnabled 1754 } 1755 1756 func (m *xxx_IO_Tx_IODebug) SetCyclicTransmissionEnabled(b bool) { 1757 m.isCyclicEnabled = b 1758 select { 1759 case m.wakeUpChan <- struct{}{}: 1760 default: 1761 } 1762 } 1763 1764 func (m *xxx_IO_Tx_IODebug) WakeUpChan() <-chan struct{} { 1765 return m.wakeUpChan 1766 } 1767 1768 func (m *xxx_IO_Tx_IODebug) Transmit(ctx context.Context) error { 1769 select { 1770 case m.transmitEventChan <- struct{}{}: 1771 return nil 1772 case <-ctx.Done(): 1773 return fmt.Errorf("event-triggered transmit of IODebug: %w", ctx.Err()) 1774 } 1775 } 1776 1777 func (m *xxx_IO_Tx_IODebug) TransmitEventChan() <-chan struct{} { 1778 return m.transmitEventChan 1779 } 1780 1781 var _ canrunner.TransmittedMessage = &xxx_IO_Tx_IODebug{} 1782 1783 type MOTOR interface { 1784 sync.Locker 1785 Tx() MOTOR_Tx 1786 Rx() MOTOR_Rx 1787 Run(ctx context.Context) error 1788 } 1789 1790 type MOTOR_Rx interface { 1791 http.Handler // for debugging 1792 DriverHeartbeat() MOTOR_Rx_DriverHeartbeat 1793 MotorCommand() MOTOR_Rx_MotorCommand 1794 } 1795 1796 type MOTOR_Tx interface { 1797 http.Handler // for debugging 1798 MotorStatus() MOTOR_Tx_MotorStatus 1799 } 1800 1801 type MOTOR_Rx_DriverHeartbeat interface { 1802 DriverHeartbeatReader 1803 ReceiveTime() time.Time 1804 SetAfterReceiveHook(h func(context.Context) error) 1805 } 1806 1807 type MOTOR_Rx_MotorCommand interface { 1808 MotorCommandReader 1809 ReceiveTime() time.Time 1810 SetAfterReceiveHook(h func(context.Context) error) 1811 } 1812 1813 type MOTOR_Tx_MotorStatus interface { 1814 MotorStatusReader 1815 MotorStatusWriter 1816 TransmitTime() time.Time 1817 Transmit(ctx context.Context) error 1818 SetBeforeTransmitHook(h func(context.Context) error) 1819 // SetCyclicTransmissionEnabled enables/disables cyclic transmission. 1820 SetCyclicTransmissionEnabled(bool) 1821 // IsCyclicTransmissionEnabled returns whether cyclic transmission is enabled/disabled. 1822 IsCyclicTransmissionEnabled() bool 1823 } 1824 1825 type xxx_MOTOR struct { 1826 sync.Mutex // protects all node state 1827 network string 1828 address string 1829 rx xxx_MOTOR_Rx 1830 tx xxx_MOTOR_Tx 1831 } 1832 1833 var _ MOTOR = &xxx_MOTOR{} 1834 var _ canrunner.Node = &xxx_MOTOR{} 1835 1836 func NewMOTOR(network, address string) MOTOR { 1837 n := &xxx_MOTOR{network: network, address: address} 1838 n.rx.parentMutex = &n.Mutex 1839 n.tx.parentMutex = &n.Mutex 1840 n.rx.xxx_DriverHeartbeat.init() 1841 n.rx.xxx_DriverHeartbeat.Reset() 1842 n.rx.xxx_MotorCommand.init() 1843 n.rx.xxx_MotorCommand.Reset() 1844 n.tx.xxx_MotorStatus.init() 1845 n.tx.xxx_MotorStatus.Reset() 1846 return n 1847 } 1848 1849 func (n *xxx_MOTOR) Run(ctx context.Context) error { 1850 return canrunner.Run(ctx, n) 1851 } 1852 1853 func (n *xxx_MOTOR) Rx() MOTOR_Rx { 1854 return &n.rx 1855 } 1856 1857 func (n *xxx_MOTOR) Tx() MOTOR_Tx { 1858 return &n.tx 1859 } 1860 1861 type xxx_MOTOR_Rx struct { 1862 parentMutex *sync.Mutex 1863 xxx_DriverHeartbeat xxx_MOTOR_Rx_DriverHeartbeat 1864 xxx_MotorCommand xxx_MOTOR_Rx_MotorCommand 1865 } 1866 1867 var _ MOTOR_Rx = &xxx_MOTOR_Rx{} 1868 1869 func (rx *xxx_MOTOR_Rx) ServeHTTP(w http.ResponseWriter, r *http.Request) { 1870 rx.parentMutex.Lock() 1871 defer rx.parentMutex.Unlock() 1872 candebug.ServeMessagesHTTP(w, r, []generated.Message{ 1873 &rx.xxx_DriverHeartbeat, 1874 &rx.xxx_MotorCommand, 1875 }) 1876 } 1877 1878 func (rx *xxx_MOTOR_Rx) DriverHeartbeat() MOTOR_Rx_DriverHeartbeat { 1879 return &rx.xxx_DriverHeartbeat 1880 } 1881 1882 func (rx *xxx_MOTOR_Rx) MotorCommand() MOTOR_Rx_MotorCommand { 1883 return &rx.xxx_MotorCommand 1884 } 1885 1886 type xxx_MOTOR_Tx struct { 1887 parentMutex *sync.Mutex 1888 xxx_MotorStatus xxx_MOTOR_Tx_MotorStatus 1889 } 1890 1891 var _ MOTOR_Tx = &xxx_MOTOR_Tx{} 1892 1893 func (tx *xxx_MOTOR_Tx) ServeHTTP(w http.ResponseWriter, r *http.Request) { 1894 tx.parentMutex.Lock() 1895 defer tx.parentMutex.Unlock() 1896 candebug.ServeMessagesHTTP(w, r, []generated.Message{ 1897 &tx.xxx_MotorStatus, 1898 }) 1899 } 1900 1901 func (tx *xxx_MOTOR_Tx) MotorStatus() MOTOR_Tx_MotorStatus { 1902 return &tx.xxx_MotorStatus 1903 } 1904 1905 func (n *xxx_MOTOR) Descriptor() *descriptor.Node { 1906 return Nodes().MOTOR 1907 } 1908 1909 func (n *xxx_MOTOR) Connect() (net.Conn, error) { 1910 return socketcan.Dial(n.network, n.address) 1911 } 1912 1913 func (n *xxx_MOTOR) ReceivedMessage(id uint32) (canrunner.ReceivedMessage, bool) { 1914 switch id { 1915 case 100: 1916 return &n.rx.xxx_DriverHeartbeat, true 1917 case 101: 1918 return &n.rx.xxx_MotorCommand, true 1919 default: 1920 return nil, false 1921 } 1922 } 1923 1924 func (n *xxx_MOTOR) TransmittedMessages() []canrunner.TransmittedMessage { 1925 return []canrunner.TransmittedMessage{ 1926 &n.tx.xxx_MotorStatus, 1927 } 1928 } 1929 1930 type xxx_MOTOR_Rx_DriverHeartbeat struct { 1931 DriverHeartbeat 1932 receiveTime time.Time 1933 afterReceiveHook func(context.Context) error 1934 } 1935 1936 func (m *xxx_MOTOR_Rx_DriverHeartbeat) init() { 1937 m.afterReceiveHook = func(context.Context) error { return nil } 1938 } 1939 1940 func (m *xxx_MOTOR_Rx_DriverHeartbeat) SetAfterReceiveHook(h func(context.Context) error) { 1941 m.afterReceiveHook = h 1942 } 1943 1944 func (m *xxx_MOTOR_Rx_DriverHeartbeat) AfterReceiveHook() func(context.Context) error { 1945 return m.afterReceiveHook 1946 } 1947 1948 func (m *xxx_MOTOR_Rx_DriverHeartbeat) ReceiveTime() time.Time { 1949 return m.receiveTime 1950 } 1951 1952 func (m *xxx_MOTOR_Rx_DriverHeartbeat) SetReceiveTime(t time.Time) { 1953 m.receiveTime = t 1954 } 1955 1956 var _ canrunner.ReceivedMessage = &xxx_MOTOR_Rx_DriverHeartbeat{} 1957 1958 type xxx_MOTOR_Rx_MotorCommand struct { 1959 MotorCommand 1960 receiveTime time.Time 1961 afterReceiveHook func(context.Context) error 1962 } 1963 1964 func (m *xxx_MOTOR_Rx_MotorCommand) init() { 1965 m.afterReceiveHook = func(context.Context) error { return nil } 1966 } 1967 1968 func (m *xxx_MOTOR_Rx_MotorCommand) SetAfterReceiveHook(h func(context.Context) error) { 1969 m.afterReceiveHook = h 1970 } 1971 1972 func (m *xxx_MOTOR_Rx_MotorCommand) AfterReceiveHook() func(context.Context) error { 1973 return m.afterReceiveHook 1974 } 1975 1976 func (m *xxx_MOTOR_Rx_MotorCommand) ReceiveTime() time.Time { 1977 return m.receiveTime 1978 } 1979 1980 func (m *xxx_MOTOR_Rx_MotorCommand) SetReceiveTime(t time.Time) { 1981 m.receiveTime = t 1982 } 1983 1984 var _ canrunner.ReceivedMessage = &xxx_MOTOR_Rx_MotorCommand{} 1985 1986 type xxx_MOTOR_Tx_MotorStatus struct { 1987 MotorStatus 1988 transmitTime time.Time 1989 beforeTransmitHook func(context.Context) error 1990 isCyclicEnabled bool 1991 wakeUpChan chan struct{} 1992 transmitEventChan chan struct{} 1993 } 1994 1995 var _ MOTOR_Tx_MotorStatus = &xxx_MOTOR_Tx_MotorStatus{} 1996 var _ canrunner.TransmittedMessage = &xxx_MOTOR_Tx_MotorStatus{} 1997 1998 func (m *xxx_MOTOR_Tx_MotorStatus) init() { 1999 m.beforeTransmitHook = func(context.Context) error { return nil } 2000 m.wakeUpChan = make(chan struct{}, 1) 2001 m.transmitEventChan = make(chan struct{}) 2002 } 2003 2004 func (m *xxx_MOTOR_Tx_MotorStatus) SetBeforeTransmitHook(h func(context.Context) error) { 2005 m.beforeTransmitHook = h 2006 } 2007 2008 func (m *xxx_MOTOR_Tx_MotorStatus) BeforeTransmitHook() func(context.Context) error { 2009 return m.beforeTransmitHook 2010 } 2011 2012 func (m *xxx_MOTOR_Tx_MotorStatus) TransmitTime() time.Time { 2013 return m.transmitTime 2014 } 2015 2016 func (m *xxx_MOTOR_Tx_MotorStatus) SetTransmitTime(t time.Time) { 2017 m.transmitTime = t 2018 } 2019 2020 func (m *xxx_MOTOR_Tx_MotorStatus) IsCyclicTransmissionEnabled() bool { 2021 return m.isCyclicEnabled 2022 } 2023 2024 func (m *xxx_MOTOR_Tx_MotorStatus) SetCyclicTransmissionEnabled(b bool) { 2025 m.isCyclicEnabled = b 2026 select { 2027 case m.wakeUpChan <- struct{}{}: 2028 default: 2029 } 2030 } 2031 2032 func (m *xxx_MOTOR_Tx_MotorStatus) WakeUpChan() <-chan struct{} { 2033 return m.wakeUpChan 2034 } 2035 2036 func (m *xxx_MOTOR_Tx_MotorStatus) Transmit(ctx context.Context) error { 2037 select { 2038 case m.transmitEventChan <- struct{}{}: 2039 return nil 2040 case <-ctx.Done(): 2041 return fmt.Errorf("event-triggered transmit of MotorStatus: %w", ctx.Err()) 2042 } 2043 } 2044 2045 func (m *xxx_MOTOR_Tx_MotorStatus) TransmitEventChan() <-chan struct{} { 2046 return m.transmitEventChan 2047 } 2048 2049 var _ canrunner.TransmittedMessage = &xxx_MOTOR_Tx_MotorStatus{} 2050 2051 type SENSOR interface { 2052 sync.Locker 2053 Tx() SENSOR_Tx 2054 Rx() SENSOR_Rx 2055 Run(ctx context.Context) error 2056 } 2057 2058 type SENSOR_Rx interface { 2059 http.Handler // for debugging 2060 DriverHeartbeat() SENSOR_Rx_DriverHeartbeat 2061 } 2062 2063 type SENSOR_Tx interface { 2064 http.Handler // for debugging 2065 SensorSonars() SENSOR_Tx_SensorSonars 2066 } 2067 2068 type SENSOR_Rx_DriverHeartbeat interface { 2069 DriverHeartbeatReader 2070 ReceiveTime() time.Time 2071 SetAfterReceiveHook(h func(context.Context) error) 2072 } 2073 2074 type SENSOR_Tx_SensorSonars interface { 2075 SensorSonarsReader 2076 SensorSonarsWriter 2077 TransmitTime() time.Time 2078 Transmit(ctx context.Context) error 2079 SetBeforeTransmitHook(h func(context.Context) error) 2080 // SetCyclicTransmissionEnabled enables/disables cyclic transmission. 2081 SetCyclicTransmissionEnabled(bool) 2082 // IsCyclicTransmissionEnabled returns whether cyclic transmission is enabled/disabled. 2083 IsCyclicTransmissionEnabled() bool 2084 } 2085 2086 type xxx_SENSOR struct { 2087 sync.Mutex // protects all node state 2088 network string 2089 address string 2090 rx xxx_SENSOR_Rx 2091 tx xxx_SENSOR_Tx 2092 } 2093 2094 var _ SENSOR = &xxx_SENSOR{} 2095 var _ canrunner.Node = &xxx_SENSOR{} 2096 2097 func NewSENSOR(network, address string) SENSOR { 2098 n := &xxx_SENSOR{network: network, address: address} 2099 n.rx.parentMutex = &n.Mutex 2100 n.tx.parentMutex = &n.Mutex 2101 n.rx.xxx_DriverHeartbeat.init() 2102 n.rx.xxx_DriverHeartbeat.Reset() 2103 n.tx.xxx_SensorSonars.init() 2104 n.tx.xxx_SensorSonars.Reset() 2105 return n 2106 } 2107 2108 func (n *xxx_SENSOR) Run(ctx context.Context) error { 2109 return canrunner.Run(ctx, n) 2110 } 2111 2112 func (n *xxx_SENSOR) Rx() SENSOR_Rx { 2113 return &n.rx 2114 } 2115 2116 func (n *xxx_SENSOR) Tx() SENSOR_Tx { 2117 return &n.tx 2118 } 2119 2120 type xxx_SENSOR_Rx struct { 2121 parentMutex *sync.Mutex 2122 xxx_DriverHeartbeat xxx_SENSOR_Rx_DriverHeartbeat 2123 } 2124 2125 var _ SENSOR_Rx = &xxx_SENSOR_Rx{} 2126 2127 func (rx *xxx_SENSOR_Rx) ServeHTTP(w http.ResponseWriter, r *http.Request) { 2128 rx.parentMutex.Lock() 2129 defer rx.parentMutex.Unlock() 2130 candebug.ServeMessagesHTTP(w, r, []generated.Message{ 2131 &rx.xxx_DriverHeartbeat, 2132 }) 2133 } 2134 2135 func (rx *xxx_SENSOR_Rx) DriverHeartbeat() SENSOR_Rx_DriverHeartbeat { 2136 return &rx.xxx_DriverHeartbeat 2137 } 2138 2139 type xxx_SENSOR_Tx struct { 2140 parentMutex *sync.Mutex 2141 xxx_SensorSonars xxx_SENSOR_Tx_SensorSonars 2142 } 2143 2144 var _ SENSOR_Tx = &xxx_SENSOR_Tx{} 2145 2146 func (tx *xxx_SENSOR_Tx) ServeHTTP(w http.ResponseWriter, r *http.Request) { 2147 tx.parentMutex.Lock() 2148 defer tx.parentMutex.Unlock() 2149 candebug.ServeMessagesHTTP(w, r, []generated.Message{ 2150 &tx.xxx_SensorSonars, 2151 }) 2152 } 2153 2154 func (tx *xxx_SENSOR_Tx) SensorSonars() SENSOR_Tx_SensorSonars { 2155 return &tx.xxx_SensorSonars 2156 } 2157 2158 func (n *xxx_SENSOR) Descriptor() *descriptor.Node { 2159 return Nodes().SENSOR 2160 } 2161 2162 func (n *xxx_SENSOR) Connect() (net.Conn, error) { 2163 return socketcan.Dial(n.network, n.address) 2164 } 2165 2166 func (n *xxx_SENSOR) ReceivedMessage(id uint32) (canrunner.ReceivedMessage, bool) { 2167 switch id { 2168 case 100: 2169 return &n.rx.xxx_DriverHeartbeat, true 2170 default: 2171 return nil, false 2172 } 2173 } 2174 2175 func (n *xxx_SENSOR) TransmittedMessages() []canrunner.TransmittedMessage { 2176 return []canrunner.TransmittedMessage{ 2177 &n.tx.xxx_SensorSonars, 2178 } 2179 } 2180 2181 type xxx_SENSOR_Rx_DriverHeartbeat struct { 2182 DriverHeartbeat 2183 receiveTime time.Time 2184 afterReceiveHook func(context.Context) error 2185 } 2186 2187 func (m *xxx_SENSOR_Rx_DriverHeartbeat) init() { 2188 m.afterReceiveHook = func(context.Context) error { return nil } 2189 } 2190 2191 func (m *xxx_SENSOR_Rx_DriverHeartbeat) SetAfterReceiveHook(h func(context.Context) error) { 2192 m.afterReceiveHook = h 2193 } 2194 2195 func (m *xxx_SENSOR_Rx_DriverHeartbeat) AfterReceiveHook() func(context.Context) error { 2196 return m.afterReceiveHook 2197 } 2198 2199 func (m *xxx_SENSOR_Rx_DriverHeartbeat) ReceiveTime() time.Time { 2200 return m.receiveTime 2201 } 2202 2203 func (m *xxx_SENSOR_Rx_DriverHeartbeat) SetReceiveTime(t time.Time) { 2204 m.receiveTime = t 2205 } 2206 2207 var _ canrunner.ReceivedMessage = &xxx_SENSOR_Rx_DriverHeartbeat{} 2208 2209 type xxx_SENSOR_Tx_SensorSonars struct { 2210 SensorSonars 2211 transmitTime time.Time 2212 beforeTransmitHook func(context.Context) error 2213 isCyclicEnabled bool 2214 wakeUpChan chan struct{} 2215 transmitEventChan chan struct{} 2216 } 2217 2218 var _ SENSOR_Tx_SensorSonars = &xxx_SENSOR_Tx_SensorSonars{} 2219 var _ canrunner.TransmittedMessage = &xxx_SENSOR_Tx_SensorSonars{} 2220 2221 func (m *xxx_SENSOR_Tx_SensorSonars) init() { 2222 m.beforeTransmitHook = func(context.Context) error { return nil } 2223 m.wakeUpChan = make(chan struct{}, 1) 2224 m.transmitEventChan = make(chan struct{}) 2225 } 2226 2227 func (m *xxx_SENSOR_Tx_SensorSonars) SetBeforeTransmitHook(h func(context.Context) error) { 2228 m.beforeTransmitHook = h 2229 } 2230 2231 func (m *xxx_SENSOR_Tx_SensorSonars) BeforeTransmitHook() func(context.Context) error { 2232 return m.beforeTransmitHook 2233 } 2234 2235 func (m *xxx_SENSOR_Tx_SensorSonars) TransmitTime() time.Time { 2236 return m.transmitTime 2237 } 2238 2239 func (m *xxx_SENSOR_Tx_SensorSonars) SetTransmitTime(t time.Time) { 2240 m.transmitTime = t 2241 } 2242 2243 func (m *xxx_SENSOR_Tx_SensorSonars) IsCyclicTransmissionEnabled() bool { 2244 return m.isCyclicEnabled 2245 } 2246 2247 func (m *xxx_SENSOR_Tx_SensorSonars) SetCyclicTransmissionEnabled(b bool) { 2248 m.isCyclicEnabled = b 2249 select { 2250 case m.wakeUpChan <- struct{}{}: 2251 default: 2252 } 2253 } 2254 2255 func (m *xxx_SENSOR_Tx_SensorSonars) WakeUpChan() <-chan struct{} { 2256 return m.wakeUpChan 2257 } 2258 2259 func (m *xxx_SENSOR_Tx_SensorSonars) Transmit(ctx context.Context) error { 2260 select { 2261 case m.transmitEventChan <- struct{}{}: 2262 return nil 2263 case <-ctx.Done(): 2264 return fmt.Errorf("event-triggered transmit of SensorSonars: %w", ctx.Err()) 2265 } 2266 } 2267 2268 func (m *xxx_SENSOR_Tx_SensorSonars) TransmitEventChan() <-chan struct{} { 2269 return m.transmitEventChan 2270 } 2271 2272 var _ canrunner.TransmittedMessage = &xxx_SENSOR_Tx_SensorSonars{} 2273 2274 // Nodes returns the example node descriptors. 2275 func Nodes() *NodesDescriptor { 2276 return nd 2277 } 2278 2279 // NodesDescriptor contains all example node descriptors. 2280 type NodesDescriptor struct { 2281 DBG *descriptor.Node 2282 DRIVER *descriptor.Node 2283 IO *descriptor.Node 2284 MOTOR *descriptor.Node 2285 SENSOR *descriptor.Node 2286 } 2287 2288 // Messages returns the example message descriptors. 2289 func Messages() *MessagesDescriptor { 2290 return md 2291 } 2292 2293 // MessagesDescriptor contains all example message descriptors. 2294 type MessagesDescriptor struct { 2295 EmptyMessage *EmptyMessageDescriptor 2296 DriverHeartbeat *DriverHeartbeatDescriptor 2297 MotorCommand *MotorCommandDescriptor 2298 SensorSonars *SensorSonarsDescriptor 2299 MotorStatus *MotorStatusDescriptor 2300 IODebug *IODebugDescriptor 2301 } 2302 2303 // UnmarshalFrame unmarshals the provided example CAN frame. 2304 func (md *MessagesDescriptor) UnmarshalFrame(f can.Frame) (generated.Message, error) { 2305 switch f.ID { 2306 case md.EmptyMessage.ID: 2307 var msg EmptyMessage 2308 if err := msg.UnmarshalFrame(f); err != nil { 2309 return nil, fmt.Errorf("unmarshal example frame: %w", err) 2310 } 2311 return &msg, nil 2312 case md.DriverHeartbeat.ID: 2313 var msg DriverHeartbeat 2314 if err := msg.UnmarshalFrame(f); err != nil { 2315 return nil, fmt.Errorf("unmarshal example frame: %w", err) 2316 } 2317 return &msg, nil 2318 case md.MotorCommand.ID: 2319 var msg MotorCommand 2320 if err := msg.UnmarshalFrame(f); err != nil { 2321 return nil, fmt.Errorf("unmarshal example frame: %w", err) 2322 } 2323 return &msg, nil 2324 case md.SensorSonars.ID: 2325 var msg SensorSonars 2326 if err := msg.UnmarshalFrame(f); err != nil { 2327 return nil, fmt.Errorf("unmarshal example frame: %w", err) 2328 } 2329 return &msg, nil 2330 case md.MotorStatus.ID: 2331 var msg MotorStatus 2332 if err := msg.UnmarshalFrame(f); err != nil { 2333 return nil, fmt.Errorf("unmarshal example frame: %w", err) 2334 } 2335 return &msg, nil 2336 case md.IODebug.ID: 2337 var msg IODebug 2338 if err := msg.UnmarshalFrame(f); err != nil { 2339 return nil, fmt.Errorf("unmarshal example frame: %w", err) 2340 } 2341 return &msg, nil 2342 default: 2343 return nil, fmt.Errorf("unmarshal example frame: ID not in database: %d", f.ID) 2344 } 2345 } 2346 2347 type EmptyMessageDescriptor struct { 2348 *descriptor.Message 2349 } 2350 2351 type DriverHeartbeatDescriptor struct { 2352 *descriptor.Message 2353 Command *descriptor.Signal 2354 } 2355 2356 type MotorCommandDescriptor struct { 2357 *descriptor.Message 2358 Steer *descriptor.Signal 2359 Drive *descriptor.Signal 2360 } 2361 2362 type SensorSonarsDescriptor struct { 2363 *descriptor.Message 2364 Mux *descriptor.Signal 2365 ErrCount *descriptor.Signal 2366 Left *descriptor.Signal 2367 NoFiltLeft *descriptor.Signal 2368 Middle *descriptor.Signal 2369 NoFiltMiddle *descriptor.Signal 2370 Right *descriptor.Signal 2371 NoFiltRight *descriptor.Signal 2372 Rear *descriptor.Signal 2373 NoFiltRear *descriptor.Signal 2374 } 2375 2376 type MotorStatusDescriptor struct { 2377 *descriptor.Message 2378 WheelError *descriptor.Signal 2379 SpeedKph *descriptor.Signal 2380 } 2381 2382 type IODebugDescriptor struct { 2383 *descriptor.Message 2384 TestUnsigned *descriptor.Signal 2385 TestEnum *descriptor.Signal 2386 TestSigned *descriptor.Signal 2387 TestFloat *descriptor.Signal 2388 TestBoolEnum *descriptor.Signal 2389 TestScaledEnum *descriptor.Signal 2390 } 2391 2392 // Database returns the example database descriptor. 2393 func (md *MessagesDescriptor) Database() *descriptor.Database { 2394 return d 2395 } 2396 2397 var nd = &NodesDescriptor{ 2398 DBG: d.Nodes[0], 2399 DRIVER: d.Nodes[1], 2400 IO: d.Nodes[2], 2401 MOTOR: d.Nodes[3], 2402 SENSOR: d.Nodes[4], 2403 } 2404 2405 var md = &MessagesDescriptor{ 2406 EmptyMessage: &EmptyMessageDescriptor{ 2407 Message: d.Messages[0], 2408 }, 2409 DriverHeartbeat: &DriverHeartbeatDescriptor{ 2410 Message: d.Messages[1], 2411 Command: d.Messages[1].Signals[0], 2412 }, 2413 MotorCommand: &MotorCommandDescriptor{ 2414 Message: d.Messages[2], 2415 Steer: d.Messages[2].Signals[0], 2416 Drive: d.Messages[2].Signals[1], 2417 }, 2418 SensorSonars: &SensorSonarsDescriptor{ 2419 Message: d.Messages[3], 2420 Mux: d.Messages[3].Signals[0], 2421 ErrCount: d.Messages[3].Signals[1], 2422 Left: d.Messages[3].Signals[2], 2423 NoFiltLeft: d.Messages[3].Signals[3], 2424 Middle: d.Messages[3].Signals[4], 2425 NoFiltMiddle: d.Messages[3].Signals[5], 2426 Right: d.Messages[3].Signals[6], 2427 NoFiltRight: d.Messages[3].Signals[7], 2428 Rear: d.Messages[3].Signals[8], 2429 NoFiltRear: d.Messages[3].Signals[9], 2430 }, 2431 MotorStatus: &MotorStatusDescriptor{ 2432 Message: d.Messages[4], 2433 WheelError: d.Messages[4].Signals[0], 2434 SpeedKph: d.Messages[4].Signals[1], 2435 }, 2436 IODebug: &IODebugDescriptor{ 2437 Message: d.Messages[5], 2438 TestUnsigned: d.Messages[5].Signals[0], 2439 TestEnum: d.Messages[5].Signals[1], 2440 TestSigned: d.Messages[5].Signals[2], 2441 TestFloat: d.Messages[5].Signals[3], 2442 TestBoolEnum: d.Messages[5].Signals[4], 2443 TestScaledEnum: d.Messages[5].Signals[5], 2444 }, 2445 } 2446 2447 var d = (*descriptor.Database)(&descriptor.Database{ 2448 SourceFile: (string)("testdata/dbc/example/example.dbc"), 2449 Version: (string)(""), 2450 Messages: ([]*descriptor.Message)([]*descriptor.Message{ 2451 (*descriptor.Message)(&descriptor.Message{ 2452 Name: (string)("EmptyMessage"), 2453 ID: (uint32)(1), 2454 IsExtended: (bool)(false), 2455 Length: (uint8)(0), 2456 SendType: (descriptor.SendType)(0), 2457 Description: (string)(""), 2458 Signals: ([]*descriptor.Signal)(nil), 2459 SenderNode: (string)("DBG"), 2460 CycleTime: (time.Duration)(0), 2461 DelayTime: (time.Duration)(0), 2462 }), 2463 (*descriptor.Message)(&descriptor.Message{ 2464 Name: (string)("DriverHeartbeat"), 2465 ID: (uint32)(100), 2466 IsExtended: (bool)(false), 2467 Length: (uint8)(1), 2468 SendType: (descriptor.SendType)(1), 2469 Description: (string)("Sync message used to synchronize the controllers"), 2470 Signals: ([]*descriptor.Signal)([]*descriptor.Signal{ 2471 (*descriptor.Signal)(&descriptor.Signal{ 2472 Name: (string)("Command"), 2473 Start: (uint8)(0), 2474 Length: (uint8)(8), 2475 IsBigEndian: (bool)(false), 2476 IsSigned: (bool)(false), 2477 IsMultiplexer: (bool)(false), 2478 IsMultiplexed: (bool)(false), 2479 MultiplexerValue: (uint)(0), 2480 Offset: (float64)(0), 2481 Scale: (float64)(1), 2482 Min: (float64)(0), 2483 Max: (float64)(0), 2484 Unit: (string)(""), 2485 Description: (string)(""), 2486 ValueDescriptions: ([]*descriptor.ValueDescription)([]*descriptor.ValueDescription{ 2487 (*descriptor.ValueDescription)(&descriptor.ValueDescription{ 2488 Value: (int64)(0), 2489 Description: (string)("None"), 2490 }), 2491 (*descriptor.ValueDescription)(&descriptor.ValueDescription{ 2492 Value: (int64)(1), 2493 Description: (string)("Sync"), 2494 }), 2495 (*descriptor.ValueDescription)(&descriptor.ValueDescription{ 2496 Value: (int64)(2), 2497 Description: (string)("Reboot"), 2498 }), 2499 (*descriptor.ValueDescription)(&descriptor.ValueDescription{ 2500 Value: (int64)(3), 2501 Description: (string)("Headlights On"), 2502 }), 2503 }), 2504 ReceiverNodes: ([]string)([]string{ 2505 (string)("SENSOR"), 2506 (string)("MOTOR"), 2507 }), 2508 DefaultValue: (int)(0), 2509 }), 2510 }), 2511 SenderNode: (string)("DRIVER"), 2512 CycleTime: (time.Duration)(1000000000), 2513 DelayTime: (time.Duration)(0), 2514 }), 2515 (*descriptor.Message)(&descriptor.Message{ 2516 Name: (string)("MotorCommand"), 2517 ID: (uint32)(101), 2518 IsExtended: (bool)(false), 2519 Length: (uint8)(1), 2520 SendType: (descriptor.SendType)(1), 2521 Description: (string)(""), 2522 Signals: ([]*descriptor.Signal)([]*descriptor.Signal{ 2523 (*descriptor.Signal)(&descriptor.Signal{ 2524 Name: (string)("Steer"), 2525 Start: (uint8)(0), 2526 Length: (uint8)(4), 2527 IsBigEndian: (bool)(false), 2528 IsSigned: (bool)(true), 2529 IsMultiplexer: (bool)(false), 2530 IsMultiplexed: (bool)(false), 2531 MultiplexerValue: (uint)(0), 2532 Offset: (float64)(-5), 2533 Scale: (float64)(1), 2534 Min: (float64)(-5), 2535 Max: (float64)(5), 2536 Unit: (string)(""), 2537 Description: (string)(""), 2538 ValueDescriptions: ([]*descriptor.ValueDescription)(nil), 2539 ReceiverNodes: ([]string)([]string{ 2540 (string)("MOTOR"), 2541 }), 2542 DefaultValue: (int)(0), 2543 }), 2544 (*descriptor.Signal)(&descriptor.Signal{ 2545 Name: (string)("Drive"), 2546 Start: (uint8)(4), 2547 Length: (uint8)(4), 2548 IsBigEndian: (bool)(false), 2549 IsSigned: (bool)(false), 2550 IsMultiplexer: (bool)(false), 2551 IsMultiplexed: (bool)(false), 2552 MultiplexerValue: (uint)(0), 2553 Offset: (float64)(0), 2554 Scale: (float64)(1), 2555 Min: (float64)(0), 2556 Max: (float64)(9), 2557 Unit: (string)(""), 2558 Description: (string)(""), 2559 ValueDescriptions: ([]*descriptor.ValueDescription)(nil), 2560 ReceiverNodes: ([]string)([]string{ 2561 (string)("MOTOR"), 2562 }), 2563 DefaultValue: (int)(0), 2564 }), 2565 }), 2566 SenderNode: (string)("DRIVER"), 2567 CycleTime: (time.Duration)(100000000), 2568 DelayTime: (time.Duration)(0), 2569 }), 2570 (*descriptor.Message)(&descriptor.Message{ 2571 Name: (string)("SensorSonars"), 2572 ID: (uint32)(200), 2573 IsExtended: (bool)(false), 2574 Length: (uint8)(8), 2575 SendType: (descriptor.SendType)(1), 2576 Description: (string)(""), 2577 Signals: ([]*descriptor.Signal)([]*descriptor.Signal{ 2578 (*descriptor.Signal)(&descriptor.Signal{ 2579 Name: (string)("Mux"), 2580 Start: (uint8)(0), 2581 Length: (uint8)(4), 2582 IsBigEndian: (bool)(false), 2583 IsSigned: (bool)(false), 2584 IsMultiplexer: (bool)(true), 2585 IsMultiplexed: (bool)(false), 2586 MultiplexerValue: (uint)(0), 2587 Offset: (float64)(0), 2588 Scale: (float64)(1), 2589 Min: (float64)(0), 2590 Max: (float64)(0), 2591 Unit: (string)(""), 2592 Description: (string)(""), 2593 ValueDescriptions: ([]*descriptor.ValueDescription)(nil), 2594 ReceiverNodes: ([]string)([]string{ 2595 (string)("DRIVER"), 2596 (string)("IO"), 2597 }), 2598 DefaultValue: (int)(0), 2599 }), 2600 (*descriptor.Signal)(&descriptor.Signal{ 2601 Name: (string)("ErrCount"), 2602 Start: (uint8)(4), 2603 Length: (uint8)(12), 2604 IsBigEndian: (bool)(false), 2605 IsSigned: (bool)(false), 2606 IsMultiplexer: (bool)(false), 2607 IsMultiplexed: (bool)(false), 2608 MultiplexerValue: (uint)(0), 2609 Offset: (float64)(0), 2610 Scale: (float64)(1), 2611 Min: (float64)(0), 2612 Max: (float64)(0), 2613 Unit: (string)(""), 2614 Description: (string)(""), 2615 ValueDescriptions: ([]*descriptor.ValueDescription)(nil), 2616 ReceiverNodes: ([]string)([]string{ 2617 (string)("DRIVER"), 2618 (string)("IO"), 2619 }), 2620 DefaultValue: (int)(0), 2621 }), 2622 (*descriptor.Signal)(&descriptor.Signal{ 2623 Name: (string)("Left"), 2624 Start: (uint8)(16), 2625 Length: (uint8)(12), 2626 IsBigEndian: (bool)(false), 2627 IsSigned: (bool)(false), 2628 IsMultiplexer: (bool)(false), 2629 IsMultiplexed: (bool)(true), 2630 MultiplexerValue: (uint)(0), 2631 Offset: (float64)(0), 2632 Scale: (float64)(0.1), 2633 Min: (float64)(0), 2634 Max: (float64)(0), 2635 Unit: (string)(""), 2636 Description: (string)(""), 2637 ValueDescriptions: ([]*descriptor.ValueDescription)(nil), 2638 ReceiverNodes: ([]string)([]string{ 2639 (string)("DRIVER"), 2640 (string)("IO"), 2641 }), 2642 DefaultValue: (int)(0), 2643 }), 2644 (*descriptor.Signal)(&descriptor.Signal{ 2645 Name: (string)("NoFiltLeft"), 2646 Start: (uint8)(16), 2647 Length: (uint8)(12), 2648 IsBigEndian: (bool)(false), 2649 IsSigned: (bool)(false), 2650 IsMultiplexer: (bool)(false), 2651 IsMultiplexed: (bool)(true), 2652 MultiplexerValue: (uint)(1), 2653 Offset: (float64)(0), 2654 Scale: (float64)(0.1), 2655 Min: (float64)(0), 2656 Max: (float64)(0), 2657 Unit: (string)(""), 2658 Description: (string)(""), 2659 ValueDescriptions: ([]*descriptor.ValueDescription)(nil), 2660 ReceiverNodes: ([]string)([]string{ 2661 (string)("DBG"), 2662 }), 2663 DefaultValue: (int)(0), 2664 }), 2665 (*descriptor.Signal)(&descriptor.Signal{ 2666 Name: (string)("Middle"), 2667 Start: (uint8)(28), 2668 Length: (uint8)(12), 2669 IsBigEndian: (bool)(false), 2670 IsSigned: (bool)(false), 2671 IsMultiplexer: (bool)(false), 2672 IsMultiplexed: (bool)(true), 2673 MultiplexerValue: (uint)(0), 2674 Offset: (float64)(0), 2675 Scale: (float64)(0.1), 2676 Min: (float64)(0), 2677 Max: (float64)(0), 2678 Unit: (string)(""), 2679 Description: (string)(""), 2680 ValueDescriptions: ([]*descriptor.ValueDescription)(nil), 2681 ReceiverNodes: ([]string)([]string{ 2682 (string)("DRIVER"), 2683 (string)("IO"), 2684 }), 2685 DefaultValue: (int)(0), 2686 }), 2687 (*descriptor.Signal)(&descriptor.Signal{ 2688 Name: (string)("NoFiltMiddle"), 2689 Start: (uint8)(28), 2690 Length: (uint8)(12), 2691 IsBigEndian: (bool)(false), 2692 IsSigned: (bool)(false), 2693 IsMultiplexer: (bool)(false), 2694 IsMultiplexed: (bool)(true), 2695 MultiplexerValue: (uint)(1), 2696 Offset: (float64)(0), 2697 Scale: (float64)(0.1), 2698 Min: (float64)(0), 2699 Max: (float64)(0), 2700 Unit: (string)(""), 2701 Description: (string)(""), 2702 ValueDescriptions: ([]*descriptor.ValueDescription)(nil), 2703 ReceiverNodes: ([]string)([]string{ 2704 (string)("DBG"), 2705 }), 2706 DefaultValue: (int)(0), 2707 }), 2708 (*descriptor.Signal)(&descriptor.Signal{ 2709 Name: (string)("Right"), 2710 Start: (uint8)(40), 2711 Length: (uint8)(12), 2712 IsBigEndian: (bool)(false), 2713 IsSigned: (bool)(false), 2714 IsMultiplexer: (bool)(false), 2715 IsMultiplexed: (bool)(true), 2716 MultiplexerValue: (uint)(0), 2717 Offset: (float64)(0), 2718 Scale: (float64)(0.1), 2719 Min: (float64)(0), 2720 Max: (float64)(0), 2721 Unit: (string)(""), 2722 Description: (string)(""), 2723 ValueDescriptions: ([]*descriptor.ValueDescription)(nil), 2724 ReceiverNodes: ([]string)([]string{ 2725 (string)("DRIVER"), 2726 (string)("IO"), 2727 }), 2728 DefaultValue: (int)(0), 2729 }), 2730 (*descriptor.Signal)(&descriptor.Signal{ 2731 Name: (string)("NoFiltRight"), 2732 Start: (uint8)(40), 2733 Length: (uint8)(12), 2734 IsBigEndian: (bool)(false), 2735 IsSigned: (bool)(false), 2736 IsMultiplexer: (bool)(false), 2737 IsMultiplexed: (bool)(true), 2738 MultiplexerValue: (uint)(1), 2739 Offset: (float64)(0), 2740 Scale: (float64)(0.1), 2741 Min: (float64)(0), 2742 Max: (float64)(0), 2743 Unit: (string)(""), 2744 Description: (string)(""), 2745 ValueDescriptions: ([]*descriptor.ValueDescription)(nil), 2746 ReceiverNodes: ([]string)([]string{ 2747 (string)("DBG"), 2748 }), 2749 DefaultValue: (int)(0), 2750 }), 2751 (*descriptor.Signal)(&descriptor.Signal{ 2752 Name: (string)("Rear"), 2753 Start: (uint8)(52), 2754 Length: (uint8)(12), 2755 IsBigEndian: (bool)(false), 2756 IsSigned: (bool)(false), 2757 IsMultiplexer: (bool)(false), 2758 IsMultiplexed: (bool)(true), 2759 MultiplexerValue: (uint)(0), 2760 Offset: (float64)(0), 2761 Scale: (float64)(0.1), 2762 Min: (float64)(0), 2763 Max: (float64)(0), 2764 Unit: (string)(""), 2765 Description: (string)(""), 2766 ValueDescriptions: ([]*descriptor.ValueDescription)(nil), 2767 ReceiverNodes: ([]string)([]string{ 2768 (string)("DRIVER"), 2769 (string)("IO"), 2770 }), 2771 DefaultValue: (int)(0), 2772 }), 2773 (*descriptor.Signal)(&descriptor.Signal{ 2774 Name: (string)("NoFiltRear"), 2775 Start: (uint8)(52), 2776 Length: (uint8)(12), 2777 IsBigEndian: (bool)(false), 2778 IsSigned: (bool)(false), 2779 IsMultiplexer: (bool)(false), 2780 IsMultiplexed: (bool)(true), 2781 MultiplexerValue: (uint)(1), 2782 Offset: (float64)(0), 2783 Scale: (float64)(0.1), 2784 Min: (float64)(0), 2785 Max: (float64)(0), 2786 Unit: (string)(""), 2787 Description: (string)(""), 2788 ValueDescriptions: ([]*descriptor.ValueDescription)(nil), 2789 ReceiverNodes: ([]string)([]string{ 2790 (string)("DBG"), 2791 }), 2792 DefaultValue: (int)(0), 2793 }), 2794 }), 2795 SenderNode: (string)("SENSOR"), 2796 CycleTime: (time.Duration)(100000000), 2797 DelayTime: (time.Duration)(0), 2798 }), 2799 (*descriptor.Message)(&descriptor.Message{ 2800 Name: (string)("MotorStatus"), 2801 ID: (uint32)(400), 2802 IsExtended: (bool)(false), 2803 Length: (uint8)(3), 2804 SendType: (descriptor.SendType)(1), 2805 Description: (string)(""), 2806 Signals: ([]*descriptor.Signal)([]*descriptor.Signal{ 2807 (*descriptor.Signal)(&descriptor.Signal{ 2808 Name: (string)("WheelError"), 2809 Start: (uint8)(0), 2810 Length: (uint8)(1), 2811 IsBigEndian: (bool)(false), 2812 IsSigned: (bool)(false), 2813 IsMultiplexer: (bool)(false), 2814 IsMultiplexed: (bool)(false), 2815 MultiplexerValue: (uint)(0), 2816 Offset: (float64)(0), 2817 Scale: (float64)(1), 2818 Min: (float64)(0), 2819 Max: (float64)(0), 2820 Unit: (string)(""), 2821 Description: (string)(""), 2822 ValueDescriptions: ([]*descriptor.ValueDescription)(nil), 2823 ReceiverNodes: ([]string)([]string{ 2824 (string)("DRIVER"), 2825 (string)("IO"), 2826 }), 2827 DefaultValue: (int)(0), 2828 }), 2829 (*descriptor.Signal)(&descriptor.Signal{ 2830 Name: (string)("SpeedKph"), 2831 Start: (uint8)(8), 2832 Length: (uint8)(16), 2833 IsBigEndian: (bool)(false), 2834 IsSigned: (bool)(false), 2835 IsMultiplexer: (bool)(false), 2836 IsMultiplexed: (bool)(false), 2837 MultiplexerValue: (uint)(0), 2838 Offset: (float64)(0), 2839 Scale: (float64)(0.001), 2840 Min: (float64)(0), 2841 Max: (float64)(0), 2842 Unit: (string)("km/h"), 2843 Description: (string)(""), 2844 ValueDescriptions: ([]*descriptor.ValueDescription)(nil), 2845 ReceiverNodes: ([]string)([]string{ 2846 (string)("DRIVER"), 2847 (string)("IO"), 2848 }), 2849 DefaultValue: (int)(0), 2850 }), 2851 }), 2852 SenderNode: (string)("MOTOR"), 2853 CycleTime: (time.Duration)(100000000), 2854 DelayTime: (time.Duration)(0), 2855 }), 2856 (*descriptor.Message)(&descriptor.Message{ 2857 Name: (string)("IODebug"), 2858 ID: (uint32)(500), 2859 IsExtended: (bool)(false), 2860 Length: (uint8)(6), 2861 SendType: (descriptor.SendType)(2), 2862 Description: (string)(""), 2863 Signals: ([]*descriptor.Signal)([]*descriptor.Signal{ 2864 (*descriptor.Signal)(&descriptor.Signal{ 2865 Name: (string)("TestUnsigned"), 2866 Start: (uint8)(0), 2867 Length: (uint8)(8), 2868 IsBigEndian: (bool)(false), 2869 IsSigned: (bool)(false), 2870 IsMultiplexer: (bool)(false), 2871 IsMultiplexed: (bool)(false), 2872 MultiplexerValue: (uint)(0), 2873 Offset: (float64)(0), 2874 Scale: (float64)(1), 2875 Min: (float64)(0), 2876 Max: (float64)(0), 2877 Unit: (string)(""), 2878 Description: (string)(""), 2879 ValueDescriptions: ([]*descriptor.ValueDescription)(nil), 2880 ReceiverNodes: ([]string)([]string{ 2881 (string)("DBG"), 2882 }), 2883 DefaultValue: (int)(0), 2884 }), 2885 (*descriptor.Signal)(&descriptor.Signal{ 2886 Name: (string)("TestEnum"), 2887 Start: (uint8)(8), 2888 Length: (uint8)(6), 2889 IsBigEndian: (bool)(false), 2890 IsSigned: (bool)(false), 2891 IsMultiplexer: (bool)(false), 2892 IsMultiplexed: (bool)(false), 2893 MultiplexerValue: (uint)(0), 2894 Offset: (float64)(0), 2895 Scale: (float64)(1), 2896 Min: (float64)(0), 2897 Max: (float64)(0), 2898 Unit: (string)(""), 2899 Description: (string)(""), 2900 ValueDescriptions: ([]*descriptor.ValueDescription)([]*descriptor.ValueDescription{ 2901 (*descriptor.ValueDescription)(&descriptor.ValueDescription{ 2902 Value: (int64)(1), 2903 Description: (string)("One"), 2904 }), 2905 (*descriptor.ValueDescription)(&descriptor.ValueDescription{ 2906 Value: (int64)(2), 2907 Description: (string)("Two"), 2908 }), 2909 }), 2910 ReceiverNodes: ([]string)([]string{ 2911 (string)("DBG"), 2912 }), 2913 DefaultValue: (int)(2), 2914 }), 2915 (*descriptor.Signal)(&descriptor.Signal{ 2916 Name: (string)("TestSigned"), 2917 Start: (uint8)(16), 2918 Length: (uint8)(8), 2919 IsBigEndian: (bool)(false), 2920 IsSigned: (bool)(true), 2921 IsMultiplexer: (bool)(false), 2922 IsMultiplexed: (bool)(false), 2923 MultiplexerValue: (uint)(0), 2924 Offset: (float64)(0), 2925 Scale: (float64)(1), 2926 Min: (float64)(0), 2927 Max: (float64)(0), 2928 Unit: (string)(""), 2929 Description: (string)(""), 2930 ValueDescriptions: ([]*descriptor.ValueDescription)(nil), 2931 ReceiverNodes: ([]string)([]string{ 2932 (string)("DBG"), 2933 }), 2934 DefaultValue: (int)(0), 2935 }), 2936 (*descriptor.Signal)(&descriptor.Signal{ 2937 Name: (string)("TestFloat"), 2938 Start: (uint8)(24), 2939 Length: (uint8)(8), 2940 IsBigEndian: (bool)(false), 2941 IsSigned: (bool)(false), 2942 IsMultiplexer: (bool)(false), 2943 IsMultiplexed: (bool)(false), 2944 MultiplexerValue: (uint)(0), 2945 Offset: (float64)(0), 2946 Scale: (float64)(0.5), 2947 Min: (float64)(0), 2948 Max: (float64)(0), 2949 Unit: (string)(""), 2950 Description: (string)(""), 2951 ValueDescriptions: ([]*descriptor.ValueDescription)(nil), 2952 ReceiverNodes: ([]string)([]string{ 2953 (string)("DBG"), 2954 }), 2955 DefaultValue: (int)(0), 2956 }), 2957 (*descriptor.Signal)(&descriptor.Signal{ 2958 Name: (string)("TestBoolEnum"), 2959 Start: (uint8)(32), 2960 Length: (uint8)(1), 2961 IsBigEndian: (bool)(false), 2962 IsSigned: (bool)(false), 2963 IsMultiplexer: (bool)(false), 2964 IsMultiplexed: (bool)(false), 2965 MultiplexerValue: (uint)(0), 2966 Offset: (float64)(0), 2967 Scale: (float64)(1), 2968 Min: (float64)(0), 2969 Max: (float64)(0), 2970 Unit: (string)(""), 2971 Description: (string)(""), 2972 ValueDescriptions: ([]*descriptor.ValueDescription)([]*descriptor.ValueDescription{ 2973 (*descriptor.ValueDescription)(&descriptor.ValueDescription{ 2974 Value: (int64)(0), 2975 Description: (string)("Zero"), 2976 }), 2977 (*descriptor.ValueDescription)(&descriptor.ValueDescription{ 2978 Value: (int64)(1), 2979 Description: (string)("One"), 2980 }), 2981 }), 2982 ReceiverNodes: ([]string)([]string{ 2983 (string)("DBG"), 2984 }), 2985 DefaultValue: (int)(0), 2986 }), 2987 (*descriptor.Signal)(&descriptor.Signal{ 2988 Name: (string)("TestScaledEnum"), 2989 Start: (uint8)(40), 2990 Length: (uint8)(2), 2991 IsBigEndian: (bool)(false), 2992 IsSigned: (bool)(false), 2993 IsMultiplexer: (bool)(false), 2994 IsMultiplexed: (bool)(false), 2995 MultiplexerValue: (uint)(0), 2996 Offset: (float64)(0), 2997 Scale: (float64)(2), 2998 Min: (float64)(0), 2999 Max: (float64)(6), 3000 Unit: (string)(""), 3001 Description: (string)(""), 3002 ValueDescriptions: ([]*descriptor.ValueDescription)([]*descriptor.ValueDescription{ 3003 (*descriptor.ValueDescription)(&descriptor.ValueDescription{ 3004 Value: (int64)(0), 3005 Description: (string)("Zero"), 3006 }), 3007 (*descriptor.ValueDescription)(&descriptor.ValueDescription{ 3008 Value: (int64)(1), 3009 Description: (string)("Two"), 3010 }), 3011 (*descriptor.ValueDescription)(&descriptor.ValueDescription{ 3012 Value: (int64)(2), 3013 Description: (string)("Four"), 3014 }), 3015 (*descriptor.ValueDescription)(&descriptor.ValueDescription{ 3016 Value: (int64)(3), 3017 Description: (string)("Six"), 3018 }), 3019 }), 3020 ReceiverNodes: ([]string)([]string{ 3021 (string)("DBG"), 3022 }), 3023 DefaultValue: (int)(0), 3024 }), 3025 }), 3026 SenderNode: (string)("IO"), 3027 CycleTime: (time.Duration)(0), 3028 DelayTime: (time.Duration)(0), 3029 }), 3030 }), 3031 Nodes: ([]*descriptor.Node)([]*descriptor.Node{ 3032 (*descriptor.Node)(&descriptor.Node{ 3033 Name: (string)("DBG"), 3034 Description: (string)(""), 3035 }), 3036 (*descriptor.Node)(&descriptor.Node{ 3037 Name: (string)("DRIVER"), 3038 Description: (string)("The driver controller driving the car"), 3039 }), 3040 (*descriptor.Node)(&descriptor.Node{ 3041 Name: (string)("IO"), 3042 Description: (string)(""), 3043 }), 3044 (*descriptor.Node)(&descriptor.Node{ 3045 Name: (string)("MOTOR"), 3046 Description: (string)("The motor controller of the car"), 3047 }), 3048 (*descriptor.Node)(&descriptor.Node{ 3049 Name: (string)("SENSOR"), 3050 Description: (string)("The sensor controller of the car"), 3051 }), 3052 }), 3053 })