YaskawaNX100RobotSimulator.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading;
  6. using System.Threading.Tasks;
  7. using MECF.Framework.Simulator.Core.Driver;
  8. namespace MECF.Framework.Simulator.Core.Robots
  9. {
  10. public class YaskawaNX100RobotSimulator : YaskawaNX100ControllerSimulator
  11. {
  12. public YaskawaNX100RobotSimulator()
  13. : base(10113)
  14. {
  15. }
  16. //$ <UNo> (<SeqNo>) MMAP<TrsSt> <SlotNo> <Sum> <CR> //$,<UNo>(,<SeqNo>),<Sts>,<Ackcd>,MTRS,<Mtn>,<TrsSt>,<Slot>,<Posture>,<Hand>,<TrsPnt>(,<OfstX>,<OfstY>,<OfstZ>)(,<Angle>)(,<Sum>)<CR>
  17. //$ <UNo> (<SeqNo>) <StsN> <Ackcd> 01 <Result> 02 <Result> … XX <Result> <Sum> <CR>
  18. public override void HandleRMAP(string msg)
  19. {
  20. Random rd = new Random();
  21. string unit = msg.Substring(1, 1);
  22. string seq = msg.Substring(2, 2);
  23. string cmd = msg.Substring(4, 4);
  24. string trs = msg.Substring(8, 2);
  25. string slot = msg.Substring(10, 2);
  26. string sts = 0.ToString("X02");
  27. string Ackcd = 0.ToString("X04");
  28. string error = 0.ToString("X04");
  29. //bool random = false;
  30. bool full = trs == "C1" || trs == "C2";
  31. //string mapData = GetMapData(random, full);
  32. bool pre = trs == "C1" || trs == "C3";
  33. bool mid = trs == "C2" || trs == "C4";
  34. bool post = trs == "C5" || trs == "C6";
  35. string mapData = GetMapData(pre, mid, post);
  36. if (trs == "C1")
  37. mapData = GetMapData(1,5);
  38. else
  39. mapData = GetMapData(0, 1);
  40. string feedback = string.Format(",{0},{1},{2},{3},{4},", unit, seq, sts, Ackcd, mapData).Replace(",","").Replace(":", "");
  41. string sum = CheckSum(feedback);
  42. string result = String.Format("{0}{1}{2}","$", feedback, sum);
  43. OnWriteMessage(result);
  44. }
  45. }
  46. }