Something went wrong. Try again.
Completely reimplimented in zig (eventually)
Something went wrong. Try again.
Java
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162package com.microchip.mplab.ipelib.device;
import com.microchip.mplab.ipelib.common.SharedData;import com.microchip.mplab.ipelib.tools.IPENotifier;import com.microchip.mplab.mdbcore.MessageMediator.Message;import com.microchip.mplab.mdbcore.MessageMediator.MessageMediatorListener;
public class MessageMediator implements MessageMediatorListener { private boolean isOutputWindow = true; private SharedData sharedData; private IPENotifier ipeNotify = null;
public MessageMediator() { this.ipeNotify = IPENotifier.getIPENotifierController(); System.out.println(""); }
public int handleMessage(Message objMessage, int ActionID) { this.sharedData = SharedData.getSingletonObject(); if (this.sharedData.getUIMode()) { this.ipeNotify.SetMessageObjectNotify(objMessage, ActionID);
while (!this.sharedData.getUserResponseFlag()) { }
this.sharedData.setUserResponseFlag(false); return this.sharedData.getUserResponseCode(); } else { String mes = objMessage.getMessageString(); if (objMessage.getClearOutputWindow()) { }
if (mes.contains("IDE")) { mes = mes.replace("MPLAB IDE", "MPLAB IPE"); mes = mes.replace("wold", "would"); mes = mes.replace(". ", ".\n"); String[] splitStrings = mes.split(".\n");
for (int i = 0; i < splitStrings.length; i++) { if (splitStrings[i].contains("project properties")) { splitStrings[i] = ""; } }
mes = "";
for (int m = 0; m < splitStrings.length; m++) { mes = mes.concat(splitStrings[m] + ".\n"); } }
if (!this.sharedData.getUIMode() && mes.contains("MPLAB PM3 Card file not found.")) { mes = mes.replace("MPLAB PM3 Card file not found.", ""); }
if (!this.sharedData.getUIMode() && mes.contains("Please toggle the power on the target device")) { this.ipeNotify.setMessageNotification(mes); }
if (!this.sharedData.getUIMode() && mes.contains("Invalid Device ID. Please check your connections to the Target Device")) { System.out.print("IPE:" + mes); System.out.print("IPE:Operation Failed"); System.exit(1); }
if (!this.sharedData.getUIMode() && mes.contains("PICkit 3 is in Programmer-to-go mode.")) { return 1; } else { if (!this.sharedData.getUIMode() && (mes.contains("Device is protected") || mes.contains("DAL is now"))) { this.ipeNotify.setMessageNotification(mes); System.exit(0); }
this.checkForsetAction(ActionID); if (this.isOutputWindow && !this.isFilterRequired(mes)) { this.ipeNotify.setMessageNotification(mes); }
return 0; } } }
private boolean checkForsetAction(Integer ActionID) { boolean retVal = false; switch (ActionID) { case 0: case 1: case 2: case 3: case 6: case 7: case 8: case 9: case 10: case 11: case 13: case 14: case 15: case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23: default: break; case 4: retVal = true; break; case 5: this.isOutputWindow = true; break; case 12: this.isOutputWindow = false; }
return retVal; }
public boolean isFilterRequired(String msg) { boolean retVal = false; String[] dat = new String[]{ "PM3 Versions Details", "MPLAB OS Suite Version", "BIOS Version", "OS Version", "Power Monitor Version", "CPLD Version", "FPGA Version", "ICSP Monitor Version", "USB Version", "Database Version", "Verifying", "Verify completed", "Programming target", "Programming completed", "Reading", "Reading completed" };
for (int iLoop = 0; iLoop < dat.length; iLoop++) { msg = msg.trim(); if (msg.startsWith(dat[iLoop])) { retVal = true; break; } }
return retVal; }
private static enum OutputType { Message, Error, Color, ErrorLink; }}