/** * Helper method to handle automated build behavior in the event of an error. Depending on the specified behavior, one of three * results are possible: * a) User is prompted on whether to proceed with the automated build or not, * b) The error is regarded as a build-stopper and the method returns failure, * or * c) The error is acknowledged but not regarded as a build-stopper, and the method returns success. * In any event, the error is logged for the user's information. * * @param InBehavior Behavior to use to respond to the error * @param InErrorMsg Error to log * @param OutAccumulatedErrors List of errors accumulated from the build process so far; InErrorMsg will be added to the list * * @return true if the build should proceed after processing the error behavior; false if it should not */ bool FEditorBuildUtils::ProcessAutomatedBuildBehavior( EAutomatedBuildBehavior InBehavior, const FText& InErrorMsg, FText& OutAccumulatedErrors ) { // Assume the behavior should result in the build being successful/proceeding to start bool bSuccessful = true; switch ( InBehavior ) { // In the event the user should be prompted for the error, display a modal dialog describing the error and ask the user // if the build should proceed or not case ABB_PromptOnError: { bSuccessful = EAppReturnType::Yes == FMessageDialog::Open(EAppMsgType::YesNo, InErrorMsg); } break; // In the event that the specified error should abort the build, mark the processing as a failure case ABB_FailOnError: bSuccessful = false; break; } // Log the error message so the user is aware of it LogErrorMessage( InErrorMsg, OutAccumulatedErrors ); // If the processing resulted in the build inevitably being aborted, write to the log about the abortion if ( !bSuccessful ) { LogErrorMessage( NSLOCTEXT("UnrealEd", "AutomatedBuild_Error_AutomatedBuildAborted", "Automated build aborted."), OutAccumulatedErrors ); } return bSuccessful; }
bool TCPSocket::Connect( const IPv4Address& destination ) { //Set up the socket m_Socket = static_cast< int >( socket( AF_INET, SOCK_STREAM, IPPROTO_TCP ) ); // Adress Family = INET and the protocol to be used is TCP if ( m_Socket <= 0 ) { LogErrorMessage( "Failed to create socket", "TCPSocket" ); return false; } SetBlockingMode( false ); // Try to connect Logger::Log( "Attempting to connect to " + destination.GetPrintableAddressAndPort(), "TCPSocket", LogSeverity::INFO_MSG ); sockaddr_in addr = destination.GetSockAddr(); timeval timeOut; timeOut.tv_sec = CONNECTION_TIMEOUT_SECONDS; timeOut.tv_usec = 0; fd_set set; FD_ZERO( &set ); FD_SET( m_Socket, &set ); int returnVal; if ( ( returnVal = connect( m_Socket, ( sockaddr * )&addr, sizeof( sockaddr_in ) ) ) == INVALID_SOCKET ) { if ( !SHOULD_WAIT_FOR_TIMEOUT ) return false; } returnVal = select( static_cast<int>( m_Socket + 1 ), NULL, &set, NULL, &timeOut ); if ( returnVal > 0 ) // A socket was connected { m_Destination = destination; m_Connected = true; SetNoDelay(); Logger::Log( "Connection attempt to " + destination.GetPrintableAddressAndPort() + " was successfull!", "TCPSocket", LogSeverity::INFO_MSG ); return true; } else if ( returnVal == 0 ) { Logger::Log( "Connection attempt to " + destination.GetPrintableAddressAndPort() + " timed out", "TCPSocket", LogSeverity::INFO_MSG ); return false; } else { LogErrorMessage( "Connection attempt to " + destination.GetPrintableAddressAndPort() + " failed", "TCPSocket" ); return false; } }
bool CSendToMarket::SendToMarket(TTradeRequest &trade_mes) { try { // send Trade Request to MEE #ifdef NO_MEE_FOR_TRADERESULT m_pCMEE->SubmitTradeRequest(&trade_mes); #else m_Socket->dbt5Send(reinterpret_cast<void *>(&trade_mes), sizeof(TTradeRequest)); #endif } catch (CSocketErr *pErr) { m_Socket->dbt5Disconnect(); // close connection timeval t1; gettimeofday(&t1, NULL); ostringstream osErr; osErr << "Cannot send to market, time "<<t1.tv_sec<<", "<<t1.tv_usec<<", m_Socket = "<<m_Socket->getSocketFd() << endl << "Error: " << pErr->ErrorText() << " at CSendToMarket::SendToMarket" << endl; delete pErr; LogErrorMessage(osErr.str()); return false; } return true; }
int CiSeries::getAlarmInfo() { //char *almmsg[] = { // "P/S 100 ALARM","P/S 000 ALARM", // "P/S 101 ALARM","P/S ALARM (1-255)", // "OT ALARM", "OH ALARM", // "SERVO ALARM", "unknown ALARM", // "APC ALARM", "SPINDLE ALARM", // "P/S ALARM (5000-)" //} ; char *almmsg[] = { "P/S alarm", "Overtravel alarm", "Servo alarm", "(Not used)", "Overheat alarm", "Stroke limit - 1", "Stroke limit - 2", "Edit alarm", "APC alarm", "(Not used)", "P/S 5000 ... alarm", "(Not used)", "(Not used)", "(Not used)", "External alarm", "Reverse control alarm"}; short ret=0; ODBALM buf ; unsigned short idx ; ret=cnc_alarm( _adapter->mFlibhndl, &buf ) ; if (ret != EW_OK) { return LogErrorMessage("iSeries::getAlarmInfo() cnc_alarm FAILED\n", ret ); } if ( buf.data == 0 ) { _adapter->SetMTCTagValue("fault", ""); } else { std::string sAlarm; for ( idx = 0 ; idx < 11 ; idx++ ) { if ( buf.data & 0x0001 ) sAlarm+= almmsg[idx] ; buf.data >>= 1 ; } _adapter->SetMTCTagValue("fault", sAlarm); } return 0; }
int CiSeries::connect() { LOGONCE GLogger.Status(StdStringFormat("iSeries::connect Using Protocol=%s\n", Globals.FanucProtocol.c_str())); short ret; _adapter->mFlibhndl=0; if(Globals.FanucProtocol == "HSSB") { GLogger.Fatal(StdStringFormat("iSeries::connect HSSB cnc_allclibhndl2 Port=%d\n", _adapter->mDevicePort )); //GLogger << FATAL << "THIS EXECUTABLE DOES NOT HANDLE HSSB - EXCLUSIVELY Focas w/ Processing library for TCP/IP\n"; #ifdef iSERIESHSSB ret = ::cnc_allclibhndl2(_adapter->mDevicePort,&_adapter->mFlibhndl); #else GLogger.Fatal( "THIS EXECUTABLE DOES NOT HANDLE LAN - EXCLUSIVELY Focas w/ Processing library for HSSB\n" ); return -1; #endif } else { GLogger.Fatal(StdStringFormat("iSeries::connect LAN cnc_allclibhndl3 IP=%s Port=%d\n",Globals.FanucIpAddress.c_str(), _adapter->mDevicePort )); #ifdef iSERIESLAN try{ ret = ::cnc_allclibhndl3(Globals.FanucIpAddress.c_str(), _adapter->mDevicePort, 10, &_adapter->mFlibhndl); } catch(...) { GLogger.Fatal(StdStringFormat("iSeries::connect LAN cnc_allclibhndl3 Exception\n")); } #else GLogger.Fatal( "THIS EXECUTABLE DOES NOT HANDLE LAN - EXCLUSIVELY Focas w/ Processing library for HSSB\n"); return -1; #endif } GLogger.Fatal (StdStringFormat("iSeries::connect cnc_allclibhndl Result:%x\n " , ret )); if (ret != EW_OK) { LogErrorMessage("iSeries::connect cnc_allclibhndl3 failed ",ret); _adapter->SetMTCTagValue("avail","UNAVAILABLE"); _adapter->SetMTCTagValue("power","OFF"); _adapter->mConnected = false; LOGONCE GLogger.Fatal(StdStringFormat("iSeries::connect FAILED Power = OFF\n", ret )); return -1; } GLogger.LogMessage(StdStringFormat("iSeries::connect connected ON\n", ret ), HEAVYDEBUG); _adapter->mConnected = true; _adapter->SetMTCTagValue("power","ON"); _adapter->SetMTCTagValue("avail","AVAILABLE"); return 0; }
void TCPSocket::Disconnect() { int result; #if PLATFORM == PLATFORM_WINDOWS result = shutdown( m_Socket, SD_BOTH ); #else result = shutdown( m_Socket, SHUT_RDWR ); #endif if ( result != 0 ) LogErrorMessage( "Failed to shut down socket", "TCPSocket" ); #if PLATFORM == PLATFORM_WINDOWS result = closesocket( m_Socket ); #else result = close( m_Socket ); #endif if ( result != 0 ) LogErrorMessage( "Failed to close socket", "TCPSocket" ); m_Socket = INVALID_SOCKET; m_Connected = false; }
bool TCPSocket::SetTimeout( unsigned int seconds ) { bool result1; bool result2; bool toReturn; struct timeval timeout; timeout.tv_sec = seconds; timeout.tv_usec = 0; result1 = setsockopt( m_Socket, SOL_SOCKET, SO_RCVTIMEO, ( char * )&timeout, sizeof( timeout ) ) != SOCKET_ERROR; result2 = setsockopt( m_Socket, SOL_SOCKET, SO_SNDTIMEO, ( char * )&timeout, sizeof( timeout ) ) != SOCKET_ERROR; toReturn = result1 && result2; if ( !toReturn ) LogErrorMessage( "Failed to set timeout time", "TCPSocket" ); return toReturn; }
bool CSendToMarket::SendToMarket(TTradeRequest &trade_mes) { try { // send Trade Request to MEE m_Socket->dbt5Send(reinterpret_cast<void *>(&trade_mes), sizeof(TTradeRequest)); } catch (CSocketErr *pErr) { m_Socket->dbt5Disconnect(); // close connection ostringstream osErr; osErr << "Cannot send to market" << endl << "Error: " << pErr->ErrorText() << " at CSendToMarket::SendToMarket" << endl; delete pErr; LogErrorMessage(osErr.str()); return false; } return true; }
bool TCPSocket::SendRawData( const Byte* const data, const unsigned int dataSize ) { if ( m_Socket == INVALID_SOCKET ) { Logger::Log( "Attempted to send to invalid socket", "TCPSocket", LogSeverity::WARNING_MSG ); return false; } int bytesSent = send( m_Socket, data, dataSize, SENDFLAGS ); if ( bytesSent != dataSize ) { int error = GET_NETWORK_ERROR; if ( error == ROBOECONNECTIONABORTED || error == ROBOEWOULDBLOCK || error == EPIPE || error == ROBOECONNRESET ) { m_Connected = false; Logger::Log( "Connection to " + m_Destination.GetPrintableAddressAndPort() + " was aborted", "TCPSocket", LogSeverity::INFO_MSG ); } else LogErrorMessage( "Sending of packet with length " + rToString( dataSize ) + " and destination " + m_Destination.GetPrintableAddressAndPort() + " failed", "TCPSocket" ); return false; } return true; }
Message* TCPSocket::Receive() { if ( m_Socket == INVALID_SOCKET ) { Logger::Log( "Attempted to receive from invalid socket", "TCPSocket", LogSeverity::WARNING_MSG ); return nullptr; } int nrOfBytesReceived; if ( m_ExpectedHeaderBytes > 0 ) // If we are waiting for header data { nrOfBytesReceived = recv( m_Socket, m_Pos, m_ExpectedHeaderBytes, 0 ); // Try to receive header if ( nrOfBytesReceived == 0 ) // Check if the socket was gracefully disconnected { m_Connected = false; Logger::Log( "Connection to " + m_Destination.GetPrintableAddressAndPort() + " terminated gracefully", "TCPSocket", LogSeverity::INFO_MSG ); } else if ( nrOfBytesReceived == -1 ) { int error = GET_NETWORK_ERROR; if ( error != ROBOEWOULDBLOCK ) { if ( error == ROBOECONNECTIONABORTED || error == ROBOECONNRESET ) { m_Connected = false; Logger::Log( "Connection to " + m_Destination.GetPrintableAddressAndPort( ) + " was aborted", "TCPSocket", LogSeverity::INFO_MSG ); } else LogErrorMessage( "An unhandled error occured while receiving header data", "TCPSocket" ); } return nullptr; // No data was ready to be received or there was an error } if ( nrOfBytesReceived == m_ExpectedHeaderBytes ) { m_ExpectedHeaderBytes = 0; // We received the full header // Get the size of the packet (Embedded as first part) and create a buffer of that size m_PayloadData = static_cast<Byte*>( tMalloc( m_ExpectedPayloadBytes ) ); m_ExpectedPayloadBytes -= sizeof( unsigned int ); // We have already received the size value m_Pos = m_PayloadData; // Pos now points to the new buffer since that is where we will want to write on the next recv } else // Only a part of the header was received. Account for this and handle it on next function call { m_ExpectedHeaderBytes -= nrOfBytesReceived; m_Pos += nrOfBytesReceived; return nullptr; } } nrOfBytesReceived = recv( m_Socket, m_Pos, m_ExpectedPayloadBytes, 0 ); // Try to receive payload if ( nrOfBytesReceived == -1 ) { int error = GET_NETWORK_ERROR; if ( error != ROBOEWOULDBLOCK ) { if ( error == ROBOECONNECTIONABORTED ) { m_Connected = false; Logger::Log( "Connection to " + m_Destination.GetPrintableAddressAndPort( ) + " was aborted", "TCPSocket", LogSeverity::INFO_MSG ); } else LogErrorMessage( "An unhandled error occured while receiving payload data", "TCPSocket" ); } return nullptr; // No data was ready to be received or there was an error } // If all data was received. Clean up, prepare for next call and return the buffer as a packet (Will need to be cast to the correct type on the outside using the Type field) if ( nrOfBytesReceived == m_ExpectedPayloadBytes ) { MessageTypes::MessageType messageType; Byte* walker = m_PayloadData; memcpy( &messageType, walker, sizeof( MESSAGE_TYPE_ENUM_UNDELYING_TYPE ) ); Message* packet; if ( messageType == 0 ) { NetworkMessageTypes::NetworkMessageType networkedMessageType; memcpy( &networkedMessageType, walker + sizeof( MESSAGE_TYPE_ENUM_UNDELYING_TYPE ) + sizeof( bool ), sizeof( NetworkMessageTypes::NetworkMessageType ) ); packet = NetworkMessages::GetDefaultMessage( networkedMessageType ); } else { packet = Messages::GetDefaultMessage( messageType ); } packet->Deserialize( ( const char*& )walker ); #if NETWORK_DEBUG if ( walker != m_PayloadData + packet->GetSerializationSize( ) ) { int differentiatingSize = walker - m_PayloadData - packet->GetSerializationSize( ); assert( false ); } MemoryAllocator::VerifyPointer( packet ); #endif tFree( m_PayloadData ); m_PayloadData = nullptr; m_Pos = reinterpret_cast<Byte*>( &m_ExpectedPayloadBytes ); m_ExpectedPayloadBytes = -1; m_ExpectedHeaderBytes = sizeof( unsigned int ); return packet; } else // Only part of the payload was received. Account for this and try to receive the rest in an upcoming function call { m_ExpectedPayloadBytes -= nrOfBytesReceived; m_Pos += nrOfBytesReceived; return nullptr; } }
// // // SIP Uri Logger // // void CSipUriAndAuthorityTest::SipLogError(TInt aError, const TDesC16& aSipUri) const { TBool wrongError=EFalse; //compare the Equivalent SIP URI to look for the correct error, these SIP URIs must be in T_UriParserSipUri.txt //All equal if (0==aSipUri.Compare(KCompsSipUriEqual0) && KErrNone != aError || 0==aSipUri.Compare(KCompsSipUriEqual1) && KErrNone != aError || 0==aSipUri.Compare(KCompsSipUriEqual2) && KErrNone != aError) { iTestHarness->LogIt(KCompsSipUriValidMess0); wrongError=ETrue; } //All not equal if (0==aSipUri.Compare(KCompsSipUriNotEqual0) && KUriUtilsErrDifferentUserInfo == aError || 0==aSipUri.Compare(KCompsSipUriNotEqual1) && KUriUtilsErrDifferentPath == aError || 0==aSipUri.Compare(KCompsSipUriNotEqual2) && KUriUtilsErrDifferentPort == aError ) { iTestHarness->LogIt(KCompsSipUriEqualMess1); } //compare the SIP URIs to look for the correct error returned by CUri for validation if (0==aSipUri.Compare(KCompsSipUriNotEqual1) && KUriUtilsErrDifferentPath != aError ) { iTestHarness->LogIt(KCompsSipUriInvalidMess9); wrongError=ETrue; } if (0==aSipUri.Compare(KCompsSipUriValid0) && KErrNone!= aError || 0==aSipUri.Compare(KCompsSipUriValid1) && KErrNone!= aError) { iTestHarness->LogIt(KCompsSipUriValidMess0); wrongError=ETrue; } if (0==aSipUri.Compare(KCompsSipUriInvalid0) && KErrNotSupported != aError) { iTestHarness->LogIt(KCompsSipUriInvalidMess0); wrongError=ETrue; } if( 0==aSipUri.Compare(KCompsSipUriInvalid5) && KUriUtilsErrInvalidParam!= aError || 0==aSipUri.Compare(KCompsSipUriInvalid6) && KUriUtilsErrInvalidParam!= aError) { iTestHarness->LogIt(KCompsSipUriInvalidMess1); wrongError=ETrue; } if (0==aSipUri.Compare(KCompsSipUriInvalid3) && KUriUtilsErrInvalidHost!= aError) { iTestHarness->LogIt(KCompsSipUriInvalidMess2); wrongError=ETrue; } if (0==aSipUri.Compare(KCompsSipUriInvalid2) && KUriUtilsErrInvalidHeaders != aError) { iTestHarness->LogIt(KCompsSipUriInvalidMess8); wrongError=ETrue; } if (0==aSipUri.Compare(KCompsSipUriInvalid1) && KUriUtilsErrInvalidPort != aError || 0==aSipUri.Compare(KCompsSipUriInvalid4) && KUriUtilsErrInvalidPort!= aError || 0==aSipUri.Compare(KCompsSipUriNotEqual2) && KUriUtilsErrDifferentPort != aError) { iTestHarness->LogIt(KCompsSipUriInvalidMess3); wrongError=ETrue; } if (0==aSipUri.Compare(KCompsSipUriInvalid7) && KUriUtilsErrInvalidUserInfo!= aError || 0==aSipUri.Compare(KCompsSipUriNotEqual0) && KUriUtilsErrDifferentUserInfo != aError) { iTestHarness->LogIt(KCompsSipUriInvalidMess7); wrongError=ETrue; } if (wrongError) { iTestHarness->LogIt(KCompsSipUriInvalidMess5); } LogErrorMessage(aSipUri, aError); if (wrongError) { iTestHarness->EndTest(aError); } else { iTestHarness->EndTest(KErrNone); } }
int CiSeries::getSpeeds() { GLogger.LogMessage("iSeries::getSpeeds enter\n", 3); if (!_adapter->mConnected) return -1; double spindlespeed=0, feedrate=0; ODBSPEED speed; /* Data type. 0 ( feed rate ), 1 ( spindle speed ) , -1 ( all ) */ short ret = cnc_rdspeed(_adapter->mFlibhndl, -1, &speed); if (ret == EW_OK) { spindlespeed=speed.acts.data; if(speed.acts.dec>0) spindlespeed=spindlespeed / pow( 10.0, (double) speed.acts.dec); feedrate=speed.actf.data; if(speed.actf.dec>0) feedrate=feedrate / pow( 10.0, (double) speed.actf.dec); } else // Error { GLogger.Warning(StdStringFormat("Error: iSeries::getSpeeds=%d\n", ret)); LogErrorMessage("Error: iSeries::cnc_rdspeed", ret); } if(spindlespeed==0) { std::string feed,X, Y, Z, A, B,mode,execution; mode=_adapter->GetMTCTagValue("controllermode"); execution=_adapter->GetMTCTagValue("execution"); feed=_adapter->GetMTCTagValue("path_feedratefrt"); X=_adapter->GetMTCTagValue("Xabs"); Y=_adapter->GetMTCTagValue("Yabs"); Z=_adapter->GetMTCTagValue("Zabs"); A=_adapter->GetMTCTagValue("Aabs"); B=_adapter->GetMTCTagValue("Babs"); // If moving and in auto mode, assume spindle on if( (mode == "AUTOMATIC" ) && (execution == "EXECUTING" )&& ( lastFeed!=feed || lastX!=X || lastY!= Y || lastZ!=Z //|| lastA!=A //||lastB!=B ) ) mLag=4; // 3 cycles - 3 seconds; else mLag--; if(mLag<0) mLag=0; if(mLag>0) { spindlespeed = 99.0; // _adapter->SetMTCTagValue("Srpm","99.0"); } else { spindlespeed = 0; // _adapter->SetMTCTagValue("Srpm","0"); } } _adapter->SetMTCTagValue("path_feedratefrt", StdStringFormat("%8.4f", feedrate)); _adapter->SetMTCTagValue("Srpm", StdStringFormat("%8.4f", spindlespeed)); GLogger.LogMessage("iSeries::getSpeeds done\n", 3); GLogger.LogMessage("iSeries::getSpindleLoad\n", 5); #if 1 short nspd; ret = cnc_rdnspdl(_adapter->mFlibhndl, &nspd); if (ret != EW_OK) { LOGONCE GLogger.Fatal("iSeries::cnc_rdnspdl Failed\n"); return -1; } ODBSPN *load = static_cast<ODBSPN *>(alloca(nspd * sizeof(ODBSPN))); //ODBSPLOAD load[MAX_SPINDLES]; /* 4 = maximum spinlde number */ ret = cnc_rdspload (_adapter->mFlibhndl, -1, load); if (ret != EW_OK) { LOGONCE GLogger.Fatal(StdStringFormat("iSeries::cnc_rdspload Failed\n")); return ret; } _adapter->SetMTCTagValue("Sload", StdStringFormat("%8.4f", load[0].data[0])); #endif GLogger.LogMessage("iSeries::getLoads Leave\n", 3); return EW_OK; }
int CiSeries::getStatus() { GLogger.LogMessage("iSeries::getStatus Enter\n", 3); if (!_adapter->mConnected) return -1; short ret; IODBSGNL sgnl; /// Difference 15i versus 16/18/.. i series if (EW_OK == (ret=cnc_rdopnlsgnl(_adapter->mFlibhndl, 0xFFFF, &sgnl))) { std::string sFovr = StdStringFormat("%d", (int) sgnl.feed_ovrd ); // Broken? //_adapter->SetMTCTagValue("path_feedrateovr", sFovr); _adapter->SetMTCTagValue("path_feedrateovr", "100"); _adapter->SetMTCTagValue("Sovr", "100"); } else { _adapter->SetMTCTagValue("Sovr", "100"); _adapter->SetMTCTagValue("path_feedrateovr", "100"); GLogger.Warning(StdStringFormat("Error: iSeries::cnc_rdopnlsgnl=%d\n", ret)); LogErrorMessage("Error: iSeries::cnc_rdopnlsgnl", ret); } //this one may fail // bit 6 : Spindle override signal (only Series 15) //if(EW_OK == cnc_rdopnlsgnl(_adapter->mFlibhndl, 0x40, &sgnl)) // _adapter->SetMTCTagValue("Sovr", StdStringFormat("%8.4f", sgnl.spdl_ovrd * 10.0)); ODBST status; ret = cnc_statinfo(_adapter->mFlibhndl, &status); if (ret == EW_OK) { GLogger.Info(StdStringFormat("Controller mode iSeries::cnc_statinfo=%d\n", status.aut)); // Series 16/18/21/0/Power Mate if (status.aut == 0) // MDI for aut _adapter->SetMTCTagValue("controllermode", "MANUAL"); else if (status.aut != 2) // Other than no selection or MDI _adapter->SetMTCTagValue("controllermode", "AUTOMATIC"); else _adapter->SetMTCTagValue("controllermode", "MANUAL"); /** run Status of automatic operation 0 : ****(reset) 1 : STOP 2 : HOLD 3 : STaRT 4 : MSTR(during retraction and re-positioning of tool retraction and recovery, and operation of JOG MDI) */ GLogger.Info(StdStringFormat("Execution mode iSeries::cnc_statinfo=%d\n", status.run)); if(status.run == 0 ) _adapter->SetMTCTagValue("execution", "IDLE"); else if (status.run == 1 || status.run == 2) // STOP or HOLD is ePAUSED _adapter->SetMTCTagValue("execution", "PAUSED"); else if (status.run >2) // STaRT _adapter->SetMTCTagValue("execution", "EXECUTING"); //else if (status.run ==4) // _adapter->SetMTCTagValue("execution", "PAUSED"); //else // _adapter->SetMTCTagValue("execution", "PAUSED"); } else { _adapter->disconnect(); } GLogger.LogMessage("iSeries::getStatus Leave\n", 3); return EW_OK; }
int CiSeries::getLine() { GLogger.LogMessage("iSeries::getLine Enter\n", 3); std::string prognum,progname; short ret; if (!_adapter->mConnected) return -1; GLogger.Info("iSeries::getLine\n"); ODBSEQ block; ret = cnc_rdseqnum(_adapter->mFlibhndl, &block ); // 15,16,18,21,0,powermate if (ret == EW_OK) { _adapter->SetMTCTagValue("line", StdStringFormat("%d", block.data)); } else { GLogger.Info(StdStringFormat("Error iSeries::cnc_rdseqnum=%d\n", ret)); } ODBPRO buf ; ret = cnc_rdprgnum( _adapter->mFlibhndl, &buf ) ; // 15,16,18,21,0,powermate if (ret == EW_OK) { //prognum=StdStringFormat("O%04hd", buf.data); // mdata - Main program number. data- Running program number. prognum=StdStringFormat("O%04d", buf.data); // mdata - Main program number. data- Running program number. GLogger.Info(StdStringFormat("iSeries::cnc_rdprgnum prognum = %d\n", buf.mdata)); GLogger.Info(StdStringFormat("iSeries::cnc_rdprgnum prognum = %d\n",(int) (buf.mdata&0xFFFF))); GLogger.Info(StdStringFormat("iSeries::cnc_rdprgnum prognum data = %d\n",(int) (buf.data&0xFFFF))); } else { GLogger.Info(StdStringFormat("Error CiSeries::cnc_rdprgnum=%d", ret)); LogErrorMessage(" CiSeries::cnc_rdprgnum FAILED\n", ret ); } if(1) // Globals.ProgramLogic == "FirstComment") { short i, blk; unsigned short num; short top = 0; char prg[BUFSIZE+1]; std::string sLine; //do { num = BUFSIZE; ret = cnc_rdexecprog(_adapter->mFlibhndl,&num, &blk, prg); if ( ret == EW_LENGTH ) { LogErrorMessage(" iSeries::cnc_rdexecprog FAILED Length Error\n", ret ); goto error; } if ( ret ) { LogErrorMessage("iSeries::cnc_rdexecprog NOSPECIFIC ERROR\n", ret ); goto error; } // Find first comment ( ) SHOULD BE ON FIRST LINE // Extract comment, if not null assign to progname, which is output as program to MTConnect { //sLine = prg[i].comment; sLine = prg; // [i].comment; int n = sLine.find("("); int m= sLine.find(")"); if(std::string::npos ==n && std::string::npos ==m) { LOGONCE GLogger.Fatal(StdStringFormat("Didn't find comment %s\n",sLine.c_str())); goto error; } sLine= sLine.substr(n+1,m-n-1); if(!sLine.empty() && sLine != "()") { // GLogger.Fatal(StdStringFormat("Program Name = %s\n",sLine.c_str())); progname=sLine; } } } error: if(!progname.empty()) { _adapter->SetMTCTagValue("program", progname); } else if(!prognum.empty()) { _adapter->SetMTCTagValue("program", prognum); } else { _adapter->SetMTCTagValue("program", "O1"); } GLogger.LogMessage("iSeries::getLine Leave\n", 3); return EW_OK; }
bool FEditorBuildUtils::EditorAutomatedBuildAndSubmit( const FEditorAutomatedBuildSettings& BuildSettings, FText& OutErrorMessages ) { // Assume the build is successful to start bool bBuildSuccessful = true; // Keep a set of packages that should be submitted to source control at the end of a successful build. The build preparation and processing // will add and remove from the set depending on build settings, errors, etc. TSet<UPackage*> PackagesToSubmit; // Perform required preparations for the automated build process bBuildSuccessful = PrepForAutomatedBuild( BuildSettings, PackagesToSubmit, OutErrorMessages ); // If the preparation went smoothly, attempt the actual map building process if ( bBuildSuccessful ) { bBuildSuccessful = EditorBuild( GWorld, EBuildOptions::BuildAllSubmit ); // If the map build failed, log the error if ( !bBuildSuccessful ) { LogErrorMessage( NSLOCTEXT("UnrealEd", "AutomatedBuild_Error_BuildFailed", "The map build failed or was canceled."), OutErrorMessages ); } } // If any map errors resulted from the build, process them according to the behavior specified in the build settings if ( bBuildSuccessful && FMessageLog("MapCheck").NumMessages( EMessageSeverity::Warning ) > 0 ) { bBuildSuccessful = ProcessAutomatedBuildBehavior( BuildSettings.BuildErrorBehavior, NSLOCTEXT("UnrealEd", "AutomatedBuild_Error_MapErrors", "Map errors occurred while building.\n\nAttempt to continue the build?"), OutErrorMessages ); } // If it's still safe to proceed, attempt to save all of the level packages that have been marked for submission if ( bBuildSuccessful ) { UPackage* CurOutermostPkg = GWorld->PersistentLevel->GetOutermost(); FString PackagesThatFailedToSave; // Try to save the p-level if it should be submitted if ( PackagesToSubmit.Contains( CurOutermostPkg ) && !FEditorFileUtils::SaveLevel( GWorld->PersistentLevel ) ) { // If the p-level failed to save, remove it from the set of packages to submit PackagesThatFailedToSave += FString::Printf( TEXT("%s\n"), *CurOutermostPkg->GetName() ); PackagesToSubmit.Remove( CurOutermostPkg ); } // Try to save each streaming level (if they should be submitted) for ( TArray<ULevelStreaming*>::TIterator LevelIter( GWorld->StreamingLevels ); LevelIter; ++LevelIter ) { ULevelStreaming* CurStreamingLevel = *LevelIter; if ( CurStreamingLevel != NULL ) { ULevel* Level = CurStreamingLevel->GetLoadedLevel(); if ( Level != NULL ) { CurOutermostPkg = Level->GetOutermost(); if ( PackagesToSubmit.Contains( CurOutermostPkg ) && !FEditorFileUtils::SaveLevel( Level ) ) { // If a save failed, remove the streaming level from the set of packages to submit PackagesThatFailedToSave += FString::Printf( TEXT("%s\n"), *CurOutermostPkg->GetName() ); PackagesToSubmit.Remove( CurOutermostPkg ); } } } } // If any packages failed to save, process the behavior specified by the build settings to see how the process should proceed if ( PackagesThatFailedToSave.Len() > 0 ) { bBuildSuccessful = ProcessAutomatedBuildBehavior( BuildSettings.FailedToSaveBehavior, FText::Format( NSLOCTEXT("UnrealEd", "AutomatedBuild_Error_FilesFailedSave", "The following assets failed to save and cannot be submitted:\n\n{0}\n\nAttempt to continue the build?"), FText::FromString(PackagesThatFailedToSave) ), OutErrorMessages ); } } // If still safe to proceed, make sure there are actually packages remaining to submit if ( bBuildSuccessful ) { bBuildSuccessful = PackagesToSubmit.Num() > 0; if ( !bBuildSuccessful ) { LogErrorMessage( NSLOCTEXT("UnrealEd", "AutomatedBuild_Error_NoValidLevels", "None of the current levels are valid for submission; automated build aborted."), OutErrorMessages ); } } // Finally, if everything has gone smoothly, submit the requested packages to source control if ( bBuildSuccessful ) { SubmitPackagesForAutomatedBuild( PackagesToSubmit, BuildSettings ); } // Check if the user requested the editor shutdown at the conclusion of the automated build if ( BuildSettings.bShutdownEditorOnCompletion ) { FPlatformMisc::RequestExit( false ); } return bBuildSuccessful; }
/** * Helper method designed to perform the necessary preparations required to complete an automated editor build * * @param BuildSettings Build settings that will be used for the editor build * @param OutPkgsToSubmit Set of packages that need to be saved and submitted after a successful build * @param OutErrorMessages Errors that resulted from the preparation (may or may not force the build to stop, depending on build settings) * * @return true if the preparation was successful and the build should continue; false if the preparation failed and the build should be aborted */ bool FEditorBuildUtils::PrepForAutomatedBuild( const FEditorAutomatedBuildSettings& BuildSettings, TSet<UPackage*>& OutPkgsToSubmit, FText& OutErrorMessages ) { // Assume the preparation is successful to start bool bBuildSuccessful = true; OutPkgsToSubmit.Empty(); ISourceControlProvider& SourceControlProvider = ISourceControlModule::Get().GetProvider(); // Source control is required for the automated build, so ensure that SCC support is compiled in and // that the server is enabled and available for use if ( !ISourceControlModule::Get().IsEnabled() || !SourceControlProvider.IsAvailable() ) { bBuildSuccessful = false; LogErrorMessage( NSLOCTEXT("UnrealEd", "AutomatedBuild_Error_SCCError", "Cannot connect to source control; automated build aborted."), OutErrorMessages ); } // Empty changelists aren't allowed; abort the build if one wasn't provided if ( bBuildSuccessful && BuildSettings.ChangeDescription.Len() == 0 ) { bBuildSuccessful = false; LogErrorMessage( NSLOCTEXT("UnrealEd", "AutomatedBuild_Error_NoCLDesc", "A changelist description must be provided; automated build aborted."), OutErrorMessages ); } TArray<UPackage*> PreviouslySavedWorldPackages; TArray<UPackage*> PackagesToCheckout; TArray<ULevel*> LevelsToSave; if ( bBuildSuccessful ) { TArray<UWorld*> AllWorlds; FString UnsavedWorlds; EditorLevelUtils::GetWorlds( GWorld, AllWorlds, true ); // Check all of the worlds that will be built to ensure they have been saved before and have a filename // associated with them. If they don't, they won't be able to be submitted to source control. FString CurWorldPkgFileName; for ( TArray<UWorld*>::TConstIterator WorldIter( AllWorlds ); WorldIter; ++WorldIter ) { const UWorld* CurWorld = *WorldIter; check( CurWorld ); UPackage* CurWorldPackage = CurWorld->GetOutermost(); check( CurWorldPackage ); if ( FPackageName::DoesPackageExist( CurWorldPackage->GetName(), NULL, &CurWorldPkgFileName ) ) { PreviouslySavedWorldPackages.AddUnique( CurWorldPackage ); // Add all packages which have a corresponding file to the set of packages to submit for now. As preparation continues // any packages that can't be submitted due to some error will be removed. OutPkgsToSubmit.Add( CurWorldPackage ); } else { UnsavedWorlds += FString::Printf( TEXT("%s\n"), *CurWorldPackage->GetName() ); } } // If any of the worlds haven't been saved before, process the build setting's behavior to see if the build // should proceed or not if ( UnsavedWorlds.Len() > 0 ) { bBuildSuccessful = ProcessAutomatedBuildBehavior( BuildSettings.NewMapBehavior, FText::Format( NSLOCTEXT("UnrealEd", "AutomatedBuild_Error_UnsavedMap", "The following levels have never been saved before and cannot be submitted:\n\n{0}\n\nAttempt to continue the build?"), FText::FromString(UnsavedWorlds) ), OutErrorMessages ); } } // Load the asset tools module FAssetToolsModule& AssetToolsModule = FModuleManager::GetModuleChecked<FAssetToolsModule>("AssetTools"); if ( bBuildSuccessful ) { // Update the source control status of any relevant world packages in order to determine which need to be // checked out, added to the depot, etc. SourceControlProvider.Execute( ISourceControlOperation::Create<FUpdateStatus>(), SourceControlHelpers::PackageFilenames(PreviouslySavedWorldPackages) ); FString PkgsThatCantBeCheckedOut; for ( TArray<UPackage*>::TConstIterator PkgIter( PreviouslySavedWorldPackages ); PkgIter; ++PkgIter ) { UPackage* CurPackage = *PkgIter; const FString CurPkgName = CurPackage->GetName(); FSourceControlStatePtr SourceControlState = SourceControlProvider.GetState(CurPackage, EStateCacheUsage::ForceUpdate); if( !SourceControlState.IsValid() || (!SourceControlState->IsSourceControlled() && !SourceControlState->IsUnknown() && !SourceControlState->IsIgnored())) { FString CurFilename; if ( FPackageName::DoesPackageExist( CurPkgName, NULL, &CurFilename ) ) { if ( IFileManager::Get().IsReadOnly( *CurFilename ) ) { PkgsThatCantBeCheckedOut += FString::Printf( TEXT("%s\n"), *CurPkgName ); OutPkgsToSubmit.Remove( CurPackage ); } } } else if(SourceControlState->CanCheckout()) { PackagesToCheckout.Add( CurPackage ); } else { PkgsThatCantBeCheckedOut += FString::Printf( TEXT("%s\n"), *CurPkgName ); OutPkgsToSubmit.Remove( CurPackage ); } } // If any of the packages can't be checked out or are read-only, process the build setting's behavior to see if the build // should proceed or not if ( PkgsThatCantBeCheckedOut.Len() > 0 ) { bBuildSuccessful = ProcessAutomatedBuildBehavior( BuildSettings.UnableToCheckoutFilesBehavior, FText::Format( NSLOCTEXT("UnrealEd", "AutomatedBuild_Error_UnsaveableFiles", "The following assets cannot be checked out of source control (or are read-only) and cannot be submitted:\n\n{0}\n\nAttempt to continue the build?"), FText::FromString(PkgsThatCantBeCheckedOut) ), OutErrorMessages ); } } if ( bBuildSuccessful ) { // Check out all of the packages from source control that need to be checked out if ( PackagesToCheckout.Num() > 0 ) { TArray<FString> PackageFilenames = SourceControlHelpers::PackageFilenames(PackagesToCheckout); SourceControlProvider.Execute( ISourceControlOperation::Create<FCheckOut>(), PackageFilenames ); // Update the package status of the packages that were just checked out to confirm that they // were actually checked out correctly SourceControlProvider.Execute( ISourceControlOperation::Create<FUpdateStatus>(), PackageFilenames ); FString FilesThatFailedCheckout; for ( TArray<UPackage*>::TConstIterator CheckedOutIter( PackagesToCheckout ); CheckedOutIter; ++CheckedOutIter ) { UPackage* CurPkg = *CheckedOutIter; FSourceControlStatePtr SourceControlState = SourceControlProvider.GetState(CurPkg, EStateCacheUsage::ForceUpdate); // If any of the packages failed to check out, remove them from the set of packages to submit if ( !SourceControlState.IsValid() || (!SourceControlState->IsCheckedOut() && !SourceControlState->IsAdded() && SourceControlState->IsSourceControlled()) ) { FilesThatFailedCheckout += FString::Printf( TEXT("%s\n"), *CurPkg->GetName() ); OutPkgsToSubmit.Remove( CurPkg ); } } // If any of the packages failed to check out correctly, process the build setting's behavior to see if the build // should proceed or not if ( FilesThatFailedCheckout.Len() > 0 ) { bBuildSuccessful = ProcessAutomatedBuildBehavior( BuildSettings.UnableToCheckoutFilesBehavior, FText::Format( NSLOCTEXT("UnrealEd", "AutomatedBuild_Error_FilesFailedCheckout", "The following assets failed to checkout of source control and cannot be submitted:\n{0}\n\nAttempt to continue the build?"), FText::FromString(FilesThatFailedCheckout)), OutErrorMessages ); } } } // Verify there are still actually any packages left to submit. If there aren't, abort the build and warn the user of the situation. if ( bBuildSuccessful ) { bBuildSuccessful = OutPkgsToSubmit.Num() > 0; if ( !bBuildSuccessful ) { LogErrorMessage( NSLOCTEXT("UnrealEd", "AutomatedBuild_Error_NoValidLevels", "None of the current levels are valid for submission; automated build aborted."), OutErrorMessages ); } } // If the build is safe to commence, force all of the levels visible to make sure the build operates correctly if ( bBuildSuccessful ) { bool bVisibilityToggled = false; if ( !FLevelUtils::IsLevelVisible( GWorld->PersistentLevel ) ) { EditorLevelUtils::SetLevelVisibility( GWorld->PersistentLevel, true, false ); bVisibilityToggled = true; } for ( TArray<ULevelStreaming*>::TConstIterator LevelIter( GWorld->StreamingLevels ); LevelIter; ++LevelIter ) { ULevelStreaming* CurStreamingLevel = *LevelIter; if ( CurStreamingLevel && !FLevelUtils::IsLevelVisible( CurStreamingLevel ) ) { CurStreamingLevel->bShouldBeVisibleInEditor = true; bVisibilityToggled = true; } } if ( bVisibilityToggled ) { GWorld->FlushLevelStreaming(); } } return bBuildSuccessful; }