|  | @@ -50,9 +50,11 @@ namespace Venus_RT.Devices
 | 
												
													
														
															|  |          private readonly Regex _rex_check_load = new Regex(@"LOAD\s+(A|B)\s+(\w+)\s*");
 |  |          private readonly Regex _rex_check_load = new Regex(@"LOAD\s+(A|B)\s+(\w+)\s*");
 | 
												
													
														
															|  |          private readonly Regex _rex_error_code = new Regex(@"_ERR\s+(\d+)\s*");
 |  |          private readonly Regex _rex_error_code = new Regex(@"_ERR\s+(\d+)\s*");
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | 
 |  | +        private const string EOF = "\r\n";
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  |          public SIASUNRobot()
 |  |          public SIASUNRobot()
 | 
												
													
														
															|  |          {
 |  |          {
 | 
												
													
														
															|  | -            _socket = new AsyncSocket("");
 |  | 
 | 
												
													
														
															|  | 
 |  | +            _socket = new AsyncSocket("", EOF);
 | 
												
													
														
															|  |              _socket.Connect(SC.GetStringValue($"TM.IPAddress"));
 |  |              _socket.Connect(SC.GetStringValue($"TM.IPAddress"));
 | 
												
													
														
															|  |              _socket.OnDataChanged += OnReceiveMessage;
 |  |              _socket.OnDataChanged += OnReceiveMessage;
 | 
												
													
														
															|  |              _socket.OnErrorHappened += OnErrorHappen;
 |  |              _socket.OnErrorHappened += OnErrorHappen;
 | 
												
											
												
													
														
															|  | @@ -77,11 +79,11 @@ namespace Venus_RT.Devices
 | 
												
													
														
															|  |              _status = RState.Running;
 |  |              _status = RState.Running;
 | 
												
													
														
															|  |              _currentOP = OPStep.Home;
 |  |              _currentOP = OPStep.Home;
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | -            return _SendCommand("HOME ALL\r");
 |  | 
 | 
												
													
														
															|  | 
 |  | +            return _SendCommand("HOME ALL");
 | 
												
													
														
															|  |          }
 |  |          }
 | 
												
													
														
															|  |          public bool Halt()
 |  |          public bool Halt()
 | 
												
													
														
															|  |          {
 |  |          {
 | 
												
													
														
															|  | -            return _SendCommand("HALT\r");
 |  | 
 | 
												
													
														
															|  | 
 |  | +            return _SendCommand("HALT");
 | 
												
													
														
															|  |          }
 |  |          }
 | 
												
													
														
															|  |          public bool CheckLoad(Hand hand = Hand.Blade1)
 |  |          public bool CheckLoad(Hand hand = Hand.Blade1)
 | 
												
													
														
															|  |          {
 |  |          {
 | 
												
											
												
													
														
															|  | @@ -90,7 +92,7 @@ namespace Venus_RT.Devices
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  |              _currentOP = hand == Hand.Blade2 ? OPStep.CheckLoad_ArmB : OPStep.CheckLoad_ArmA;
 |  |              _currentOP = hand == Hand.Blade2 ? OPStep.CheckLoad_ArmB : OPStep.CheckLoad_ArmA;
 | 
												
													
														
															|  |              _status = RState.Running;
 |  |              _status = RState.Running;
 | 
												
													
														
															|  | -            return _SendCommand($"CHECK LOAD {_checkLoadStation} ARM {Hand2Arm(hand)}\r");
 |  | 
 | 
												
													
														
															|  | 
 |  | +            return _SendCommand($"CHECK LOAD {_checkLoadStation} ARM {Hand2Arm(hand)}");
 | 
												
													
														
															|  |          }
 |  |          }
 | 
												
													
														
															|  |          public bool Goto(ModuleName station, int slot, Hand hand)
 |  |          public bool Goto(ModuleName station, int slot, Hand hand)
 | 
												
													
														
															|  |          {
 |  |          {
 | 
												
											
												
													
														
															|  | @@ -99,7 +101,7 @@ namespace Venus_RT.Devices
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  |              _currentOP = OPStep.Goto;
 |  |              _currentOP = OPStep.Goto;
 | 
												
													
														
															|  |              _status = RState.Running;
 |  |              _status = RState.Running;
 | 
												
													
														
															|  | -            return _SendCommand($"GOTO N {_StationNumbers[station]} SLOT {slot} ARM {Hand2Arm(hand)}\r");
 |  | 
 | 
												
													
														
															|  | 
 |  | +            return _SendCommand($"GOTO N {_StationNumbers[station]} SLOT {slot} ARM {Hand2Arm(hand)}");
 | 
												
													
														
															|  |          }
 |  |          }
 | 
												
													
														
															|  |          public bool MoveTo(ModuleName stnFrom, ModuleName stnTo, Hand hand)
 |  |          public bool MoveTo(ModuleName stnFrom, ModuleName stnTo, Hand hand)
 | 
												
													
														
															|  |          {
 |  |          {
 | 
												
											
												
													
														
															|  | @@ -108,7 +110,7 @@ namespace Venus_RT.Devices
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  |              _currentOP = OPStep.MoveTo;
 |  |              _currentOP = OPStep.MoveTo;
 | 
												
													
														
															|  |              _status = RState.Running;
 |  |              _status = RState.Running;
 | 
												
													
														
															|  | -            return _SendCommand($"XFER ARM {Hand2Arm(hand)} {_StationNumbers[stnFrom]} {_StationNumbers[stnTo]}\r");
 |  | 
 | 
												
													
														
															|  | 
 |  | +            return _SendCommand($"XFER ARM {Hand2Arm(hand)} {_StationNumbers[stnFrom]} {_StationNumbers[stnTo]}");
 | 
												
													
														
															|  |          }
 |  |          }
 | 
												
													
														
															|  |          public bool PickExtend(ModuleName chamber, int slot, Hand hand)
 |  |          public bool PickExtend(ModuleName chamber, int slot, Hand hand)
 | 
												
													
														
															|  |          {
 |  |          {
 | 
												
											
												
													
														
															|  | @@ -118,7 +120,7 @@ namespace Venus_RT.Devices
 | 
												
													
														
															|  |              _currentOP = OPStep.PickExtend;
 |  |              _currentOP = OPStep.PickExtend;
 | 
												
													
														
															|  |              _status = RState.Running;
 |  |              _status = RState.Running;
 | 
												
													
														
															|  |              SetRobotMovingInfo(RobotAction.Extending, hand, chamber);
 |  |              SetRobotMovingInfo(RobotAction.Extending, hand, chamber);
 | 
												
													
														
															|  | -            return _SendCommand($"PICK {_StationNumbers[chamber]} SLOT {slot} ARM {Hand2Arm(hand)} ENRT\r");
 |  | 
 | 
												
													
														
															|  | 
 |  | +            return _SendCommand($"PICK {_StationNumbers[chamber]} SLOT {slot} ARM {Hand2Arm(hand)} ENRT");
 | 
												
													
														
															|  |          }
 |  |          }
 | 
												
													
														
															|  |          public bool PickRetract(ModuleName chamber, int slot, Hand hand)
 |  |          public bool PickRetract(ModuleName chamber, int slot, Hand hand)
 | 
												
													
														
															|  |          {
 |  |          {
 | 
												
											
												
													
														
															|  | @@ -128,7 +130,7 @@ namespace Venus_RT.Devices
 | 
												
													
														
															|  |              _currentOP = OPStep.PickRetract;
 |  |              _currentOP = OPStep.PickRetract;
 | 
												
													
														
															|  |              _status = RState.Running;
 |  |              _status = RState.Running;
 | 
												
													
														
															|  |              SetRobotMovingInfo(RobotAction.Retracting, hand, chamber);
 |  |              SetRobotMovingInfo(RobotAction.Retracting, hand, chamber);
 | 
												
													
														
															|  | -            return _SendCommand($"PICK {_StationNumbers[chamber]} SLOT {slot} ARM {Hand2Arm(hand)} STRT\r");
 |  | 
 | 
												
													
														
															|  | 
 |  | +            return _SendCommand($"PICK {_StationNumbers[chamber]} SLOT {slot} ARM {Hand2Arm(hand)} STRT");
 | 
												
													
														
															|  |          }
 |  |          }
 | 
												
													
														
															|  |          public bool PlaceExtend(ModuleName chamber, int slot, Hand hand)
 |  |          public bool PlaceExtend(ModuleName chamber, int slot, Hand hand)
 | 
												
													
														
															|  |          {
 |  |          {
 | 
												
											
												
													
														
															|  | @@ -138,7 +140,7 @@ namespace Venus_RT.Devices
 | 
												
													
														
															|  |              _currentOP = OPStep.PlaceExtent;
 |  |              _currentOP = OPStep.PlaceExtent;
 | 
												
													
														
															|  |              _status = RState.Running;
 |  |              _status = RState.Running;
 | 
												
													
														
															|  |              SetRobotMovingInfo(RobotAction.Extending, hand, chamber);
 |  |              SetRobotMovingInfo(RobotAction.Extending, hand, chamber);
 | 
												
													
														
															|  | -            return _SendCommand($"PLACE {_StationNumbers[chamber]} SLOT {slot} ARM {Hand2Arm(hand)} ENRT\r");
 |  | 
 | 
												
													
														
															|  | 
 |  | +            return _SendCommand($"PLACE {_StationNumbers[chamber]} SLOT {slot} ARM {Hand2Arm(hand)} ENRT");
 | 
												
													
														
															|  |          }
 |  |          }
 | 
												
													
														
															|  |          public bool PlaceRetract(ModuleName chamber, int slot, Hand hand)
 |  |          public bool PlaceRetract(ModuleName chamber, int slot, Hand hand)
 | 
												
													
														
															|  |          {
 |  |          {
 | 
												
											
												
													
														
															|  | @@ -148,7 +150,7 @@ namespace Venus_RT.Devices
 | 
												
													
														
															|  |              _currentOP = OPStep.PlaceExtent;
 |  |              _currentOP = OPStep.PlaceExtent;
 | 
												
													
														
															|  |              _status = RState.Running;
 |  |              _status = RState.Running;
 | 
												
													
														
															|  |              SetRobotMovingInfo(RobotAction.Retracting, hand, chamber);
 |  |              SetRobotMovingInfo(RobotAction.Retracting, hand, chamber);
 | 
												
													
														
															|  | -            return _SendCommand($"PLACE {_StationNumbers[chamber]} SLOT {slot} ARM {Hand2Arm(hand)} STRT\r");
 |  | 
 | 
												
													
														
															|  | 
 |  | +            return _SendCommand($"PLACE {_StationNumbers[chamber]} SLOT {slot} ARM {Hand2Arm(hand)} STRT");
 | 
												
													
														
															|  |          }
 |  |          }
 | 
												
													
														
															|  |          public bool Pick(ModuleName station, int slot, Hand hand)
 |  |          public bool Pick(ModuleName station, int slot, Hand hand)
 | 
												
													
														
															|  |          {
 |  |          {
 | 
												
											
												
													
														
															|  | @@ -158,7 +160,7 @@ namespace Venus_RT.Devices
 | 
												
													
														
															|  |              _currentOP = OPStep.Pick;
 |  |              _currentOP = OPStep.Pick;
 | 
												
													
														
															|  |              _status = RState.Running;
 |  |              _status = RState.Running;
 | 
												
													
														
															|  |              SetRobotMovingInfo(RobotAction.Picking, hand, station);
 |  |              SetRobotMovingInfo(RobotAction.Picking, hand, station);
 | 
												
													
														
															|  | -            return _SendCommand($"PICK {_StationNumbers[station]} SLOT {slot} ARM {Hand2Arm(hand)}\r");
 |  | 
 | 
												
													
														
															|  | 
 |  | +            return _SendCommand($"PICK {_StationNumbers[station]} SLOT {slot} ARM {Hand2Arm(hand)}");
 | 
												
													
														
															|  |          }
 |  |          }
 | 
												
													
														
															|  |          public bool Place(ModuleName station, int slot, Hand hand)
 |  |          public bool Place(ModuleName station, int slot, Hand hand)
 | 
												
													
														
															|  |          {
 |  |          {
 | 
												
											
												
													
														
															|  | @@ -168,13 +170,13 @@ namespace Venus_RT.Devices
 | 
												
													
														
															|  |              _currentOP = OPStep.Place;
 |  |              _currentOP = OPStep.Place;
 | 
												
													
														
															|  |              _status = RState.Running;
 |  |              _status = RState.Running;
 | 
												
													
														
															|  |              SetRobotMovingInfo(RobotAction.Placing, hand, station);
 |  |              SetRobotMovingInfo(RobotAction.Placing, hand, station);
 | 
												
													
														
															|  | -            return _SendCommand($"PLACE {_StationNumbers[station]} SLOT {slot} ARM {Hand2Arm(hand)}\r");
 |  | 
 | 
												
													
														
															|  | 
 |  | +            return _SendCommand($"PLACE {_StationNumbers[station]} SLOT {slot} ARM {Hand2Arm(hand)}");
 | 
												
													
														
															|  |          }
 |  |          }
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  |          private bool _SendCommand(string cmd)
 |  |          private bool _SendCommand(string cmd)
 | 
												
													
														
															|  |          {
 |  |          {
 | 
												
													
														
															|  |              LOG.WriteSingeLine(eEvent.INFO_TM_ROBOT, ModuleName.TMRobot, $"Send Command to SIASUN TM Robot: {cmd}");
 |  |              LOG.WriteSingeLine(eEvent.INFO_TM_ROBOT, ModuleName.TMRobot, $"Send Command to SIASUN TM Robot: {cmd}");
 | 
												
													
														
															|  | -            return _socket.Write(cmd);
 |  | 
 | 
												
													
														
															|  | 
 |  | +            return _socket.Write(cmd + EOF);
 | 
												
													
														
															|  |          }
 |  |          }
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  |          private bool CheckRobotStatus()
 |  |          private bool CheckRobotStatus()
 | 
												
											
												
													
														
															|  | @@ -200,19 +202,18 @@ namespace Venus_RT.Devices
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  |          private void OnReceiveMessage(string RevMsg)
 |  |          private void OnReceiveMessage(string RevMsg)
 | 
												
													
														
															|  |          {
 |  |          {
 | 
												
													
														
															|  | -            if(_rex_error_code.IsMatch(RevMsg))
 |  | 
 | 
												
													
														
															|  | 
 |  | +            LOG.WriteSingeLine(eEvent.INFO_TM_ROBOT, ModuleName.TMRobot, $"Receive message from SIASUN TM Robot: {RevMsg}, while {_currentOP}");
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +            if (_rex_error_code.IsMatch(RevMsg))
 | 
												
													
														
															|  |              {
 |  |              {
 | 
												
													
														
															|  |                  _IsHomed = false;
 |  |                  _IsHomed = false;
 | 
												
													
														
															|  |                  _status = RState.Failed;
 |  |                  _status = RState.Failed;
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  |                  var results = _rex_error_code.Match(RevMsg);
 |  |                  var results = _rex_error_code.Match(RevMsg);
 | 
												
													
														
															|  |                  ErrorMessageHandler(results.Groups[1].Value);
 |  |                  ErrorMessageHandler(results.Groups[1].Value);
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  |                  return;
 |  |                  return;
 | 
												
													
														
															|  |              }
 |  |              }
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | -            LOG.WriteSingeLine(eEvent.INFO_TM_ROBOT, ModuleName.TMRobot, $"Receive message from SIASUN TM Robot: {RevMsg}, while {_currentOP}");
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  |              switch (_currentOP)
 |  |              switch (_currentOP)
 | 
												
													
														
															|  |              {
 |  |              {
 | 
												
													
														
															|  |                  case OPStep.Goto:
 |  |                  case OPStep.Goto:
 | 
												
											
												
													
														
															|  | @@ -238,8 +239,8 @@ namespace Venus_RT.Devices
 | 
												
													
														
															|  |                      break;
 |  |                      break;
 | 
												
													
														
															|  |                  case OPStep.Home:
 |  |                  case OPStep.Home:
 | 
												
													
														
															|  |                      {
 |  |                      {
 | 
												
													
														
															|  | -                       
 |  | 
 | 
												
													
														
															|  | -                        if (RevMsg.TrimEnd(new char[] { '\r', '\n' }) == "_RDY")
 |  | 
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +                        if (RevMsg.Trim() == "_RDY")
 | 
												
													
														
															|  |                          {
 |  |                          {
 | 
												
													
														
															|  |                              //CheckLoad(Hand.Blade1);
 |  |                              //CheckLoad(Hand.Blade1);
 | 
												
													
														
															|  |                              _currentOP = OPStep.Idle;
 |  |                              _currentOP = OPStep.Idle;
 |