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