bool EXCELLON_IMAGE::readToolInformation( char*& aText ) { // Read a tool definition like T1C0.02 or T1F00S00C0.02 or T1C0.02F00S00 // and enter the TCODE param in list (using the D_CODE param management, which // is similar to TCODE params. if( *aText == 'T' ) // This is the beginning of the definition aText++; // Read tool number: int iprm = ReadInt( aText, false ); // Skip Feed rate and Spindle speed, if any here while( *aText && ( *aText == 'F' || *aText == 'S' ) ) { aText++; ReadInt( aText, false ); } // Read tool shape if( ! *aText ) ReportMessage( wxString:: Format( _( "Tool definition shape not found" ) ) ); else if( *aText != 'C' ) ReportMessage( wxString:: Format( _( "Tool definition '%c' not supported" ), *aText ) ); if( *aText ) aText++; //read tool diameter: double dprm = ReadDouble( aText, false ); m_Has_DCode = true; // Initialize Dcode to handle this Tool // Remember: dcodes are >= FIRST_DCODE D_CODE* dcode = GetDCODE( iprm + FIRST_DCODE ); if( dcode == NULL ) return false; // conv_scale = scaling factor from inch to Internal Unit double conv_scale = IU_PER_MILS * 1000; if( m_GerbMetric ) conv_scale /= 25.4; dcode->m_Size.x = dcode->m_Size.y = KiROUND( dprm * conv_scale ); dcode->m_Shape = APT_CIRCLE; dcode->m_Defined = true; return true; }
void verlet(const char* filename){ dictionary* ini; ini = iniparser_load(filename); iniparser_dump(ini, stdout); FILE *file; file = fopen(LOGFILE, "a"); iniparser_dump(ini, file); fclose(file); ReportMessage("\n"); t_key key = key_init(ini); t_pSys pSys = pSys_init (ini); t_opts opts = opts_init (ini); t_pair p = t_pair_init(ini); t_dump dump = dump_init(ini); t_fix fix = fix_init(ini); t_compute compute = compute_init(ini, &key); init (&key, &pSys, &opts, &p, &compute); if(key.dump) dump_run(&key, &pSys, &opts, &dump); // Make initial snapshot. while(opts.thisIter < opts.targIters){ // Repeat until iterational limit. verlet_iter (&key, &pSys, &opts, &p, &fix, &compute); if(key.dump) dump_run(&key, &pSys, &opts, &dump); resetStep(&pSys); } }
bool EXCELLON_IMAGE::Execute_Drill_Command( char*& text ) { D_CODE* tool; GERBER_DRAW_ITEM * gbritem; while( true ) { switch( *text ) { case 'X': ReadXYCoord( text ); break; case 'Y': ReadXYCoord( text ); break; case 'G': // G85 is found here for oval holes m_PreviousPos = m_CurrentPos; Execute_EXCELLON_G_Command( text ); break; case 0: // E.O.L: execute command tool = GetDCODE( m_Current_Tool, false ); if( !tool ) { wxString msg; msg.Printf( _( "Tool <%d> not defined" ), m_Current_Tool ); ReportMessage( msg ); return false; } gbritem = new GERBER_DRAW_ITEM( GetParent()->GetBoard(), this ); GetParent()->GetBoard()->m_Drawings.Append( gbritem ); if( m_SlotOn ) // Oval hole { fillLineGBRITEM( gbritem, tool->m_Num_Dcode, GetParent()->getActiveLayer(), m_PreviousPos, m_CurrentPos, tool->m_Size, false ); } else { fillFlashedGBRITEM( gbritem, tool->m_Shape, tool->m_Num_Dcode, GetParent()->getActiveLayer(), m_CurrentPos, tool->m_Size, false ); } StepAndRepeatItem( *gbritem ); m_PreviousPos = m_CurrentPos; return true; break; default: text++; break; } } return true; }
void* THREAD_FUNC(void *args) { int tid = *((int*)args); bool useCerr = tid % 2; for(int x = 0; x < 100; ++x) { std::stringstream ss; ss << "TID[ " << tid << " ] - Message " << x; std::string s(ss.str()); ReportMessage(s, useCerr); } }
bool GERBER_IMAGE::ExecuteRS274XCommand( int command, char buff[GERBER_BUFZ], char*& text ) { int code; int xy_seq_len; // not used, provided but not yet in use int xy_seq_char; bool ok = true; char line[GERBER_BUFZ]; wxString msg; double fcoord; // conv_scale = scaling factor from inch to Internal Unit double conv_scale = IU_PER_MILS * 1000; if( m_GerbMetric ) conv_scale /= 25.4; // D( printf( "%22s: Command <%c%c>\n", __func__, (command >> 8) & 0xFF, command & 0xFF ); ) switch( command ) { case FORMAT_STATEMENT: xy_seq_len = 2; while( *text != '*' ) { switch( *text ) { case ' ': text++; break; case 'L': // No Leading 0 m_DecimalFormat = false; m_NoTrailingZeros = false; text++; break; case 'T': // No trailing 0 m_DecimalFormat = false; m_NoTrailingZeros = true; text++; break; case 'D': // Decimal format: sometimes found, but not really documented m_DecimalFormat = true; text++; break; case 'A': // Absolute coord m_Relative = false; text++; break; case 'I': // Relative coord m_Relative = true; text++; break; case 'N': // Sequence code (followed by the number of digits // for the X,Y command text++; xy_seq_char = *text++; if( (xy_seq_char >= '0') && (xy_seq_char <= '9') ) xy_seq_len = -'0'; break; case 'X': case 'Y': // Values transmitted :2 (really xy_seq_len : // digits { code = *(text++); char ctmp = *(text++) - '0'; if( code == 'X' ) { xy_seq_len--; // number of digits after the decimal point (0 to 6 allowed) m_FmtScale.x = *text - '0'; m_FmtLen.x = ctmp + m_FmtScale.x; // m_FmtScale is 0 to 6 if( m_FmtScale.x < 0 ) m_FmtScale.x = 0; if( m_FmtScale.x > 6 ) m_FmtScale.x = 6; } else { xy_seq_len--; m_FmtScale.y = *text - '0'; m_FmtLen.y = ctmp + m_FmtScale.y; if( m_FmtScale.y < 0 ) m_FmtScale.y = 0; if( m_FmtScale.y > 6 ) m_FmtScale.y = 6; } text++; } break; case '*': break; default: GetEndOfBlock( buff, text, m_Current_File ); ok = false; break; } } if( xy_seq_len != 0 ) { ReportMessage( wxT( "RS274X: suspicious Format Statement (FS) command" ) ); } break; case AXIS_SELECT: // command ASAXBY*% or %ASAYBX*% m_SwapAxis = false; if( strnicmp( text, "AYBX", 4 ) == 0 ) m_SwapAxis = true; break; case MIRROR_IMAGE: // commanf %MIA0B0*%, %MIA0B1*%, %MIA1B0*%, %MIA1B1*% m_MirrorA = m_MirrorB = 0; while( *text && *text != '*' ) { switch( *text ) { case 'A': // Mirror A axis ? text++; if( *text == '1' ) m_MirrorA = true; break; case 'B': // Mirror B axis ? text++; if( *text == '1' ) m_MirrorB = true; break; default: text++; break; } } break; case MODE_OF_UNITS: code = ReadXCommand( text ); if( code == INCH ) m_GerbMetric = false; else if( code == MILLIMETER ) m_GerbMetric = true; conv_scale = m_GerbMetric ? IU_PER_MILS / 25.4 : IU_PER_MILS; break; case OFFSET: // command: OFAnnBnn (nn = float number) = layer Offset m_Offset.x = m_Offset.y = 0; while( *text != '*' ) { switch( *text ) { case 'A': // A axis offset in current unit (inch or mm) text++; fcoord = ReadDouble( text ); m_Offset.x = KiROUND( fcoord * conv_scale ); break; case 'B': // B axis offset in current unit (inch or mm) text++; fcoord = ReadDouble( text ); m_Offset.y = KiROUND( fcoord * conv_scale ); break; } } break; case SCALE_FACTOR: m_Scale.x = m_Scale.y = 1.0; while( *text != '*' ) { switch( *text ) { case 'A': // A axis scale text++; m_Scale.x = ReadDouble( text ); break; case 'B': // B axis scale text++; m_Scale.y = ReadDouble( text ); break; } } break; case IMAGE_OFFSET: // command: IOAnnBnn (nn = float number) = Image Offset m_ImageOffset.x = m_ImageOffset.y = 0; while( *text != '*' ) { switch( *text ) { case 'A': // A axis offset in current unit (inch or mm) text++; fcoord = ReadDouble( text ); m_ImageOffset.x = KiROUND( fcoord * conv_scale ); break; case 'B': // B axis offset in current unit (inch or mm) text++; fcoord = ReadDouble( text ); m_ImageOffset.y = KiROUND( fcoord * conv_scale ); break; } } break; case IMAGE_ROTATION: // command IR0* or IR90* or IR180* or IR270* if( strnicmp( text, "0*", 2 ) == 0 ) m_ImageRotation = 0; if( strnicmp( text, "90*", 2 ) == 0 ) m_ImageRotation = 90; if( strnicmp( text, "180*", 2 ) == 0 ) m_ImageRotation = 180; if( strnicmp( text, "270*", 2 ) == 0 ) m_ImageRotation = 270; else ReportMessage( _( "RS274X: Command \"IR\" rotation value not allowed" ) ); break; case STEP_AND_REPEAT: // command SR, like %SRX3Y2I5.0J2*% m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // Start a new Gerber layer GetLayerParams().m_StepForRepeat.x = 0.0; GetLayerParams().m_StepForRepeat.x = 0.0; // offset for Step and Repeat command GetLayerParams().m_XRepeatCount = 1; GetLayerParams().m_YRepeatCount = 1; // The repeat count GetLayerParams().m_StepForRepeatMetric = m_GerbMetric; // the step units while( *text && *text != '*' ) { switch( *text ) { case 'I': // X axis offset text++; GetLayerParams().m_StepForRepeat.x = ReadDouble( text ); break; case 'J': // Y axis offset text++; GetLayerParams().m_StepForRepeat.y = ReadDouble( text ); break; case 'X': // X axis repeat count text++; GetLayerParams().m_XRepeatCount = ReadInt( text ); break; case 'Y': // Y axis offset text++; GetLayerParams().m_YRepeatCount = ReadInt( text ); break; default: text++; break; } } break; case IMAGE_JUSTIFY: // Command IJAnBn* m_ImageJustifyXCenter = false; // Image Justify Center on X axis (default = false) m_ImageJustifyYCenter = false; // Image Justify Center on Y axis (default = false) m_ImageJustifyOffset = wxPoint(0,0); // Image Justify Offset on XY axis (default = 0,0) while( *text && *text != '*' ) { // IJ command is (for A or B axis) AC or AL or A<coordinate> switch( *text ) { case 'A': // A axis justify text++; if( *text == 'C' ) { m_ImageJustifyXCenter = true; text++; } else if( *text == 'L' ) { m_ImageJustifyXCenter = true; text++; } else m_ImageJustifyOffset.x = KiROUND( ReadDouble( text ) * conv_scale); break; case 'B': // B axis justify text++; if( *text == 'C' ) { m_ImageJustifyYCenter = true; text++; } else if( *text == 'L' ) { m_ImageJustifyYCenter = true; text++; } else m_ImageJustifyOffset.y = KiROUND( ReadDouble( text ) * conv_scale); break; default: text++; break; } } if( m_ImageJustifyXCenter ) m_ImageJustifyOffset.x = 0; if( m_ImageJustifyYCenter ) m_ImageJustifyOffset.y = 0; break; case KNOCKOUT: m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // Start a new Gerber layer msg = _( "RS274X: Command KNOCKOUT ignored by GerbView" ) ; ReportMessage( msg ); break; case PLOTTER_FILM: // Command PF <string> // This is an info about film that must be used to plot this file // Has no meaning here. We just display this string msg = wxT( "Plotter Film info:<br>" ); while( *text != '*' ) { msg.Append( *text++ ); } ReportMessage( msg ); break; case ROTATE: // Layer rotation: command like %RO45*% m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // Start a new Gerber layer m_LocalRotation =ReadDouble( text ); // Store layer rotation in degrees break; case IMAGE_NAME: m_ImageName.Empty(); while( *text != '*' ) { m_ImageName.Append( *text++ ); } break; case LAYER_NAME: m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // Start a new Gerber layer GetLayerParams( ).m_LayerName.Empty(); while( *text != '*' ) { GetLayerParams( ).m_LayerName.Append( *text++ ); } break; case IMAGE_POLARITY: if( strnicmp( text, "NEG", 3 ) == 0 ) m_ImageNegative = true; else m_ImageNegative = false; D( printf( "%22s: IMAGE_POLARITY m_ImageNegative=%s\n", __func__, m_ImageNegative ? "true" : "false" ); ) break; case LAYER_POLARITY: if( *text == 'C' ) GetLayerParams().m_LayerNegative = true; else GetLayerParams().m_LayerNegative = false; D( printf( "%22s: LAYER_POLARITY m_LayerNegative=%s\n", __func__, GetLayerParams().m_LayerNegative ? "true" : "false" ); ) break;
bool EXCELLON_IMAGE::Execute_EXCELLON_G_Command( char*& text ) { EXCELLON_CMD* cmd = NULL; bool success = false; int id = DRILL_G_UNKNOWN; // Search command in list EXCELLON_CMD* candidate; char * gcmd = text; // gcmd points the G command, for error messages. for( unsigned ii = 0; ; ii++ ) { candidate = &excellon_G_CmdList[ii]; int len = candidate->m_Name.size(); if( len == 0 ) // End of list reached break; if( candidate->m_Name.compare( 0, len, text, len ) == 0 ) // found. { cmd = candidate; text += len; success = true; id = cmd->m_Code; break; } } switch( id ) { case DRILL_G_ZERO_SET: ReadXYCoord( text ); m_Offset = m_CurrentPos; break; case DRILL_G_ROUT: m_SlotOn = false; m_PolygonFillMode = true; break; case DRILL_G_DRILL: m_SlotOn = false; m_PolygonFillMode = false; break; case DRILL_G_SLOT: m_SlotOn = true; break; case DRILL_G_LINEARMOVE: m_Iterpolation = GERB_INTERPOL_LINEAR_1X; break; case DRILL_G_CWMOVE: m_Iterpolation = GERB_INTERPOL_ARC_NEG; break; case DRILL_G_CCWMOVE: m_Iterpolation = GERB_INTERPOL_ARC_POS; break; case DRILL_G_ABSOLUTE: m_Relative = false; // false = absolute coord break; case DRILL_G_INCREMENTAL: m_Relative = true; // true = relative coord break; case DRILL_G_UNKNOWN: default: { wxString msg; msg.Printf( _( "Unknown Excellon G Code: <%s>" ), GetChars(FROM_UTF8(gcmd)) ); ReportMessage( msg ); while( *text ) text++; return false; } } return success; }
bool EXCELLON_IMAGE::Execute_HEADER_Command( char*& text ) { EXCELLON_CMD* cmd = NULL; int iprm; double dprm; D_CODE* dcode; wxString msg; // Search command in list EXCELLON_CMD* candidate; for( unsigned ii = 0; ; ii++ ) { candidate = &excellonHeaderCmdList[ii]; int len = candidate->m_Name.size(); if( len == 0 ) // End of list reached break; if( candidate->m_Name.compare( 0, len, text, len ) == 0 ) // found. { cmd = candidate; text += len; break; } } if( !cmd ) { msg.Printf( wxT( "Unknown Excellon command <%s>" ), text ); ReportMessage( msg ); while( *text ) text++; return false; } // Execute command // some do nothing switch( cmd->m_Code ) { case DRILL_SKIP: case DRILL_M_UNKNOWN: break; case DRILL_M_END: break; case DRILL_M_ENDREWIND: break; case DRILL_M_MESSAGE: break; case DRILL_M_LONGMESSAGE: break; case DRILL_M_HEADER: m_State = READ_HEADER_STATE; break; case DRILL_M_ENDHEADER: m_State = READ_PROGRAM_STATE; break; case DRILL_REWIND_STOP: // TODO: what this command really is ? m_State = READ_PROGRAM_STATE; break; case DRILL_M_METRIC: SelectUnits( true ); break; case DRILL_METRICHEADER: // command like METRIC,TZ or METRIC,LZ SelectUnits( true ); if( *text != ',' ) { ReportMessage( _( "METRIC command has no parameter" ) ); break; } text++; // skip separator if( *text == 'T' ) m_NoTrailingZeros = false; else m_NoTrailingZeros = true; break; case DRILL_M_IMPERIAL: SelectUnits( false ); break; case DRILL_IMPERIALHEADER: // command like INCH,TZ or INCH,LZ SelectUnits( false ); if( *text != ',' ) { ReportMessage( _( "INCH command has no parameter" ) ); break; } text++; // skip separator if( *text == 'T' ) m_NoTrailingZeros = false; else m_NoTrailingZeros = true; break; case DRILL_M_BEGINPATTERN: break; case DRILL_M_ENDPATTERN: break; case DRILL_M_CANNEDTEXT: break; case DRILL_M_TIPCHECK: break; case DRILL_DETECT_BROKEN: break; case DRILL_INCREMENTALHEADER: m_Relative = true; break; case DRILL_TOOL_CHANGE_STOP: break; case DRILL_AUTOMATIC_SPEED: break; case DRILL_AXIS_VERSION: break; case DRILL_RESET_CMD: break; case DRILL_AUTOMATIC_TOOL_CHANGE: break; case DRILL_FMT: break; case DRILL_TOOL_INFORMATION: // Read a tool definition like T1C0.02: // Read tool number: iprm = ReadInt( text, false ); // Read tool shape if( *text != 'C' ) ReportMessage( _( "Tool definition <%c> not supported" ) ); if( *text ) text++; //read tool diameter: dprm = ReadDouble( text, false ); m_Has_DCode = true; // Initialize Dcode to handle this Tool dcode = GetDCODE( iprm + FIRST_DCODE ); // Remember: dcodes are >= FIRST_DCODE if( dcode == NULL ) break; double conv_scale = m_GerbMetric ? PCB_INTERNAL_UNIT / 25.4 : PCB_INTERNAL_UNIT; dcode->m_Size.x = dcode->m_Size.y = wxRound( dprm * conv_scale ); dcode->m_Shape = APT_CIRCLE; break; } while( *text ) text++; return true; }
extern "C" DWORD UnInstallLoopBack(void) { BOOL ok; DWORD ret = 0; GUID netGuid; HDEVINFO hDeviceInfo = INVALID_HANDLE_VALUE; SP_DEVINFO_DATA DeviceInfoData; DWORD index = 0; BOOL found = FALSE; DWORD size = 0; // initialize the structure size DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA); // copy the net class GUID memcpy(&netGuid, &GUID_DEVCLASS_NET, sizeof(GUID_DEVCLASS_NET)); // return a device info set contains all installed devices of the Net class hDeviceInfo = SetupDiGetClassDevs(&netGuid, NULL, NULL, DIGCF_PRESENT); if (hDeviceInfo == INVALID_HANDLE_VALUE) return GetLastError(); // enumerate the driver info list while (TRUE) { TCHAR * deviceHwid; ok = SetupDiEnumDeviceInfo(hDeviceInfo, index, &DeviceInfoData); if(!ok) { if(GetLastError() == ERROR_NO_MORE_ITEMS) break; else { index++; continue; } } // try to get the DeviceDesc registry property ok = SetupDiGetDeviceRegistryProperty(hDeviceInfo, &DeviceInfoData, SPDRP_HARDWAREID, NULL, NULL, 0, &size); if (!ok) { ret = GetLastError(); if (ret != ERROR_INSUFFICIENT_BUFFER) { index++; continue; } deviceHwid = (TCHAR *)malloc(size); ok = SetupDiGetDeviceRegistryProperty(hDeviceInfo, &DeviceInfoData, SPDRP_HARDWAREID, NULL, (PBYTE)deviceHwid, size, NULL); if (!ok) { free(deviceHwid); deviceHwid = NULL; index++; continue; } } else { // something is wrong. This shouldn't have worked with a NULL buffer ReportMessage(0, "GetDeviceRegistryProperty succeeded with a NULL buffer", NULL, NULL, 0); index++; continue; } for (TCHAR *t = deviceHwid; t && *t && t < &deviceHwid[size / sizeof(TCHAR)]; t += _tcslen(t) + 1) { if(!_tcsicmp(DRIVERHWID, t)) { found = TRUE; break; } } if (deviceHwid) { free(deviceHwid); deviceHwid = NULL; } if (found) break; index++; } if (found == FALSE) { ret = GetLastError(); ReportMessage(0,"Driver does not seem to be installed", DRIVER_DESC, NULL, ret); goto cleanup; } ok = SetupDiSetSelectedDevice(hDeviceInfo, &DeviceInfoData); if (!ok) { ret = GetLastError(); goto cleanup; } ok = SetupDiCallClassInstaller(DIF_REMOVE, hDeviceInfo, &DeviceInfoData); if (!ok) { ret = GetLastError(); goto cleanup; } ret = 0; cleanup: // clean up the device info set if (hDeviceInfo != INVALID_HANDLE_VALUE) SetupDiDestroyDeviceInfoList(hDeviceInfo); return ret; }
extern "C" DWORD InstallLoopBack(LPCTSTR pConnectionName, LPCTSTR ip, LPCTSTR mask) { BOOL ok; DWORD ret = 0; GUID netGuid; HDEVINFO hDeviceInfo = INVALID_HANDLE_VALUE; SP_DEVINFO_DATA DeviceInfoData; SP_DRVINFO_DATA DriverInfoData; SP_DEVINSTALL_PARAMS DeviceInstallParams; TCHAR className[MAX_PATH]; TCHAR temp[MAX_PATH]; DWORD index = 0; BOOL found = FALSE; BOOL registered = FALSE; BOOL destroyList = FALSE; PSP_DRVINFO_DETAIL_DATA pDriverInfoDetail; DWORD detailBuf[2048]; // for our purposes, 8k buffer is more // than enough to obtain the hardware ID // of the loopback driver. HKEY hkey = NULL; DWORD cbSize; DWORD dwValueType; TCHAR pCfgGuidString[40]; // initialize the structure size DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA); DriverInfoData.cbSize = sizeof(SP_DRVINFO_DATA); // copy the net class GUID memcpy(&netGuid, &GUID_DEVCLASS_NET, sizeof(GUID_DEVCLASS_NET)); // create an empty device info set associated with the net class GUID hDeviceInfo = SetupDiCreateDeviceInfoList(&netGuid, NULL); if (hDeviceInfo == INVALID_HANDLE_VALUE) return GetLastError(); // get the class name from GUID ok = SetupDiClassNameFromGuid(&netGuid, className, MAX_PATH, NULL); if (!ok) { ret = GetLastError(); goto cleanup; } // create a device info element and add the new device instance // key to registry ok = SetupDiCreateDeviceInfo(hDeviceInfo, className, &netGuid, NULL, NULL, DICD_GENERATE_ID, &DeviceInfoData); if (!ok) { ret = GetLastError(); goto cleanup; } // select the newly created device info to be the currently // selected member ok = SetupDiSetSelectedDevice(hDeviceInfo, &DeviceInfoData); if (!ok) { ret = GetLastError(); goto cleanup; } // build a list of class drivers ok = SetupDiBuildDriverInfoList(hDeviceInfo, &DeviceInfoData, SPDIT_CLASSDRIVER); if (!ok) { ret = GetLastError(); goto cleanup; } destroyList = TRUE; // enumerate the driver info list while (TRUE) { BOOL ret; ret = SetupDiEnumDriverInfo(hDeviceInfo, &DeviceInfoData, SPDIT_CLASSDRIVER, index, &DriverInfoData); // if the function failed and GetLastError() returned // ERROR_NO_MORE_ITEMS, then we have reached the end of the // list. Othewise there was something wrong with this // particular driver. if(!ret) { if(GetLastError() == ERROR_NO_MORE_ITEMS) break; else { index++; continue; } } pDriverInfoDetail = (PSP_DRVINFO_DETAIL_DATA) detailBuf; pDriverInfoDetail->cbSize = sizeof(SP_DRVINFO_DETAIL_DATA); // if we successfully find the hardware ID and it turns out to // be the one for the loopback driver, then we are done. if (SetupDiGetDriverInfoDetail(hDeviceInfo, &DeviceInfoData, &DriverInfoData, pDriverInfoDetail, sizeof(detailBuf), NULL)) { TCHAR * t; // pDriverInfoDetail->HardwareID is a MULTISZ string. Go through the // whole list and see if there is a match somewhere. t = pDriverInfoDetail->HardwareID; while (t && *t && t < (TCHAR *) &detailBuf[sizeof(detailBuf)/sizeof(detailBuf[0])]) { if (!_tcsicmp(t, DRIVERHWID)) break; t += _tcslen(t) + 1; } if (t && *t && t < (TCHAR *) &detailBuf[sizeof(detailBuf)/sizeof(detailBuf[0])]) { found = TRUE; break; } } index++; } if (!found) { ret = GetLastError(); ReportMessage(0,"Could not find the driver to install", DRIVER_DESC, NULL, 0); goto cleanup; } // set the loopback driver to be the currently selected ok = SetupDiSetSelectedDriver(hDeviceInfo, &DeviceInfoData, &DriverInfoData); if (!ok) { ret = GetLastError(); goto cleanup; } // register the phantom device to repare for install ok = SetupDiCallClassInstaller(DIF_REGISTERDEVICE, hDeviceInfo, &DeviceInfoData); if (!ok) { ret = GetLastError(); goto cleanup; } // registered, but remove if errors occur in the following code registered = TRUE; // ask the installer if we can install the device ok = SetupDiCallClassInstaller(DIF_ALLOW_INSTALL, hDeviceInfo, &DeviceInfoData); if (!ok) { ret = GetLastError(); if (ret != ERROR_DI_DO_DEFAULT) { goto cleanup; } else ret = 0; } // install the files first ok = SetupDiCallClassInstaller(DIF_INSTALLDEVICEFILES, hDeviceInfo, &DeviceInfoData); if (!ok) { ret = GetLastError(); goto cleanup; } // get the device install parameters and disable filecopy DeviceInstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS); ok = SetupDiGetDeviceInstallParams(hDeviceInfo, &DeviceInfoData, &DeviceInstallParams); if (ok) { DeviceInstallParams.Flags |= DI_NOFILECOPY; ok = SetupDiSetDeviceInstallParams(hDeviceInfo, &DeviceInfoData, &DeviceInstallParams); if (!ok) { ret = GetLastError(); goto cleanup; } } // // Register any device-specific co-installers for this device, // ok = SetupDiCallClassInstaller(DIF_REGISTER_COINSTALLERS, hDeviceInfo, &DeviceInfoData); if (!ok) { ret = GetLastError(); goto cleanup; } // // install any installer-specified interfaces. // and then do the real install // ok = SetupDiCallClassInstaller(DIF_INSTALLINTERFACES, hDeviceInfo, &DeviceInfoData); if (!ok) { ret = GetLastError(); goto cleanup; } PAUSE; ok = SetupDiCallClassInstaller(DIF_INSTALLDEVICE, hDeviceInfo, &DeviceInfoData); if (!ok) { ret = GetLastError(); PAUSE; goto cleanup; } /* Skip to the end if we aren't setting the name */ if (!pConnectionName) goto cleanup; // Figure out NetCfgInstanceId hkey = SetupDiOpenDevRegKey(hDeviceInfo, &DeviceInfoData, DICS_FLAG_GLOBAL, 0, DIREG_DRV, KEY_READ); if (hkey == INVALID_HANDLE_VALUE) { ret = GetLastError(); goto cleanup; } cbSize = sizeof(pCfgGuidString); ret = RegQueryValueEx(hkey, _T("NetCfgInstanceId"), NULL, &dwValueType, (LPBYTE)pCfgGuidString, &cbSize); RegCloseKey(hkey); ret = RenameConnection(pCfgGuidString, pConnectionName); if (ret) { ReportMessage(0,"Could not set the connection name", NULL, pConnectionName, 0); goto cleanup; } if (!ip) goto cleanup; ret = SetIpAddress(pCfgGuidString, ip, mask); if (ret) { ReportMessage(0,"Could not set the ip address and network mask",NULL,NULL,ret); goto cleanup; } ret = LoopbackBindings(pCfgGuidString); if (ret) { ReportMessage(0,"Could not properly set the bindings",NULL,NULL,0); goto cleanup; } ret = !UpdateHostsFile( pConnectionName, ip, "hosts", FALSE ); if (ret) { ReportMessage(0,"Could not update hosts file",NULL,NULL,0); goto cleanup; } ret = !UpdateHostsFile( pConnectionName, ip, "lmhosts", TRUE ); if (ret) { ReportMessage(0,"Could not update lmhosts file",NULL,NULL,0); goto cleanup; } cleanup: // an error has occured, but the device is registered, we must remove it if (ret != 0 && registered) SetupDiCallClassInstaller(DIF_REMOVE, hDeviceInfo, &DeviceInfoData); found = SetupDiDeleteDeviceInfo(hDeviceInfo, &DeviceInfoData); // destroy the driver info list if (destroyList) SetupDiDestroyDriverInfoList(hDeviceInfo, &DeviceInfoData, SPDIT_CLASSDRIVER); // clean up the device info set if (hDeviceInfo != INVALID_HANDLE_VALUE) SetupDiDestroyDeviceInfoList(hDeviceInfo); return ret; };
bool EXCELLON_IMAGE::Execute_HEADER_Command( char*& text ) { EXCELLON_CMD* cmd = NULL; int iprm; double dprm; D_CODE* dcode; wxString msg; // Search command in list EXCELLON_CMD* candidate; for( unsigned ii = 0; ; ii++ ) { candidate = &excellonHeaderCmdList[ii]; int len = candidate->m_Name.size(); if( len == 0 ) // End of list reached break; if( candidate->m_Name.compare( 0, len, text, len ) == 0 ) // found. { cmd = candidate; text += len; break; } } if( !cmd ) { msg.Printf( wxT( "Unknown Excellon command <%s>" ), text ); ReportMessage( msg ); while( *text ) text++; return false; } // Execute command // some do nothing switch( cmd->m_Code ) { case DRILL_SKIP: case DRILL_M_UNKNOWN: break; case DRILL_M_END: break; case DRILL_M_ENDREWIND: break; case DRILL_M_MESSAGE: break; case DRILL_M_LONGMESSAGE: break; case DRILL_M_HEADER: m_State = READ_HEADER_STATE; break; case DRILL_M_ENDHEADER: m_State = READ_PROGRAM_STATE; break; case DRILL_REWIND_STOP: // End of header. No action in a viewer m_State = READ_PROGRAM_STATE; break; case DRILL_M_METRIC: SelectUnits( true ); break; case DRILL_METRICHEADER: // command like METRIC,TZ or METRIC,LZ SelectUnits( true ); if( *text != ',' ) { ReportMessage( _( "METRIC command has no parameter" ) ); break; } text++; // skip separator if( *text == 'T' ) m_NoTrailingZeros = false; else m_NoTrailingZeros = true; break; case DRILL_M_IMPERIAL: SelectUnits( false ); break; case DRILL_IMPERIALHEADER: // command like INCH,TZ or INCH,LZ SelectUnits( false ); if( *text != ',' ) { ReportMessage( _( "INCH command has no parameter" ) ); break; } text++; // skip separator if( *text == 'T' ) m_NoTrailingZeros = false; else m_NoTrailingZeros = true; break; case DRILL_M_BEGINPATTERN: break; case DRILL_M_ENDPATTERN: break; case DRILL_M_CANNEDTEXT: break; case DRILL_M_TIPCHECK: break; case DRILL_DETECT_BROKEN: break; case DRILL_INCREMENTALHEADER: if( *text != ',' ) { ReportMessage( _( "ICI command has no parameter" ) ); break; } text++; // skip separator // Parameter should be ON or OFF if( strnicmp( text, "OFF", 3 ) == 0 ) m_Relative = false; else if( strnicmp( text, "ON", 2 ) == 0 ) m_Relative = true; else ReportMessage( _( "ICI command has incorrect parameter" ) ); break; case DRILL_TOOL_CHANGE_STOP: break; case DRILL_AUTOMATIC_SPEED: break; case DRILL_AXIS_VERSION: break; case DRILL_RESET_CMD: break; case DRILL_AUTOMATIC_TOOL_CHANGE: break; case DRILL_FMT: break; case DRILL_TOOL_INFORMATION: // Read a tool definition like T1C0.02: // or T1F00S00C0.02 or T1C0.02F00S00 // Read tool number: iprm = ReadInt( text, false ); // Skip Feed rate and Spindle speed, if any here while( *text && ( *text == 'F' || *text == 'S' ) ) { text++; ReadInt( text, false ); } // Read tool shape if( *text != 'C' ) ReportMessage( wxString:: Format( _( "Tool definition <%c> not supported" ), *text ) ); if( *text ) text++; //read tool diameter: dprm = ReadDouble( text, false ); m_Has_DCode = true; // Initialize Dcode to handle this Tool dcode = GetDCODE( iprm + FIRST_DCODE ); // Remember: dcodes are >= FIRST_DCODE if( dcode == NULL ) break; // conv_scale = scaling factor from inch to Internal Unit double conv_scale = IU_PER_MILS * 1000; if( m_GerbMetric ) conv_scale /= 25.4; dcode->m_Size.x = dcode->m_Size.y = KiROUND( dprm * conv_scale ); dcode->m_Shape = APT_CIRCLE; break; } while( *text ) text++; return true; }
int main( int argc, char **argv ) { APIRET rc; COMMAND cmd = {0,0}; int n; char *cp; char rc_string[12]; CONNECTION Connection; EXCEPTIONREGISTRATIONRECORD reg_rec; ESP_QUE_ELEMENT Qelement; if( argc == 1 ) SayMsg(HELP_INVOCATION_ESP); /****************************************************************************/ /* */ /* Parse the invocation options. */ /* */ /* - If this is a child debugger, then these additional parameters will */ /* precede the invocation parameters inherited from the parent. */ /* */ /* - /child=xxxxx where child = child debugger and */ /* xxxxx = child pid (for serial connections only.)*/ /* */ /* - /handle=xxxxx where handle = switch for com handle( serial only ) */ /* xxxxx = parent's com handle - inherited by */ /* the child. */ /* */ /****************************************************************************/ memset( &EspParms, 0, sizeof( ESP_PARMS ) ); memset( &Connection, 0, sizeof(Connection) ); if( strstr( argv[1], "/child" ) ) { ParseEspChildOptions( argc, argv, &EspParms, &Connection ); } else { ParseOptions( argc, argv, &EspParms, &Connection ); } printf("\nESP Version 5.00 \n");fflush(0); /****************************************************************************/ /* - Send connection info to the router. */ /****************************************************************************/ SendConnectionToRouter( &Connection ); /****************************************************************************/ /* - Make the connection. */ /****************************************************************************/ { int RcMoreInfo = 0; rc = ConnectInit( &RcMoreInfo ); if( rc != 0 ) { char BadConnectMsg[32] = ""; int MsgId; if( (Connection.ConnectType == _NETBIOS) && (RcMoreInfo != 0) ) { /*************************************************************************/ /* - handle netbios specific connect errors. */ /*************************************************************************/ n = 1; MsgId = ERR_NB_INADEQUATE_RESOURCES; switch( RcMoreInfo ) { case CANT_LOAD_NETB_DLL: n = 0; MsgId = ERR_NB_CANT_LOAD_DLL; break; case INADEQUATE_SESSIONS: strcpy( BadConnectMsg,"sessions"); break; case INADEQUATE_COMMANDS: strcpy( BadConnectMsg,"commands"); break; case INADEQUATE_NAMES: strcpy( BadConnectMsg,"names"); break; default: n = 1; MsgId = ERR_BAD_CONNECT; sprintf( BadConnectMsg, "NetBios error rc=%d", rc ); break; } } else if( (Connection.ConnectType == SOCKET) && (RcMoreInfo != 0) ) { /*************************************************************************/ /* - handle tcpip specific connect errors. */ /*************************************************************************/ switch( RcMoreInfo ) { case CANT_LOAD_TCPIP_DLL: n = 1; MsgId = ERR_TCPIP_CANT_LOAD_DLL; sprintf( BadConnectMsg, "%d", rc ); break; case TCPIP_NOT_RUNNING: n = 0; MsgId = ERR_TCPIP_NOT_RUNNING; break; case TCPIP_ERROR: n = 0; MsgId = ERR_TCPIP_ERROR; break; case TCPIP_NO_SERVICES_PORT: n = 0; MsgId = ERR_TCPIP_NO_SERVICES_PORT; break; default: n = 1; MsgId = ERR_BAD_CONNECT; sprintf( BadConnectMsg, "tcpip error rc=%d", rc ); break; } } else { /*************************************************************************/ /* - handle generic connect errors. */ /*************************************************************************/ n = 1; MsgId = ERR_BAD_CONNECT; sprintf( BadConnectMsg, "rc=%d", rc ); } ErrorPrintf( MsgId, n, BadConnectMsg ); } } /****************************************************************************/ /* - register an exception handler for the probe. */ /****************************************************************************/ reg_rec.ExceptionHandler = Handler; DosSetExceptionHandler(®_rec); /****************************************************************************/ /* - Add a connect sema4 for serial connections and wait to be posted. */ /****************************************************************************/ if( (SerialParallel() == SERIAL) && ( IsParent() == FALSE ) ) { USHORT EspPid; TIB *pTib; PIB *pPib; ALLPIDS *p; SetComHandle( EspParms.handle ); DosGetInfoBlocks(&pTib,&pPib); EspPid = (USHORT)pPib->pib_ulpid; CreateConnectSema4( EspPid, _ESP ); SerialConnect( JUST_WAIT, 0, _ESP, SendMsgToEspQue ); p = GetEspPid( EspPid ); p->Connect = CONNECTED; } /****************************************************************************/ /* - Each child debugger will have a termination que so we can kill the */ /* child debuggers on quit/restart. */ /****************************************************************************/ if( IsParent() == FALSE ) { rc = StartEspTermQue( ); if( rc != 0 ) { sprintf(rc_string, "%d",rc); ErrorPrintf( ERR_CANT_START_QUE, TRUE, 1, rc_string ); } } /****************************************************************************/ /* - Now, start the command processing loop. */ /****************************************************************************/ for(;;) { memset(&cmd,0,sizeof(cmd) ); RmtRecv(DEFAULT_HANDLE, (char*)&cmd, sizeof(cmd)); if( IsVerbose() ) PrintCmdMessage( cmd.api ) ; switch( cmd.api ) { case FINDEXE: RxFindExe(cmd); break; case STARTUSER: RxStartUser( cmd ); break; case GOINIT: RxGoInit(cmd); break; case GOENTRY: RxGoEntry(cmd); break; case DEFBRK: RxDefBrk(cmd); break; case UNDBRK: RxUndBrk(cmd); break; case PUTINBRK: RxPutInBrk(cmd); break; case PULLOUTBRK: RxPullOutBrk(cmd); break; case INSERTALLBRK: RxInsertAllBrk(); break; case REMOVEALLBRK: RxRemoveAllBrk(); break; case SELECT_SESSION: /*************************************************************************/ /* - Only the parent probe can select one of the debuggee sessions, so */ /* we send a message and tell him to do it. */ /*************************************************************************/ Qelement.ChildPid = GetEspProcessID(); SendMsgToEspQue( ESP_QMSG_SELECT_SESSION, &Qelement, sizeof(Qelement) ); memset(&cmd,0,sizeof(cmd) ); cmd.api = SELECT_SESSION; RmtSend( DEFAULT_HANDLE, &cmd, sizeof(cmd) ); break; case GOSTEP: RxGoStep(cmd); break; case GOFAST: RxGoFast(cmd); break; case DOSDEBUG: RxDosDebug( cmd ); break; case GETTHREADINFO: RxGetThreadInfo( cmd ); break; case FREEZETHREAD: RxFreezeThread( cmd ); break; case THAWTHREAD: RxThawThread( cmd ); break; case GETCALLSTACK: RxGetCallStack(cmd); break; case GETEXEORDLLENTRY: RxGetExeOrDllEntryOrExitPt(cmd); break; case NORMALQUIT: RxNormalQuit(cmd); /*************************************************************************/ /* - The que has to be up until after the normal quit because the */ /* system will need to post an end session message to the queue. */ /*************************************************************************/ if( IsParent() ) { if( SingleMultiple() == MULTIPLE ) { ALLPIDS *p; /***********************************************************************/ /* - Send a message to all of the child probes telling them that */ /* they are going to be killed. */ /***********************************************************************/ for( p = GetAllpids(); p ; p = p->next ) { if( (p->PidFlags.IsDebug) == TRUE && (p->pid != GetEspProcessID()) ) { ESP_QUE_ELEMENT Qelement; Qelement.ChildPid = p->EspPid; SendMsgToEspTermQue(ESP_PROBE_TERM, &Qelement, sizeof(Qelement) ); } } /***********************************************************************/ /* - send a message to the que to kill all the child probes and */ /* then wait until they are all dead. */ /***********************************************************************/ ResetAllProbesAreDeadFlag( ); SendMsgToEspQue(ESP_QMSG_PARENT_TERM,NULL,0); while( AllProbesAreDead() == FALSE ){ DosSleep(100) ;} } SendMsgToEspQue(ESP_QMSG_QUE_TERM,NULL,0); } CloseConnectSema4(); cmd.api = NORMALQUIT; cmd.len = sizeof(rc); /*************************************************************************/ /* - Now, tell dbg that we're finished normal quitting. */ /*************************************************************************/ RmtSend(DEFAULT_HANDLE, &cmd , sizeof(cmd) ); RmtSend(DEFAULT_HANDLE, &rc, cmd.len ); break; case SETEXECADDR: RxSetExecAddr(cmd); break; case DEFWPS: RxDefWps(cmd); break; case PUTINWPS: RxPutInWps(cmd); break; case PULLOUTWPS: RxPullOutWps(cmd); break; case GETDATABYTES: RxGetDataBytes(cmd); break; case GETMEMBLKS: RxGetMemBlocks(cmd); break; case SETXCPTNOTIFY: RxSetExceptions(cmd); break; case SETEXECTHREAD: RxSetExecThread(cmd); break; case WRITEREGS: RxWriteRegs(cmd); break; case GETCOREGS: RxGetCoRegs(cmd); break; case SETESPRUNOPTS: RxSetEspRunOpts(cmd); break; case TERMINATEESP: if( IsParent() == FALSE ) { memset( &Qelement, 0, sizeof(Qelement) ); Qelement.ChildPid = GetEspProcessID(); SendMsgToEspQue( ESP_QMSG_CHILD_TERM, &Qelement, sizeof(Qelement) ); } DosUnsetExceptionHandler(®_rec); RmtSend(DEFAULT_HANDLE, &cmd , sizeof(cmd) ); ConnectClose( DEFAULT_HANDLE ); exit(0); break; case START_QUE_LISTEN: SendMsgToEspQue(ESP_QMSG_OPEN_CONNECT,NULL,0); break; case START_ESP_QUE: RxStartEspQue(cmd); break; case CONNECT_ESP: /*************************************************************************/ /* - Serial connection only. */ /*************************************************************************/ { USHORT GoToPid; USHORT YieldPid; ALLPIDS *pYield; ALLPIDS *pGoTo; BOOL TorF; /************************************************************************/ /* - Receive the pid to be connected and mark it connected. */ /* - If this pid has not yet been assigned to a probe, then pGoTo */ /* will be NULL. */ /* - There MUST be a probe with a pid==0, so we release that probe. */ /* ( The pid will be stuffed into the structure at goinit() time.) */ /* - Post the connect sema4 for the goto pid. */ /************************************************************************/ RmtRecv( DEFAULT_HANDLE, &GoToPid, cmd.len ); pGoTo = GetPid( GoToPid ); if( pGoTo == NULL ) pGoTo = GetPid(0); pGoTo->Connect = CONNECTED; TorF = TRUE; if( GoToPid == GetEspProcessID() ) TorF = FALSE; /************************************************************************/ /* - Send back verification that the connection has been made. */ /************************************************************************/ memset(&cmd,0,sizeof(cmd) ); cmd.api = SERIAL_POLL; RmtSend( DEFAULT_HANDLE, &cmd, sizeof(cmd) ); PostConnectSema4( &pGoTo->ConnectSema4, TorF ); /************************************************************************/ /* - Disconnect/block this probe. */ /************************************************************************/ YieldPid = (USHORT)GetEspProcessID(); pYield = GetPid( YieldPid ); pYield->Connect = DISCONNECTED; SerialConnect( SET_WAIT, YieldPid, _ESP, SendMsgToEspQue ); } break; case CTRL_BREAK: { USHORT ThisPid; USHORT CtrlBreakPid; RmtRecv( DEFAULT_HANDLE, &CtrlBreakPid, cmd.len ); ThisPid = (USHORT)GetEspProcessID(); Qelement.ChildPid = CtrlBreakPid; Qelement.ChildSid = ThisPid; SendMsgToEspQue(ESP_QMSG_CTRL_BREAK, &Qelement, sizeof(Qelement)); SerialConnect( SET_WAIT, ThisPid, _ESP, SendMsgToEspQue ); } break; case SERIAL_POLL: ReportMessage(); break; default: cp = (char*)&cmd; for( n=1; n<=sizeof(cmd); n++,cp++) printf("%c",*cp); AsyncFlushModem(); break; } } }
bool EXCELLON_IMAGE::Execute_HEADER_Command( char*& text ) { EXCELLON_CMD* cmd = NULL; wxString msg; // Search command in list for( unsigned ii = 0; ; ii++ ) { EXCELLON_CMD* candidate = &excellonHeaderCmdList[ii]; int len = candidate->m_Name.size(); if( len == 0 ) // End of list reached break; if( candidate->m_Name.compare( 0, len, text, len ) == 0 ) // found. { cmd = candidate; text += len; break; } } if( !cmd ) { msg.Printf( wxT( "Unknown Excellon command <%s>" ), text ); ReportMessage( msg ); while( *text ) text++; return false; } // Execute command // some do nothing switch( cmd->m_Code ) { case DRILL_SKIP: case DRILL_M_UNKNOWN: break; case DRILL_M_END: break; case DRILL_M_ENDREWIND: break; case DRILL_M_MESSAGE: break; case DRILL_M_LONGMESSAGE: break; case DRILL_M_HEADER: m_State = READ_HEADER_STATE; break; case DRILL_M_ENDHEADER: m_State = READ_PROGRAM_STATE; break; case DRILL_REWIND_STOP: // End of header. No action in a viewer m_State = READ_PROGRAM_STATE; break; case DRILL_M_METRIC: SelectUnits( true ); break; case DRILL_METRICHEADER: // command like METRIC,TZ or METRIC,LZ SelectUnits( true ); if( *text != ',' ) { ReportMessage( _( "METRIC command has no parameter" ) ); break; } text++; // skip separator if( *text == 'T' ) m_NoTrailingZeros = false; else m_NoTrailingZeros = true; break; case DRILL_M_IMPERIAL: SelectUnits( false ); break; case DRILL_IMPERIALHEADER: // command like INCH,TZ or INCH,LZ SelectUnits( false ); if( *text != ',' ) { ReportMessage( _( "INCH command has no parameter" ) ); break; } text++; // skip separator if( *text == 'T' ) m_NoTrailingZeros = false; else m_NoTrailingZeros = true; break; case DRILL_M_BEGINPATTERN: break; case DRILL_M_ENDPATTERN: break; case DRILL_M_CANNEDTEXT: break; case DRILL_M_TIPCHECK: break; case DRILL_DETECT_BROKEN: break; case DRILL_INCREMENTALHEADER: if( *text != ',' ) { ReportMessage( _( "ICI command has no parameter" ) ); break; } text++; // skip separator // Parameter should be ON or OFF if( strnicmp( text, "OFF", 3 ) == 0 ) m_Relative = false; else if( strnicmp( text, "ON", 2 ) == 0 ) m_Relative = true; else ReportMessage( _( "ICI command has incorrect parameter" ) ); break; case DRILL_TOOL_CHANGE_STOP: break; case DRILL_AUTOMATIC_SPEED: break; case DRILL_AXIS_VERSION: break; case DRILL_RESET_CMD: break; case DRILL_AUTOMATIC_TOOL_CHANGE: break; case DRILL_FMT: break; case DRILL_TOOL_INFORMATION: readToolInformation( text ); break; } while( *text ) text++; return true; }
bool iModule::Connect(iModule* module, size_t socket) { if (socket < 0 || socket > mInputSockets.size()) { // index out of range ReportMessage(iReportable::Error, "Socket index is out of range."); return false; } if (module == nullptr) { // we are disconnecting // report disconnect to source if (mInputSockets[socket]->mModule != nullptr) { mInputSockets[socket]->mModule->OnDisconnect(this); } mInputSockets[socket]->mModule = nullptr; // report all what we need ... // revalidate output socket ValidateOutputSocket(); // and report possible interface change .. ReportInterfaceChanged(); // In the end we inform other modules about our possible changes EmitTargetControl(); return true; } // check requirements, if we don't ignore them ... if (!Sockets::Socket::Match(module->GetOutputSocket(), *mInputSockets[socket])) { // requirments not met // create error report std::stringstream ss; ss << "Source module ( " << module->GetId(); ss << " ) does not meet target requirements on socket " << socket; std::string message; std::getline(ss, message); ReportMessage(iReportable::Error, message); return false; } // reportable disconnect if (mInputSockets[socket]->mModule != nullptr) { mInputSockets[socket]->mModule->OnDisconnect(this); } //information whether the connection was sucessful bool result = true; // connect mInputSockets[socket]->mModule = module; // Reportable connect if (module != nullptr) { if (module->OnConnect(this, socket)) { // connection accept // result = true; } else { // connection failed mInputSockets[socket]->mModule = nullptr; result = false; } } // revalidate output socket ValidateOutputSocket(); // and report possible interface change .. ReportInterfaceChanged(); // in the end we inform other modules about our possible changes EmitTargetControl(); return result; }
/* Read a gerber file, RS274D or RS274X format. */ bool GERBVIEW_FRAME::Read_GERBER_File( const wxString& GERBER_FullFileName, const wxString& D_Code_FullFileName ) { int G_command = 0; // command number for G commands like G04 int D_commande = 0; // command number for D commands like D02 char line[GERBER_BUFZ]; wxString msg; char* text; int layer; // current layer used in GerbView layer = getActiveLayer(); if( g_GERBER_List[layer] == NULL ) { g_GERBER_List[layer] = new GERBER_IMAGE( this, layer ); } GERBER_IMAGE* gerber = g_GERBER_List[layer]; ClearMessageList( ); /* Set the gerber scale: */ gerber->ResetDefaultValues(); /* Read the gerber file */ gerber->m_Current_File = wxFopen( GERBER_FullFileName, wxT( "rt" ) ); if( gerber->m_Current_File == 0 ) { msg.Printf( _( "File <%s> not found" ), GetChars( GERBER_FullFileName ) ); DisplayError( this, msg, 10 ); return false; } gerber->m_FileName = GERBER_FullFileName; wxString path = wxPathOnly( GERBER_FullFileName ); if( path != wxEmptyString ) wxSetWorkingDirectory( path ); SetLocaleTo_C_standard(); while( true ) { if( fgets( line, sizeof(line), gerber->m_Current_File ) == NULL ) { if( gerber->m_FilesPtr == 0 ) break; fclose( gerber->m_Current_File ); gerber->m_FilesPtr--; gerber->m_Current_File = gerber->m_FilesList[gerber->m_FilesPtr]; continue; } text = StrPurge( line ); while( text && *text ) { switch( *text ) { case ' ': case '\r': case '\n': text++; break; case '*': // End command gerber->m_CommandState = END_BLOCK; text++; break; case 'M': // End file gerber->m_CommandState = CMD_IDLE; while( *text ) text++; break; case 'G': /* Line type Gxx : command */ G_command = gerber->GCodeNumber( text ); gerber->Execute_G_Command( text, G_command ); break; case 'D': /* Line type Dxx : Tool selection (xx > 0) or * command if xx = 0..9 */ D_commande = gerber->DCodeNumber( text ); gerber->Execute_DCODE_Command( text, D_commande ); break; case 'X': case 'Y': /* Move or draw command */ gerber->m_CurrentPos = gerber->ReadXYCoord( text ); if( *text == '*' ) // command like X12550Y19250* { gerber->Execute_DCODE_Command( text, gerber->m_Last_Pen_Command ); } break; case 'I': case 'J': /* Auxiliary Move command */ gerber->m_IJPos = gerber->ReadIJCoord( text ); if( *text == '*' ) // command like X35142Y15945J504* { gerber->Execute_DCODE_Command( text, gerber->m_Last_Pen_Command ); } break; case '%': if( gerber->m_CommandState != ENTER_RS274X_CMD ) { gerber->m_CommandState = ENTER_RS274X_CMD; gerber->ReadRS274XCommand( line, text ); } else //Error { ReportMessage( wxT("Expected RS274X Command") ); gerber->m_CommandState = CMD_IDLE; text++; } break; default: text++; msg.Printf( wxT("Unexpected symbol <%c>"), *text ); ReportMessage( msg ); break; } } } fclose( gerber->m_Current_File ); SetLocaleTo_Default(); gerber->m_InUse = true; // Display errors list if( m_Messages.size() > 0 ) { HTML_MESSAGE_BOX dlg( this, _("Errors") ); dlg.ListSet(m_Messages); dlg.ShowModal(); } /* if the gerber file is only a RS274D file * (i.e. without any aperture information), wran the user: */ if( !gerber->m_Has_DCode ) { msg = _("Warning: this file has no D-Code definition\n" "It is perhaps an old RS274D file\n" "Therefore the size of items is undefined"); wxMessageBox( msg ); } return true; }