- private void assignMicroInstructionMemory() throws CoreException
- {
- try (InputStream mpmStream = mpmFile.getContents())
- {
- MicroInstructionMemory mpm = MicroInstructionMemoryParser
- .parseMemory(machine.getDefinition().getMicroInstructionMemoryDefinition(), mpmStream);
- machine.getMicroInstructionMemory().bind(mpm);
- }
- catch (IOException e)
- {
- throw new CoreException(new Status(IStatus.ERROR, MograsimActivator.PLUGIN_ID, "Unexpected IO exception reading MPM file", e));
- }
- }
-
- private void resourceChanged(IResourceChangeEvent event)
- {
- // TODO remove Sysout
- int type = event.getType();
- String typeStr;
- switch (type)
- {
- case IResourceChangeEvent.POST_BUILD:
- typeStr = "POST_BUILD";
- break;
- case IResourceChangeEvent.POST_CHANGE:
- typeStr = "POST_CHANGE";
- IResourceDelta mpmDelta;
- if ((mpmDelta = event.getDelta().findMember(mpmFile.getFullPath())) != null && (mpmDelta.getKind() & CHANGED) == CHANGED
- && mpmFile.exists())
- {
- AtomicBoolean doHotReplace = new AtomicBoolean();
- PlatformUI.getWorkbench().getDisplay().syncExec(() ->
- {
- if (MessageDialog.openConfirm(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Hot Replace MPM?",
- String.format("The MPM %s has been modified on the file system. Replace simulated MPM with modified contents?",
- mpmFile.getName())))
- doHotReplace.set(true);
- });
- if (doHotReplace.get())
- {
- try
- {
- assignMicroInstructionMemory();
- }
- catch (CoreException e)
- {
- PlatformUI.getWorkbench().getDisplay()
- .asyncExec(() -> MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
- "Failed Hot Replace!",
- "An error occurred trying to read the modified MPM from the file system: " + e.getMessage()));
- }
- }
- }
- break;
- case IResourceChangeEvent.PRE_BUILD:
- typeStr = "PRE_BUILD";
- break;
- case IResourceChangeEvent.PRE_CLOSE:
- typeStr = "PRE_CLOSE";
- break;
- case IResourceChangeEvent.PRE_DELETE:
- typeStr = "PRE_DELETE";
- break;
- case IResourceChangeEvent.PRE_REFRESH:
- typeStr = "PRE_REFRESH";
- break;
- default:
- typeStr = "<unknown: " + type + ">";
- }
- System.out.println(typeStr + ": " + event);
- }
-
- public static class MachineLaunchParams
- {
- public final String projectPath, mpmPath, ramPath;
-
- MachineLaunchParams(String projectPath, String mpmPath, String ramPath)
- {
- this.projectPath = projectPath;
- this.mpmPath = mpmPath;
- this.ramPath = ramPath;
- }
-
- public String getProjectPath()
- {
- return projectPath;
- }
-
- public String getMpmPath()
- {
- return mpmPath;
- }
-
- public String getRamPath()
- {
- return ramPath;
- }
- }