public void OpenLaserJob(string laserJobPath) { try { if (!File.Exists(laserJobPath)) { throw new FileNotFoundException(String.Format("Not found laser job file {0}", laserJobPath)); } } catch (Exception ex) { throw new MCoreExceptionPopup("SL Laser Desk [{0}] return from open job command {1}", this.Nickname, ex.ToString()); } int commandNumber = 7; CurrentJobPath = laserJobPath; List <Byte> param = SLTcp.CovertStringParamToByteList(CurrentJobPath); //Overwrite File Int Param ( 0 = no over write) param.Add(0x00); param.Add(0x00); param.Add(0x00); param.Add(0x00); List <Byte> returnQuery = (List <Byte>)QueryCommand(commandNumber, param); List <Byte> returnParams = GetParamsFromReturnQuery(commandNumber, returnQuery); Int32 paramsInt = BitConverter.ToInt32(returnParams.ToArray(), 0); if (paramsInt == 0) { throw new MCoreExceptionPopup(string.Format("SL Laser Desk [{0}] cannot open laser job [{1}]", this.Nickname, CurrentJobPath)); } }
/// <summary> /// Destroy the object /// </summary> public override void Destroy() { base.Destroy(); SLTcp.DisconnectFromLaserDesk(); KillExistingLaserDeskProcess(); if (_statusPollingThread != null && _statusPollingThread.IsAlive) { _statusPollingThread.Abort(); } }
public void Login() { int commandNumber = 1; List <Byte> param = SLTcp.CovertStringParamToByteList("1990"); List <Byte> returnQuery = (List <Byte>)QueryCommand(commandNumber, param); List <Byte> returnParams = GetParamsFromReturnQuery(commandNumber, returnQuery); Int32 paramsInt = BitConverter.ToInt32(returnParams.ToArray(), 0); if (paramsInt == 0) { //throw new MCoreExceptionPopup(string.Format("SL Laser Desk [{0}] login failed", this.Nickname)); } }
public override object QueryCommand(object command, object parameter) { lock (_locker) { List <Byte> commandList = SLTcp.BuildCommand((int)command, (List <Byte>)parameter); bool updateMsg = (int)command != 4; SLTcp.SendTCPCommand(commandList, updateMsg); List <Byte> tcpReturn = null; _retryReadCount = _retryRead; while (true) { tcpReturn = SLTcp.ReadTcpReturn(updateMsg); if (tcpReturn == null) { _retryReadCount--; if (_retryReadCount <= 0) { throw new MCoreExceptionPopup("SL Laser Desk [{0}] return from query command is null", this.Nickname); } System.Threading.Thread.Sleep(500); continue; } if ((int)command == 0x02 || (int)command == 0x03 || (int)command == 0x10) { if (tcpReturn[6] == (int)command) { break; } } else { if (tcpReturn[5] == (int)command) { break; } } } return(tcpReturn); } }
public void InitialLaserDesk() { if (!SLTcp.IsConnected) { SLTcp.ConnectToLaserDesk(TCPComm.IPAddress, TCPComm.Port); } ////Login //List<Byte> loginParam = null; //loginParam = SLTcp.CovertStringParamToByteList("1990"); //ExecuteCommand(1, loginParam); ////Remoteon //List<Byte> remoteOnParam = null; //ExecuteCommand(5, remoteOnParam); Login(); RemoteOn(); }
public void DisconnectLaserDesk() { if (SLTcp.IsConnected) { ////LogOff //List<Byte> logOffParam = null; //logOffParam = null; //ExecuteCommand(2, logOffParam); ////RemoteOff //List<Byte> remoteOffParam = null; //ExecuteCommand(6, remoteOffParam); //SLTcp.DisconnectFromLaserDesk(); Logout(); RemoteOff(); SLTcp.DisconnectFromLaserDesk(); } }
public void SelectUID(string UID) { int commandNumber = 11; List <Byte> param = new List <byte>(); //Param1 = 3 is Select by UID param.Add(0x03); param.Add(0x00); param.Add(0x00); param.Add(0x00); if (UID != null && UID != "") { param.AddRange(SLTcp.CovertStringParamToByteList(UID)); } else { throw new MCoreExceptionPopup(string.Format("SL Laser Desk [{0}] no select UID specify on laser job [{1}]", this.Nickname, CurrentJobPath)); } int retry = 3; Int32 paramsInt = 0; do { List <Byte> returnQuery = (List <Byte>)QueryCommand(commandNumber, param); List <Byte> returnParams = GetParamsFromReturnQuery(commandNumber, returnQuery); paramsInt = BitConverter.ToInt32(returnParams.ToArray(), 0); if (paramsInt == 0) { //Throw Exception when max retry if (retry <= 0) { throw new MCoreExceptionPopup(string.Format("SL Laser Desk [{0}] cannot select UID [{1}] on laser job [{2}]", this.Nickname, UID, CurrentJobPath)); } System.Threading.Thread.Sleep(100); } } while (paramsInt == 0 && retry > 0); }