Exemplo n.º 1
0
 private static void sendPIDT(ICANBus CANBus, byte receiver, MotorBoardData MBD)
 {
     if (MBD != null)
     {
         UtilCan.SetP(CANBus, true, 0x2, receiver, MBD.P, 0);
         UtilCan.SetI(CANBus, true, 0x2, receiver, MBD.I, 0);
         UtilCan.SetD(CANBus, true, 0x2, receiver, MBD.D, 0);
         UtilCan.SetTicksPerRev(CANBus, true, 0x2, receiver, MBD.TicksPerRev);
         Log.Output(Log.Severity.INFO, Log.Source.HARDWAREIO,
                    "MotorBoard with CAN ID " + receiver + " set: Model=" + MBD.Model + " P=" + MBD.P + " I=" + MBD.I + " D=" + MBD.D);
     }
 }
Exemplo n.º 2
0
 private static void sendPIDT(ICANBus CANBus, byte receiver, MotorBoardData MBD)
 {
     if (MBD == null)
     {
         Console.WriteLine("MotorBoard ID not found in CSV");
     }
     else
     {
         UtilCan.SetP(CANBus, true, 0x2, receiver, MBD.P, 0);
         UtilCan.SetI(CANBus, true, 0x2, receiver, MBD.I, 0);
         UtilCan.SetD(CANBus, true, 0x2, receiver, MBD.D, 0);
         UtilCan.SetTicksPerRev(CANBus, true, 0x2, receiver, MBD.TicksPerRev);
     }
 }
Exemplo n.º 3
0
        public void Initialize()
        {
            int LineCount = 2;

            using (var reader = new StreamReader("Motorboards.csv"))
            {
                // Ignore first line in CSV for comment about formatting
                var skipline = reader.ReadLine();
                while (!reader.EndOfStream)
                {
                    var line   = reader.ReadLine();
                    var values = line.Split(',');

                    if (values.Length < 6)
                    {
                        Console.WriteLine("Motor data fields not complete at line " + LineCount);
                    }
                    else
                    {
                        MotorBoardData add = new MotorBoardData();
                        add.Model       = int.Parse(values[1]);
                        add.P           = UInt16.Parse(values[2]);
                        add.I           = UInt16.Parse(values[3]);
                        add.D           = UInt16.Parse(values[4]);
                        add.TicksPerRev = UInt16.Parse(values[5]);
                        switch (values[0])
                        {
                        case "MB1":
                            MB1.Add(add);
                            break;

                        case "MB2":
                            MB2.Add(add);
                            break;

                        case "MB3":
                            MB3.Add(add);
                            break;

                        case "MB4":
                            MB4.Add(add);
                            break;

                        case "MB5":
                            MB5.Add(add);
                            break;

                        case "MB6":
                            MB6.Add(add);
                            break;

                        case "MB7":
                            MB7.Add(add);
                            break;

                        default:
                            Console.WriteLine("Motor name not found for line " + LineCount);
                            break;
                        }
                    }
                    LineCount++;
                }
            }
        }