// --------------------------------------------------------------------------------- // utility conversion funcs public CTmap PI2CTmap(PlugInChannelMap picm) { CTmap ctmap = new CTmap(); int nchan = picm.NumberOfChannels(); for (int i = 0; i < nchan; i++) { // ctmap.add(picm.GetName(i),new CTdata(picm.GetTimes(i), picm.GetDataAsFloat64(i))); ctmap.add(picm.GetName(i)); // only need names this direction } return ctmap; }
private PlugInChannelMap handleRegistration(PlugInChannelMap picm) throws Exception { // picm.PutTime( (System.currentTimeMillis()/1000.0), 0.0); try { if (((picm.GetName(0).equals("...")) || (picm.GetName(0).equals("*")))) { double otime = ctreader.oldTime(sourceFolder); double ntime = ctreader.newTime(sourceFolder); if (debug) System.err.println( "handleRegistration picm[0]: " + picm.GetName(0) + ", oldtime: " + otime + ", newtime: " + ntime); picm.PutTime(otime, ntime - otime); if (regPicm != null) { // round about way to cache registration. actual RBNB pre-register does not // provide time limits if (debug) System.err.println("returning pre-fetched registration..."); picm.Clear(); for (int i = 0; i < regPicm.NumberOfChannels(); i++) { picm.Add(regPicm.GetName(i)); picm.PutDataAsString(i, regString(regPicm.GetName(i))); picm.PutMime(i, "text/xml"); } return picm; // return pre-fetched registration } ArrayList<String> chanlist = ctreader.listChans(sourceFolder); if (chanlist == null) { throw (new Exception("Oops, no channels for sourceFolder: " + sourceFolder)); } picm.Clear(); for (int i = 0; i < chanlist.size(); i++) { int j = picm.Add(chanlist.get(i)); if (debug) System.err.println("register[" + j + "]: " + picm.GetName(j)); picm.PutDataAsString(i, regString(chanlist.get(i))); picm.PutMime(i, "text/xml"); } } else { CTmap ctmap = PI2CTmap(picm); // ignore time limits registration request double otime = ctreader.oldTime(sourceFolder, ctmap); double ntime = ctreader.newTime(sourceFolder, ctmap); picm.PutTime(otime, ntime - otime); if (debug) System.err.println( "handleRegistration picm[0]: " + picm.GetName(0) + ", oldtime: " + otime + ", newtime: " + ntime); int nchan = picm.NumberOfChannels(); if (debug) System.err.println("reg-request channel: " + picm.GetName(0) + ", num: " + nchan); for (int i = 0; i < nchan; i++) { // put start/end time for each channel individually? picm.PutDataAsString(i, regString(picm.GetName(i))); picm.PutMime(i, "text/xml"); } } } catch (Exception e) { System.err.println("handleRegistration exception: " + e); e.printStackTrace(); } // plugin.Flush(picm); return (picm); }