SVN-fs-dump-format-version: 2 UUID: 21924802-82e1-dc11-8138-00110910106a Revision-number: 0 Prop-content-length: 56 Content-length: 56 K 8 svn:date V 27 2008-02-22T20:09:01.458778Z PROPS-END Revision-number: 1 Prop-content-length: 99 Content-length: 99 K 7 svn:log V 0 K 10 svn:author V 5 roman K 8 svn:date V 27 2008-02-22T21:17:05.583380Z PROPS-END Node-path: niagara Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsMaster Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsMaster/.classpath Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 604 Text-content-md5: f5348192825da157a39a76b584af69fb Text-content-sha1: 819764de8696f73720611273ccd4968408f4269e Content-length: 614 PROPS-END Node-path: niagara/korsMaster/.project Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 386 Text-content-md5: 8dd2041d1ef134ce2f6e350fa1c5143f Text-content-sha1: b46802943760d9e9dfdb57fb1c8c95246df80fb9 Content-length: 396 PROPS-END korsMaster org.eclipse.jdt.core.javabuilder org.eclipse.jdt.core.javanature Node-path: niagara/korsMaster/build.xml Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 1007 Text-content-md5: ccf9006c1dd5cec5b423544b291c3e4b Text-content-sha1: 0c0919d49a3f0ab291fbb7591cf8f7e1828462cb Content-length: 1017 PROPS-END Node-path: niagara/korsMaster/module-include.xml Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 2025 Text-content-md5: 323fae5ea314bc832e152d198187ddb7 Text-content-sha1: 55f1f1b82c293f5bcb015ed5cbf64cb42c9b4a4b Content-length: 2035 PROPS-END Node-path: niagara/korsMaster/module.palette Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 1851 Text-content-md5: 28a94ae38baf8292ed523e80fd5ea4d7 Text-content-sha1: 3aced0a736381b2c675a238e3c8a89886affce3c Content-length: 1861 PROPS-END

Node-path: niagara/korsMaster/src Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsMaster/src/com Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsMaster/src/com/korsengineering Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsMaster/src/com/korsengineering/niagara Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsMaster/src/com/korsengineering/niagara/BQL Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsMaster/src/com/korsengineering/niagara/BQL/BIndirectEnum.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 9755 Text-content-md5: c785a48b024452877b3022f0b4010e9a Text-content-sha1: 53c06ac1b719a17ad1339b215d722445c17489a3 Content-length: 9765 PROPS-END package com.korsengineering.niagara.BQL; import java.io.IOException; import java.util.*; import javax.baja.status.*; import javax.baja.sys.*; import javax.baja.control.*; import javax.baja.bql.*; import javax.baja.naming.*; import javax.baja.collection.*; import javax.baja.util.*; public class BIndirectEnum extends BComponent{ public BLink[] linked; public String[] enumTags, enumNames; public int[] enumOrdinals, ordinalList; public int ordEnd, highOrdinal, ordinalIndex, enumNumber, enumTagIndex; public String ordStr, enumTemp, enumStr, enumString, enumStringParse, compName; public static final int RANGESTART = 7; public static String imageFile; public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } if (property == indexIn || property == enumStringIn){ enumTagIndex = 0; try { if (this.getLinks(this.getSlot("enumMasterIn")).length > 0) { linked = new BLink[this.getLinks(this.getSlot("enumMasterIn")).length]; linked = this.getLinks(this.getSlot("enumMasterIn")); for (int x = 0; x < linked.length; ++x) { BComponent bCom = new BComponent(); bCom = linked[x].getSourceComponent(); compName = bCom.getNavDisplayName(bCom.getProperties().getContext()); setMasterEnumName(compName); ordEnd = bCom.getNavOrd().toString().indexOf(bCom.getName()); ordStr = bCom.getNavOrd().toString().substring(7,ordEnd - 1); setMasterEnumAddress(ordStr); BOrd ord = BOrd.make(ordStr + "|bql:select from control:ControlPoint where displayName = '" + compName + "'"); BICollection result = (BICollection)ord.resolve().get(); Cursor c = result.cursor(); while (c.next()){ setMasterEnumFacetList(((BEnumWritable)c.get()).getEnumFacets().toString()); enumTemp = ((BEnumWritable)c.get()).getEnumFacets().toString(); if (enumTemp.indexOf('}') > RANGESTART){ enumStr = enumTemp.substring(RANGESTART, enumTemp.indexOf('}')); StringTokenizer st = new StringTokenizer(enumStr, ","); enumTags = new String[st.countTokens()]; for (int y = 0; st.hasMoreTokens(); ++y) { enumTags[y] = st.nextToken(); } //end for ordinalIndex = enumTags[enumTags.length - 1].indexOf('=') + 1; highOrdinal = Integer.parseInt(enumTags[enumTags.length - 1] .substring(ordinalIndex)); enumOrdinals = new int[enumTags.length]; enumNames = new String[enumTags.length]; ordinalList = new int[enumTags.length]; for (int z = 0; z <= highOrdinal; ++z){ ordinalList[enumTagIndex] = Integer.parseInt(enumTags[enumTagIndex] .substring(enumTags[enumTagIndex].indexOf('=') + 1)); if (z == ordinalList[enumTagIndex]){ enumOrdinals[enumTagIndex] = ordinalList[enumTagIndex]; enumNames[enumTagIndex] = enumTags[enumTagIndex] .substring(0, enumTags[enumTagIndex] .indexOf('=')); enumTagIndex += 1; } } BEnumRange ber = BEnumRange.make(enumOrdinals, enumNames); enumNumber = (int)getIndexIn().getValue(); enumString = ""; enumStringParse = getEnumStringIn().getValue().toString(); if (enumStringParse.length() > 0) { StringTokenizer stp = new StringTokenizer(enumStringParse, " "); if (stp.hasMoreTokens()) { enumString = stp.nextToken(); for (int ps = 0; stp.hasMoreTokens(); ++ps) { enumString = enumString.concat("$20" + stp.nextToken()); } } else { enumString = enumStringParse; } } if (ber.isOrdinal(enumNumber)){ setEnumStringOut(new BStatusString(ber.get(enumNumber).toString())); } else { if (property == indexIn) { setEnumStringOut(new BStatusString( Integer.toString(enumNumber) + " is Undefined")); getEnumStringOut().setStatus(BStatus.FAULT); } else { setEnumStringOut(new BStatusString("")); } } if (ber.isTag(enumString)) { setEnumNumberOut(new BStatusNumeric(ber.get(enumString).getOrdinal())); } else { if (property == enumStringIn) { setEnumNumberOut(new BStatusNumeric(0)); getEnumNumberOut().setStatus(BStatus.FAULT); } else { setEnumNumberOut(new BStatusNumeric(0)); } } } else { setEnumStringOut(new BStatusString("Master Facet Table Error")); getEnumStringOut().setStatus(BStatus.FAULT); } } } } else { setEnumStringOut(new BStatusString("Master Link Error")); getEnumStringOut().setStatus(BStatus.FAULT); } } catch (Exception ex){ System.out.println(BAbsTime.now().toString() + ": Kors Component Error at " + this.getSlotPath().toString() + ":" + ex.toString()); } } } public static final Property enumMasterIn = newProperty(Flags.SUMMARY, new BStatusEnum()); public static final Property indexIn = newProperty(Flags.SUMMARY, new BStatusNumeric(0)); public static final Property enumStringIn = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property masterEnumName = newProperty(Flags.SUMMARY, ""); public static final Property masterEnumAddress = newProperty(Flags.SUMMARY, ""); public static final Property masterEnumFacetList = newProperty(0, ""); public static final Property enumStringOut = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property enumNumberOut = newProperty(Flags.SUMMARY, new BStatusNumeric(0)); public BStatusEnum getEnumMasterIn() { return (BStatusEnum)get(enumMasterIn); } public BStatusNumeric getIndexIn() { return (BStatusNumeric)get(indexIn); } public BStatusString getEnumStringIn() { return (BStatusString)get(enumStringIn); } public String getMasterEnumName() { return getString(masterEnumName); } public String getMasterEnumAddress() { return getString(masterEnumAddress); } public String getMasterEnumFacetList() { return getString(masterEnumFacetList); } public BStatusString getEnumStringOut() { return (BStatusString)get(enumStringOut); } public BStatusNumeric getEnumNumberOut() { return (BStatusNumeric)get(enumNumberOut); } public void setEnumMasterIn(BStatusEnum v) { set(enumMasterIn, v); } public void setIndexIn(BStatusNumeric v) { set(indexIn, v); } public void setEnumStringIn(BStatusString v) { set(enumStringIn, v); } public void setMasterEnumName(String v) { setString(masterEnumName, v); } public void setMasterEnumAddress(String v) { setString(masterEnumAddress, v); } public void setMasterEnumFacetList(String v) { setString(masterEnumFacetList, v); } public void setEnumStringOut(BStatusString v) { set(enumStringOut, v); } public void setEnumNumberOut(BStatusNumeric v) { set(enumNumberOut, v); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BIndirectEnum.class); public Type getType() { return TYPE; } } Node-path: niagara/korsMaster/src/com/korsengineering/niagara/BQL/BIndirectTag.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 9650 Text-content-md5: c303821bdc97b2df645cf8b47ef89e79 Text-content-sha1: d1f58c8245f60a236f5641e926093d9c0d6d64d9 Content-length: 9660 PROPS-END package com.korsengineering.niagara.BQL; import java.io.IOException; import java.util.*; import javax.baja.status.*; import javax.baja.sys.*; import javax.baja.control.*; import javax.baja.bql.*; import javax.baja.naming.*; import javax.baja.collection.*; import javax.baja.util.*; public class BIndirectTag extends BComponent { public BLink[] linked; public static String [] slotNames; public static int oldSlotNumber = 0; public static boolean runOnce = false; public static final int MINSLOTS = 0; public static final int MAXSLOTS = 31; public void started(){ if (runOnce == false) { slotNames = new String[MAXSLOTS]; for (int x = 0; x < slotNames.length; ++x) { if ( x < 10) { slotNames[x] = "Slot0" + Integer.toString(x); } else { slotNames[x] = "Slot" + Integer.toString(x); } } runOnce = true; } } public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } if (property == numberOfSlots){ int numberInput = (int)getNumberOfSlots().getValue(); if (numberInput >= MINSLOTS && numberInput oldSlotNumber) { for (int x = 0; x < numberInput; ++x){ if (this.getSlot(slotNames[x])==null){ this.add(slotNames[x], new BStatusString(), Flags.SUMMARY); } } oldSlotNumber = numberInput; } if (numberInput < oldSlotNumber) { for (int x = oldSlotNumber; x > numberInput - 1; --x) { if (this.getSlot(slotNames[x])!=null) { this.remove(slotNames[x]); } } oldSlotNumber = numberInput; } } } if (property == rootIndex) { try{ if (this.getLinks(this.getSlot("rootOrdLink")).length > 0) { linked = new BLink[this.getLinks(this.getSlot("rootOrdLink")).length]; linked = this.getLinks(this.getSlot("rootOrdLink")); for (int x = 0; x < linked.length; ++x) { BComponent bCom = new BComponent(); bCom = linked[x].getSourceComponent(); int ordEnd = bCom.getNavOrd().toString().indexOf(bCom.getName()); String ordStr = bCom.getNavOrd().toString().substring(7, ordEnd - 1); for (int y = 0; y < slotNames.length; ++y) { String compName = slotNames[y]; String ordPath = ordStr + getRootFolder().getValue() + getRootIndex().getValue(); setRootOrdPath(new BStatusString(ordPath)); BOrd ord = BOrd.make(ordPath + "|bql:select from control:ControlPoint where displayName = '" + compName + "'"); BICollection result = (BICollection)ord.resolve().get(); Cursor c = result.cursor(); while (c.next()) { BControlPoint point = (BControlPoint)c.get(); point.lease(); } c = result.cursor(); String value = ""; int count = 0; Object lock = new Object(); while (c.next()) { BControlPoint point = (BControlPoint)c.get(); synchronized (lock) { while (point.getStatus().isStale() && count < 20) { try { lock.wait(100); } catch (Exception ex) { ex.printStackTrace(); } count++; } } BStatusValue out = point.getOutStatusValue(); if (out instanceof BStatusString) { value = ((BStatusString) out).getValue(); this.set(this.getProperty(slotNames[y]), new BStatusString(value)); } else if (out instanceof BStatusBoolean) { value = (((BStatusBoolean) out).getValue() ? "true" : "false"); this.set(this.getProperty(slotNames[y]), new BStatusString(value)); } else if (out instanceof BStatusNumeric) { value = Double.toString(((BStatusNumeric) out).getValue()); //String units = point.getFacets().gets(BFacets.UNITS, ""); //if (!units.equals("null")) { // value += units; //} this.set(this.getProperty(slotNames[y]), new BStatusString(value)); } else if (out instanceof BStatusEnum) { value = ((BEnumRange) point.getFacets().get(BFacets.RANGE)) .getTag(((BStatusEnum) out).getEnum().getOrdinal()); this.set(this.getProperty(slotNames[y]), new BStatusString(value)); } else { System.out.println("Unknown out type: " + out.getClass().getName()); value = "No Such Point"; } } } } } } catch(Exception ex){ //ex.printStackTrace(); } } } public void doUpdateSlotName() { int numberInput = (int)getRenameSlotNumber().getValue(); String slotNameInput = getNewSlotName().getValue(); this.rename(this.getProperty(slotNames[numberInput]), slotNameInput); slotNames[numberInput] = slotNameInput; } public static final Action updateSlotName = newAction(0); public static final Property numberOfSlots = newProperty(Flags.SUMMARY, new BStatusNumeric(0)); public static final Property renameSlotNumber = newProperty(Flags.SUMMARY, new BStatusNumeric(0)); public static final Property newSlotName = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property rootOrdLink = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property rootOrdPath = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property rootFolder = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property rootIndex = newProperty(Flags.SUMMARY, new BStatusString()); public BStatusNumeric getNumberOfSlots() { return (BStatusNumeric)get(numberOfSlots); } public BStatusNumeric getRenameSlotNumber() { return (BStatusNumeric)get(renameSlotNumber); } public BStatusString getNewSlotName() { return (BStatusString)get(newSlotName); } public BStatusString getRootOrdLink() { return (BStatusString)get(rootOrdLink); } public BStatusString getRootOrdPath() { return (BStatusString)get(rootOrdPath); } public BStatusString getRootFolder() { return (BStatusString)get(rootFolder); } public BStatusString getRootIndex() { return (BStatusString)get(rootIndex); } public void setNumberOfSlots(BStatusNumeric v) { set(numberOfSlots, v); } public void setRenameSlotNumber(BStatusNumeric v) { set(renameSlotNumber, v); } public void setNewSlotName(BStatusString v) { set(newSlotName, v); } public void setRootOrdLink(BStatusString v) { set(rootOrdLink, v); } public void setRootOrdPath(BStatusString v) { set(rootOrdPath, v); } public void setRootFolder(BStatusString v) { set(rootFolder, v); } public void setRootIndex(BStatusString v) { set(rootIndex, v); } public void updateSlotName() { invoke(updateSlotName, null, null); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BIndirectTag.class); public Type getType() { return TYPE; } } Node-path: niagara/korsMaster/src/com/korsengineering/niagara/XML Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsMaster/src/com/korsengineering/niagara/XML/BXMLTextFormatter.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 4333 Text-content-md5: 68108180f61f3ab687b95531ff1c770c Text-content-sha1: 562f4857f82f7e3b13c83e5ccd2a1134f0973c17 Content-length: 4343 PROPS-END package com.korsengineering.niagara.XML; import javax.baja.status.*; import javax.baja.sys.*; import javax.baja.control.*; import javax.baja.xml.*; public class BXMLTextFormatter extends BComponent{ public String strIn, strCON, strOut; public int depthCount; public boolean tagStart, tagText; public XParser pointer; public void changed(Property property, Context context){ super.changed(property, context); if (property == xmlIn){ strCON = ""; depthCount = 0; tagStart = tagText = false; strIn = getXmlIn().getValue(); try { pointer = XParser.make(strIn); } catch (Exception ex) { ex.printStackTrace(); } try { if (pointer.next() != XParser.EOF) { conStr(pointer.elem().toString(), 0); depthCount = pointer.depth(); } while (pointer.next() != XParser.EOF){ if (pointer.depth() > depthCount) { tagStart = true; doStartTag(true); } if (pointer.depth() < depthCount) { tagStart = tagText = false; doEndTag(true); } if (pointer.depth() == depthCount) { if (!tagStart) { doStartTag(false); tagStart = true; } else { if (!tagText) { doText(); tagText = true; } else { doEndTag(false); tagStart = tagText = false; } } } depthCount = pointer.depth(); } } catch (Exception ex) { System.out.println(BAbsTime.now().toString() + ": Kors Component Error at " + this.getSlotPath().toString() + ":" + ex.toString()); ex.printStackTrace(); } setTextOut(strCON); setXmlOut(new BStatusString(strCON)); } } public void doStartTag(boolean doReturn) { if (doReturn) doReturn(); conStr("<" + pointer.elem().name() + ">", pointer.depth()); } public void doText() { conStr("" + pointer.text(), 0); } public void doEndTag(boolean space) { if (space) { conStr("", pointer.depth()); } else { conStr("", 0); } doReturn(); } public void conStr(String strAdd, int spaceCount){ String Space = ""; if (spaceCount > 0){ for (int x = 1; x < spaceCount; ++x){ Space = Space.concat(" "); } strCON = strCON.concat(Space); } strCON = strCON.concat(strAdd); } public void doReturn(){ strCON = strCON.concat("\r"); } public static final Property xmlIn = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property xmlOut = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property textOut = newProperty(Flags.SUMMARY, ""); public BStatusString getXmlIn() { return (BStatusString)get(xmlIn); } public BStatusString getXmlOut() { return (BStatusString)get(xmlOut); } public String getTextOut() { return getString(textOut); } public void setXmlIn(BStatusString v) { set(xmlIn, v); } public void setXmlOut(BStatusString v) { set(xmlOut, v); } public void setTextOut(String v) { setString(textOut, v); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BXMLTextFormatter.class); public Type getType() { return TYPE; } } Node-path: niagara/korsMaster/src/com/korsengineering/niagara/conversion Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsMaster/src/com/korsengineering/niagara/conversion/BAbsTimeToDateParts.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 5605 Text-content-md5: 8919701e002595f96d80c7898c7076b9 Text-content-sha1: 0e14e2b5c85174d867ca2bc1f507f97a721f3ff1 Content-length: 5615 PROPS-END /** * */ package com.korsengineering.niagara.conversion; import javax.baja.status.*; import javax.baja.sys.*; import javax.baja.control.*; import javax.baja.units.*; /** * @author ARNOTTM * */ public class BAbsTimeToDateParts extends BComponent { public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } if (property == timeIn){ BAbsTime dtNow = getTimeIn(); getSecondsOut().setValue((dtNow.getSecond())); getMinutesOut().setValue((dtNow.getMinute())); setHoursOut(new BStatusNumeric(dtNow.getHour())); setDayOut(new BStatusNumeric(dtNow.getDay())); setMonthOut(new BStatusNumeric(getTimeIn().getMonth().getMonthOfYear())); setYearOut(new BStatusNumeric(getTimeIn().getYear())); BMonth myMonth = getTimeIn().getMonth(); String stMonth = new String(myMonth.toString()); setLongMonthOut(new BStatusString(stMonth)); setShortMonthOut(new BStatusString(stMonth.substring(0,3))); BWeekday myDay = getTimeIn().getWeekday(); setLongDayOut(new BStatusString(myDay.toString())); String stDay = myDay.toString().substring(0,3); setShortDayOut(new BStatusString(stDay)); } } /**Relative Time Input*/ public final static Property timeIn = newProperty(Flags.SUMMARY, BAbsTime.DEFAULT); public void setTimeIn(BAbsTime v) { set(timeIn, v); } public BAbsTime getTimeIn() { return (BAbsTime)get(timeIn); } public static BUnit mySecs = BUnit.getUnit("second"); public static BUnit myMins = BUnit.getUnit("minute"); public static BUnit myHours = BUnit.getUnit("hour"); /**StatusNumeric value out representing time in seconds*/ public final static Property secondsOut = newProperty(Flags.SUMMARY,new BStatusNumeric(),BFacets.makeNumeric(mySecs,0)); public BStatusNumeric getSecondsOut() { return (BStatusNumeric)get(secondsOut); } public void setSecondsOut(BStatusNumeric v) { set(secondsOut, v); } /**StatusNumeric value out representing time in minutes*/ public final static Property minutesOut = newProperty(Flags.SUMMARY,new BStatusNumeric(),BFacets.makeNumeric(myMins,0)); public BStatusNumeric getMinutesOut() { return (BStatusNumeric)get(minutesOut); } public void setMinutesOut(BStatusNumeric v) { set(minutesOut, v); } /**StatusNumeric value out representing time in hours*/ public final static Property hoursOut = newProperty(Flags.SUMMARY,new BStatusNumeric(),BFacets.makeNumeric(myHours,0)); public BStatusNumeric getHoursOut() { return (BStatusNumeric)get(hoursOut); } public void setHoursOut(BStatusNumeric v) { set(hoursOut, v); } /**StatusNumeric value out representing time in day of month*/ public final static Property dayOut = newProperty(Flags.SUMMARY,new BStatusNumeric(),BFacets.makeNumeric(0)); public BStatusNumeric getDayOut() { return (BStatusNumeric)get(dayOut); } public void setDayOut(BStatusNumeric v) { set(dayOut, v); } /**StatusNumeric value out representing time in month*/ public final static Property monthOut = newProperty(Flags.SUMMARY,new BStatusNumeric(),BFacets.makeNumeric(0)); public BStatusNumeric getMonthOut() { return (BStatusNumeric)get(monthOut); } public void setMonthOut(BStatusNumeric v) { set(monthOut, v); } /**StatusNumeric value out representing time in years*/ public final static Property yearOut = newProperty(Flags.SUMMARY,new BStatusNumeric(),BFacets.makeNumeric(0)); public BStatusNumeric getYearOut() { return (BStatusNumeric)get(yearOut); } public void setYearOut(BStatusNumeric v) { set(yearOut, v); } /**StatusString value out representing time in short month*/ public final static Property shortMonthOut = newProperty(Flags.SUMMARY,new BStatusString()); public BStatusString getShortMonthOut() { return (BStatusString)get(shortMonthOut); } public void setShortMonthOut(BStatusString v) { set(shortMonthOut, v); } /**StatusString value out representing time in long month*/ public final static Property longMonthOut = newProperty(Flags.SUMMARY,new BStatusString()); public BStatusString getLongMonthOut() { return (BStatusString)get(longMonthOut); } public void setLongMonthOut(BStatusString v) { set(longMonthOut, v); } /**StatusString value out representing time in short day*/ public final static Property shortDayOut = newProperty(Flags.SUMMARY,new BStatusString()); public BStatusString getShortDayOut() { return (BStatusString)get(shortDayOut); } public void setShortDayOut(BStatusString v) { set(shortDayOut, v); } /**StatusString value out representing time in long Day*/ public final static Property longDayOut = newProperty(Flags.SUMMARY,new BStatusString()); public BStatusString getLongDayOut() { return (BStatusString)get(longDayOut); } public void setLongDayOut(BStatusString v) { set(longDayOut, v); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BAbsTimeToDateParts.class); public Type getType() { return TYPE; } } Node-path: niagara/korsMaster/src/com/korsengineering/niagara/conversion/BStatusEnumToStatusString.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 1560 Text-content-md5: 90be6995ae528eb3b19cfc70490836ad Text-content-sha1: 2f8c575e0bb6575cfafcfdfe4ed069c59bf39a03 Content-length: 1570 PROPS-END package com.korsengineering.niagara.conversion; import javax.baja.status.*; import javax.baja.sys.*; import javax.baja.control.*; /**Converts a StatusEnum input to a Status String */ public class BStatusEnumToStatusString extends BComponent{ public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } if (property == enumIn) { BStatusString tmp = new BStatusString(); tmp.setValue(getEnumIn().getEnum().getTag()); setStringOut(tmp); } } //Property Declarations, Gets, and Sets //Enum Input public static final Property enumIn = newProperty(Flags.SUMMARY, new BStatusEnum()); /**String Output*/ public static final Property stringOut = newProperty(Flags.SUMMARY, new BStatusString()); //Get methods public BStatusEnum getEnumIn() { return (BStatusEnum)get(enumIn); } public BStatusString getStringOut() { return (BStatusString)get(stringOut);} //Set Methods public void setEnumIn(BStatusEnum v) { set(enumIn, v); } public void setStringOut(BStatusString v) {set(stringOut,v);} public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BStatusEnumToStatusString.class); public Type getType() { return TYPE; } } Node-path: niagara/korsMaster/src/com/korsengineering/niagara/conversion/BStatusNumericToRelTime.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 1575 Text-content-md5: cf268a53968e1086d3ca183f67bba561 Text-content-sha1: cb3eac6975157b0c9786d4c9d8077ce6b753f57c Content-length: 1585 PROPS-END package com.korsengineering.niagara.conversion; import javax.baja.status.*; import javax.baja.sys.*; import javax.baja.control.*; /**Converts a StatusNumeric input of time in seconds to a relative time output*/ public class BStatusNumericToRelTime extends BComponent{ public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } if (property == secondsIn){ int secs = (int)getSecondsIn().getValue(); BRelTime inTime = BRelTime.makeSeconds(secs); setTimeOut(inTime.abs()); } } /**StatusNumeric value in representing total time in seconds*/ public final static Property secondsIn = newProperty(Flags.SUMMARY,new BStatusNumeric()); /**Relative Time Out*/ public final static Property timeOut = newProperty(Flags.SUMMARY, BRelTime.DEFAULT); public BStatusNumeric getSecondsIn() { return (BStatusNumeric)get(secondsIn); } public BRelTime getTimeOut() { return (BRelTime)get(timeOut); } public void setSecondsIn(BStatusNumeric v) { set(secondsIn, v); } public void setTimeOut(BRelTime v) { set(timeOut, v); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BStatusNumericToRelTime.class); public Type getType() { return TYPE; } } Node-path: niagara/korsMaster/src/com/korsengineering/niagara/conversion/BStatusNumericToStatusBoolean.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 7948 Text-content-md5: b88a574a904ceb5c9f34a67b8350bdde Text-content-sha1: 3de52af118c79fbf32a8ba6ef4c602a5a4a4b71d Content-length: 7958 PROPS-END package com.korsengineering.niagara.conversion; import javax.baja.status.*; import javax.baja.sys.*; import javax.baja.control.*; /**Converts a StatusNumeric input to a 16 bit word represented *by 16 StatusBoolean outputs*/ public class BStatusNumericToStatusBoolean extends BComponent{ public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } String binStr = ""; double getNum; int castNum; if (property == numberIn) { //Convert decimal to binary getNum = getNumberIn().getValue(); if (getNum <= 65535 && getNum >= 0) { castNum = (int)getNum; binStr = toBinaryString(castNum); } setStringBinary(new BStatusString(binStr)); setBinaryOut00(new BStatusBoolean((binStr.charAt(15) == '1'))); setBinaryOut01(new BStatusBoolean((binStr.charAt(14) == '1'))); setBinaryOut02(new BStatusBoolean((binStr.charAt(13) == '1'))); setBinaryOut03(new BStatusBoolean((binStr.charAt(12) == '1'))); setBinaryOut04(new BStatusBoolean((binStr.charAt(11) == '1'))); setBinaryOut05(new BStatusBoolean((binStr.charAt(10) == '1'))); setBinaryOut06(new BStatusBoolean((binStr.charAt(9) == '1'))); setBinaryOut07(new BStatusBoolean((binStr.charAt(8) == '1'))); setBinaryOut08(new BStatusBoolean((binStr.charAt(7) == '1'))); setBinaryOut09(new BStatusBoolean((binStr.charAt(6) == '1'))); setBinaryOut10(new BStatusBoolean((binStr.charAt(5) == '1'))); setBinaryOut11(new BStatusBoolean((binStr.charAt(4) == '1'))); setBinaryOut12(new BStatusBoolean((binStr.charAt(3) == '1'))); setBinaryOut13(new BStatusBoolean((binStr.charAt(2) == '1'))); setBinaryOut14(new BStatusBoolean((binStr.charAt(1) == '1'))); setBinaryOut15(new BStatusBoolean((binStr.charAt(0) == '1'))); } } //Property Declarations, Gets, and Sets //Integer Input public static final Property numberIn = newProperty(Flags.SUMMARY, new BStatusNumeric()); /**Binary Outputs*/ public static final Property binaryOut00 = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public static final Property binaryOut01 = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public static final Property binaryOut02 = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public static final Property binaryOut03 = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public static final Property binaryOut04 = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public static final Property binaryOut05 = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public static final Property binaryOut06 = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public static final Property binaryOut07 = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public static final Property binaryOut08 = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public static final Property binaryOut09 = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public static final Property binaryOut10 = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public static final Property binaryOut11 = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public static final Property binaryOut12 = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public static final Property binaryOut13 = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public static final Property binaryOut14 = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public static final Property binaryOut15 = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); /**String Output*/ public static final Property stringBinary = newProperty(Flags.SUMMARY, new BStatusString()); //Get methods public BStatusNumeric getNumberIn() { return (BStatusNumeric)get(numberIn); } public BStatusBoolean getBinaryOut00() { return (BStatusBoolean)get(binaryOut00); } public BStatusBoolean getBinaryOut01() { return (BStatusBoolean)get(binaryOut01); } public BStatusBoolean getBinaryOut02() { return (BStatusBoolean)get(binaryOut02); } public BStatusBoolean getBinaryOut03() { return (BStatusBoolean)get(binaryOut03); } public BStatusBoolean getBinaryOut04() { return (BStatusBoolean)get(binaryOut04); } public BStatusBoolean getBinaryOut05() { return (BStatusBoolean)get(binaryOut05); } public BStatusBoolean getBinaryOut06() { return (BStatusBoolean)get(binaryOut06); } public BStatusBoolean getBinaryOut07() { return (BStatusBoolean)get(binaryOut07); } public BStatusBoolean getBinaryOut08() { return (BStatusBoolean)get(binaryOut08); } public BStatusBoolean getBinaryOut09() { return (BStatusBoolean)get(binaryOut09); } public BStatusBoolean getBinaryOut10() { return (BStatusBoolean)get(binaryOut10); } public BStatusBoolean getBinaryOut11() { return (BStatusBoolean)get(binaryOut11); } public BStatusBoolean getBinaryOut12() { return (BStatusBoolean)get(binaryOut12); } public BStatusBoolean getBinaryOut13() { return (BStatusBoolean)get(binaryOut13); } public BStatusBoolean getBinaryOut14() { return (BStatusBoolean)get(binaryOut14); } public BStatusBoolean getBinaryOut15() { return (BStatusBoolean)get(binaryOut15); } public BStatusString getStringBinary() { return (BStatusString)get(stringBinary); } //Set Methods public void setNumberIn(BStatusNumeric v) { set(numberIn, v); } public void setBinaryOut00(BStatusBoolean v) { set(binaryOut00, v); } public void setBinaryOut01(BStatusBoolean v) { set(binaryOut01, v); } public void setBinaryOut02(BStatusBoolean v) { set(binaryOut02, v); } public void setBinaryOut03(BStatusBoolean v) { set(binaryOut03, v); } public void setBinaryOut04(BStatusBoolean v) { set(binaryOut04, v); } public void setBinaryOut05(BStatusBoolean v) { set(binaryOut05, v); } public void setBinaryOut06(BStatusBoolean v) { set(binaryOut06, v); } public void setBinaryOut07(BStatusBoolean v) { set(binaryOut07, v); } public void setBinaryOut08(BStatusBoolean v) { set(binaryOut08, v); } public void setBinaryOut09(BStatusBoolean v) { set(binaryOut09, v); } public void setBinaryOut10(BStatusBoolean v) { set(binaryOut10, v); } public void setBinaryOut11(BStatusBoolean v) { set(binaryOut11, v); } public void setBinaryOut12(BStatusBoolean v) { set(binaryOut12, v); } public void setBinaryOut13(BStatusBoolean v) { set(binaryOut13, v); } public void setBinaryOut14(BStatusBoolean v) { set(binaryOut14, v); } public void setBinaryOut15(BStatusBoolean v) { set(binaryOut15, v); } public void setStringBinary(BStatusString v) { set(stringBinary, v); } /**Converts binary value to a string representation of the bit word*/ public String toBinaryString(int numberIn) { String binStr = Integer.toBinaryString(numberIn); if (binStr.length() < 16) { //pad to 16 characters int charsToPad = 16 - binStr.length(); char [] buf = new char[charsToPad]; for (int i = 0; i < charsToPad; i++) { buf[i] = '0'; } binStr = new String(buf) + binStr; } return binStr; } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BStatusNumericToStatusBoolean.class); public Type getType() { return TYPE; } } Node-path: niagara/korsMaster/src/com/korsengineering/niagara/energy Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsMaster/src/com/korsengineering/niagara/energy/BScoreCard.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 7711 Text-content-md5: 0e0266f3cdc5384b7f8504645e385854 Text-content-sha1: 15db9891cbcaf72b877ba868916d3b4c6fec387d Content-length: 7721 PROPS-END package com.korsengineering.niagara.energy; import java.util.Timer; import java.util.TimerTask; import javax.baja.status.*; import javax.baja.sys.*; import javax.baja.control.*; import javax.baja.bql.*; import javax.baja.naming.*; import javax.baja.collection.*; import javax.baja.util.*; import com.korsengineering.niagara.list.BDynamicList; public class BScoreCard extends BComponent { public int delay, period, presetTemp, remain; private double minDemand = 0.0; private double maxDemand = 0.0; private boolean bitInMinRange = false; private boolean bitInMaxRange = false; public void started(){ //build timer delay = 0; period = 60000; final Timer timer = new Timer(); timer.scheduleAtFixedRate(new TimerTask() { public void run() { //check to see if current dtime in accepted range BAbsTime getTime = BAbsTime.now(); BTimeRange tMinRange = getInMinimumDemandTimeWindow(); BDaysOfWeekBits bMinDays = getInMinimumDemandTimeDay(); //update the minimum demand if in window if( bMinDays.includes(getTime)) {//today is included, now check time window if(tMinRange.includes(getTime)) {//now is included, check to see if current value is less than stored value if(!bitInMinRange) {//this is the first time in range, so automatically use the current value minDemand =getInNumeric().getNumeric(); bitInMinRange = true; } else {//not the first, so check for 0, < double tmp = getInNumeric().getNumeric(); if((minDemand > tmp) || (minDemand == 0)) {//get status of in numeric BStatus inStatus = getInNumeric().getStatus(); if(inStatus.isOk()) { //ok to update value minDemand = tmp; } } } //set output to min value setOutMin(new BStatusNumeric(minDemand)); } else {//now not included, if bit is true, set to false bitInMinRange = false; } } else {//now not included, if bit is true, set to false bitInMinRange = false; } //now check to see if max time is in range BTimeRange tMaxRange = getInMaximumDemandTimeWindow(); BDaysOfWeekBits bMaxDays = getInMaximumDemandTimeDay(); if( bMaxDays.includes(getTime)) {//today is included, now check time window if(tMaxRange.includes(getTime)) {//now is included, check to see if current value is less than stored value BStatus inStatus = getInNumeric().getStatus(); if(!bitInMaxRange) {//this is the first time in range, so automatically use the current value if(inStatus.isOk()) { //ok to update value maxDemand = getInNumeric().getNumeric(); } else { maxDemand = 0; } bitInMaxRange = true; } else {//not the first, so check for 0, > double tmp = getInNumeric().getNumeric(); if((maxDemand < tmp) || (maxDemand == 0)) {//get status of in numeric if(inStatus.isOk()) { //ok to update value maxDemand = tmp; } } } //set output to max value setOutMax(new BStatusNumeric(maxDemand)); } else {//now not included, if bit is true, set to false if(bitInMaxRange) {//is just out of max range, calculate and set score if((minDemand>0)&&(maxDemand>0)) { setOutScore(new BStatusNumeric(minDemand / maxDemand * 100)); } else { setOutScore(new BStatusNumeric(100)); } } bitInMaxRange = false; } } else {//now not included, if bit is true, set to false if(bitInMaxRange) {//is just out of max range, calculate and set score if((minDemand>0)&&(maxDemand>0)) { setOutScore(new BStatusNumeric(minDemand / maxDemand * 100)); } else { setOutScore(new BStatusNumeric(100)); } } bitInMaxRange = false; } } }, delay, period); } public static final Property inNumeric = newProperty(Flags.SUMMARY, new BStatusNumeric()); public BStatusNumeric getInNumeric() { return (BStatusNumeric)get(inNumeric); } public void setInNumeric(BStatusNumeric v) { set(inNumeric, v); } public static final Property outScore = newProperty(Flags.SUMMARY, new BStatusNumeric(), BFacets.makeNumeric(2)); public BStatusNumeric getOutScore() { return (BStatusNumeric)get(outScore); } public void setOutScore(BStatusNumeric v) { set(outScore, v); } public static final Property outMin = newProperty(Flags.SUMMARY, new BStatusNumeric(), BFacets.makeNumeric(2)); public BStatusNumeric getOutMin() { return (BStatusNumeric)get(outMin); } public void setOutMin(BStatusNumeric v) { set(outMin, v); } public static final Property outMax = newProperty(Flags.SUMMARY, new BStatusNumeric(), BFacets.makeNumeric(2)); public BStatusNumeric getOutMax() { return (BStatusNumeric)get(outMax); } public void setOutMax(BStatusNumeric v) { set(outMax, v); } public static final Property inMinimumDemandTimeDay = newProperty(Flags.SUMMARY, BDaysOfWeekBits.sunday); public BDaysOfWeekBits getInMinimumDemandTimeDay() { return (BDaysOfWeekBits)get("inMinimumDemandTimeDay"); } public void setInMinimumDemandTimeDay(javax.baja.util.BDaysOfWeekBits v) { set("inMinimumDemandTimeDay", v); } public static final Property inMinimumDemandTimeWindow = newProperty(Flags.SUMMARY, new BTimeRange()); public BTimeRange getInMinimumDemandTimeWindow() { return (BTimeRange)get("inMinimumDemandTimeWindow"); } public void setInMinimumDemandTimeWindow(javax.baja.util.BTimeRange v) { set("inMinimumDemandTimeWindow", v); } public static final Property inMaximumDemandTimeDay = newProperty(Flags.SUMMARY, BDaysOfWeekBits.tuesday); public BDaysOfWeekBits getInMaximumDemandTimeDay() { return (BDaysOfWeekBits)get("inMaximumDemandTimeDay"); } public void setInMaximumDemandTimeDay(javax.baja.util.BDaysOfWeekBits v) { set("inMaximumDemandTimeDay", v); } public static final Property inMaximumDemandTimeWindow = newProperty(Flags.SUMMARY, new BTimeRange()); public BTimeRange getInMaximumDemandTimeWindow() { return (BTimeRange)get("inMaximumDemandTimeWindow"); } public void setInMaximumDemandTimeWindow(javax.baja.util.BTimeRange v) { set("inMaximumDemandTimeWindow", v); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BScoreCard.class); public Type getType() { return TYPE; } } Node-path: niagara/korsMaster/src/com/korsengineering/niagara/graphics Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsMaster/src/com/korsengineering/niagara/graphics/korsLogo.png Node-kind: file Node-action: add Prop-content-length: 59 Text-content-length: 1472 Text-content-md5: 0b979731f91a4c0f34a6760a30ef9190 Text-content-sha1: e5780469e3e892b273104424030dea3641026d96 Content-length: 1531 K 13 svn:mime-type V 24 application/octet-stream PROPS-END PNG  IHDR_*? pHYsgRgAMA|Q cHRMz%u0`:o_FPLTEt UK,mdC|uFwGxTblnotuxu~{ʶK@MBHxJzO~TV|dhegprsqtswuwzs|{}|xƯNAB6A5B7RG%cX1tiK{kǻQA*rdP_p{¼¼9,6*At}ҿeQ,wd=pk+wb-yd\^q¹:mP}]bxfquȺŵvrVtRNSJ MIDATxbAf-bpZb`ph [bYwq= bPo,?~aaА6rfcZU@PY H*h^ߪFMhx4  H=O 7'P)@wxA.T~ '.  V d'7I +]^a-b oQY  !iDU·mIENDB` Node-path: niagara/korsMaster/src/com/korsengineering/niagara/list Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsMaster/src/com/korsengineering/niagara/list/BDynamicList.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 3719 Text-content-md5: 6e47f4aef350fe01b30f1e37e4275b9f Text-content-sha1: 0dbf47b9a07e79a02b6c13845dd8f03b670c8665 Content-length: 3729 PROPS-END package com.korsengineering.niagara.list; import javax.baja.status.*; import javax.baja.sys.*; import javax.baja.control.*; import javax.baja.bql.*; import javax.baja.naming.*; import javax.baja.collection.*; import javax.baja.util.*; public class BDynamicList extends BComponent{ public static String [] slotNames; public static int oldSlotNumber = 0; public static boolean runOnce = false; public static final int MINSLOTS = 0; public static final int MAXSLOTS = 31; public void started(){ if (runOnce == false) { slotNames = new String[MAXSLOTS]; for (int x = 0; x < slotNames.length; ++x) { if ( x < 10) { slotNames[x] = "Input0" + Integer.toString(x); } else { slotNames[x] = "Input" + Integer.toString(x); } } runOnce = true; } } public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } if (property == numberOfItems){ int numberInput = (int)getNumberOfItems().getValue(); if (numberInput >= MINSLOTS && numberInput oldSlotNumber) { for (int x = 0; x < numberInput; ++x){ if (this.getSlot(slotNames[x])==null){ this.add(slotNames[x], new BStatusNumeric(), Flags.SUMMARY); } } oldSlotNumber = numberInput; } if (numberInput < oldSlotNumber) { for (int x = oldSlotNumber; x > numberInput - 1; --x) { if (this.getSlot(slotNames[x])!=null) { this.remove(slotNames[x]); } } oldSlotNumber = numberInput; } } } } public void doUpdateSlotName() { int numberInput = (int)getRenameSlotNumber().getValue(); String slotNameInput = getNewSlotName().getValue(); double dd = 99; this.rename(this.getProperty(slotNames[numberInput]), slotNameInput); slotNames[numberInput] = slotNameInput; } public static final Action updateSlotName = newAction(0); public static final Property numberOfItems = newProperty(Flags.SUMMARY, new BStatusNumeric(0)); public static final Property renameSlotNumber = newProperty(Flags.SUMMARY, new BStatusNumeric(0)); public static final Property newSlotName = newProperty(Flags.SUMMARY, new BStatusString()); public BStatusNumeric getNumberOfItems() { return (BStatusNumeric)get(numberOfItems); } public BStatusNumeric getRenameSlotNumber() { return (BStatusNumeric)get(renameSlotNumber); } public BStatusString getNewSlotName() { return (BStatusString)get(newSlotName); } public void setNumberOfItems(BStatusNumeric v) { set(numberOfItems, v); } public void setRenameSlotNumber(BStatusNumeric v) { set(renameSlotNumber, v); } public void setNewSlotName(BStatusString v) { set(newSlotName, v); } public void updateSlotName() { invoke(updateSlotName, null, null); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BDynamicList.class); public Type getType() { return TYPE; } } Node-path: niagara/korsMaster/src/com/korsengineering/niagara/list/BStatusNumericFifo.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 9004 Text-content-md5: b3e1e5a3e84cc021ee59adf8c460fb92 Text-content-sha1: 06d322f1589b829afaa91f796205dfb71ef6b30e Content-length: 9014 PROPS-END package com.korsengineering.niagara.list; import javax.baja.status.*; import javax.baja.sys.*; import javax.baja.control.*; import javax.baja.bql.*; import javax.baja.naming.*; import javax.baja.collection.*; import javax.baja.units.BUnit; import javax.baja.util.*; public class BStatusNumericFifo extends BComponent { boolean fire = false; static String [] slotNames; final int MAXSLOTS = 33; BLink [] linked; BUnit degrees; BFacets bfc; static final String INPUT = "Input", MAX = "Max$20Value", MIN = "Min$20Value", AVG = "Average"; static BStatusNumeric bsn; public void started(){ try{ slotNames = new String[MAXSLOTS]; setNames(); if (!getSlot(INPUT).isProperty()){ //Slot Does not Exist add(INPUT, new BStatusNumeric(0), Flags.SUMMARY); add(MAX, new BStatusNumeric(0), Flags.SUMMARY); add(MIN, new BStatusNumeric(0), Flags.SUMMARY); add(AVG, new BStatusNumeric(0), Flags.SUMMARY); addSlots(); } } catch(NullPointerException en){ add(INPUT, new BStatusNumeric(0), Flags.SUMMARY); add(MAX, new BStatusNumeric(0), Flags.SUMMARY); add(MIN, new BStatusNumeric(0), Flags.SUMMARY); add(AVG, new BStatusNumeric(0), Flags.SUMMARY); addSlots(); } catch(Exception ex){ System.out.println(BAbsTime.now().toString() + ": Kors Component Error at " + this.getSlotPath().toString() + ":" + ex.toString()); } } private void setNames(){ for (int x = 0; x < slotNames.length; ++x) { if ( x < 10) { slotNames[x] = "Output$200" + Integer.toString(x); } else { slotNames[x] = "Output$20" + Integer.toString(x); } } } private void addSlots(){ for (int x = 0; x < slotNames.length; ++x) { if(slotNames[x]==null){ setNames(); } if ( x < 10) { add(slotNames[x], new BStatusNumeric(0)); } else { add(slotNames[x], new BStatusNumeric(0)); } } } public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } for (int x = 0; x < slotNames.length; ++x) { if(slotNames[x]==null){ setNames(); } } if (property == trigger && getTrigger().getValue() && fire == false){ //linked = new BLink[getLinks(getSlot("input")).length]; //linked = getLinks(getSlot("input")); try{ linked = new BLink[getLinks(getSlot(INPUT)).length]; linked = getLinks(getSlot(INPUT)); for (int x = 0; x < linked.length; ++x) { BComponent bCom = new BComponent(); bCom = linked[x].getSourceComponent(); int ordEnd = bCom.getNavOrd().toString().indexOf(bCom.getName()); String ordStr = bCom.getNavOrd().toString().substring(7, ordEnd - 1); BOrd ord = BOrd.make(ordStr + "|bql:select from control:ControlPoint where displayName = '" + bCom.getName() + "'"); BICollection result = (BICollection)ord.resolve().get(); Cursor c = result.cursor(); while (c.next()) { BControlPoint point = (BControlPoint)c.get(); BStatusValue out = point.getOutStatusValue(); if (out instanceof BStatusString) { ((BStatusNumeric)get(getProperty(INPUT))).setStatus(BStatus.fault); } if (out instanceof BStatusBoolean) { ((BStatusNumeric)get(getProperty(INPUT))).setStatus(BStatus.fault); } if (out instanceof BStatusEnum) { ((BStatusNumeric)get(getProperty(INPUT))).setStatus(BStatus.fault); } if (out instanceof BStatusNumeric) { double value = ((BStatusNumeric)out).getValue(); BFacets bfc = point.getFacets(); System.out.println(bfc == null); if(bfc == null){ shiftData(value); minData(); maxData(); avgData(); } else{ shiftData(value, bfc); minData(bfc); maxData(bfc); avgData(bfc); } } } } } catch(Exception e){ System.out.println(BAbsTime.now().toString() + ": Kors Component Error at " + this.getSlotPath().toString() + ":" + e.toString()); } finally{ fire = true; } } else { fire = false; } } private void shiftData(double value, BFacets bfc){ double tempVal; for (int x = slotNames.length - 2; x >= 0; --x){ tempVal = ((BStatusNumeric)get(getProperty(slotNames[x]))).getValue(); set(getProperty(slotNames[x + 1]), new BStatusNumeric(tempVal)); setFacets(getSlot(slotNames[x + 1]), bfc); } set(getProperty(slotNames[0]), new BStatusNumeric(value)); setFacets(getSlot(INPUT), bfc); setFacets(getSlot(slotNames[0]), bfc); } private void shiftData(double value){ double tempVal; for (int x = slotNames.length - 2; x >= 0; --x){ tempVal = ((BStatusNumeric)get(getProperty(slotNames[x]))).getValue(); set(getProperty(slotNames[x + 1]), new BStatusNumeric(tempVal)); } set(getProperty(slotNames[0]), new BStatusNumeric(value)); } private void minData(BFacets bfc){ double tempVal, minVal; tempVal = minVal = 0; for (int x = 0; x < slotNames.length; ++x){ tempVal = ((BStatusNumeric)get(getProperty(slotNames[x]))).getValue(); if (minVal == 0){ minVal = tempVal; } else { if (tempVal > 0 && tempVal < minVal){ minVal = tempVal; } } } set(getProperty(MIN), new BStatusNumeric(minVal)); setFacets(getSlot(MIN), bfc); } private void minData(){ double tempVal, minVal; tempVal = minVal = 0; for (int x = 0; x < slotNames.length; ++x){ tempVal = ((BStatusNumeric)get(getProperty(slotNames[x]))).getValue(); if (minVal == 0){ minVal = tempVal; } else { if (tempVal > 0 && tempVal < minVal){ minVal = tempVal; } } } set(getProperty(MIN), new BStatusNumeric(minVal)); } private void maxData(BFacets bfc){ double tempVal, maxVal; tempVal = maxVal = 0; for (int x = 0; x < slotNames.length; ++x){ tempVal = ((BStatusNumeric)get(getProperty(slotNames[x]))).getValue(); if (maxVal == 0){ maxVal = tempVal; } else { if (tempVal > 0 && tempVal > maxVal){ maxVal = tempVal; } } } set(getProperty(MAX), new BStatusNumeric(maxVal)); setFacets(getSlot(MAX), bfc); } private void maxData(){ double tempVal, maxVal; tempVal = maxVal = 0; for (int x = 0; x < slotNames.length; ++x){ tempVal = ((BStatusNumeric)get(getProperty(slotNames[x]))).getValue(); if (maxVal == 0){ maxVal = tempVal; } else { if (tempVal > 0 && tempVal > maxVal){ maxVal = tempVal; } } } set(getProperty(MAX), new BStatusNumeric(maxVal)); } private void avgData(BFacets bfc){ double tempVal, avgVal, checkVal, goodVals; tempVal = avgVal = checkVal = goodVals = 0; for (int x = 0; x < slotNames.length; ++x){ checkVal = ((BStatusNumeric)get(getProperty(slotNames[x]))).getValue(); tempVal += checkVal; if (checkVal > 0){ goodVals += 1; } } avgVal = tempVal / goodVals; set(getProperty(AVG), new BStatusNumeric(avgVal)); setFacets(getSlot(AVG), bfc); } private void avgData(){ double tempVal, avgVal, checkVal, goodVals; tempVal = avgVal = checkVal = goodVals = 0; for (int x = 0; x < slotNames.length; ++x){ checkVal = ((BStatusNumeric)get(getProperty(slotNames[x]))).getValue(); tempVal += checkVal; if (checkVal > 0){ goodVals += 1; } } avgVal = tempVal / goodVals; set(getProperty(AVG), new BStatusNumeric(avgVal)); } public static final Property trigger = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BStatusBoolean getTrigger() { return (BStatusBoolean)get(trigger); } public void setTrigger(BStatusBoolean v) { set(trigger, v); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BStatusNumericFifo.class); public Type getType() { return TYPE; } } Node-path: niagara/korsMaster/src/com/korsengineering/niagara/logic Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsMaster/src/com/korsengineering/niagara/logic/BFlipFlop.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 2196 Text-content-md5: f2f236d790b703b73212fdf9dad92c94 Text-content-sha1: e3b2eef6e7f81a16e6a74d22b342d72268dc5550 Content-length: 2206 PROPS-END package com.korsengineering.niagara.logic; import javax.baja.status.*; import javax.baja.sys.*; import javax.baja.control.*; public class BFlipFlop extends BComponent{ public final static Property setInput = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public final static Property resetInput = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public final static Property output = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BStatusBoolean getResetInput() { return (BStatusBoolean)get(resetInput); } public BStatusBoolean getSetInput() { return (BStatusBoolean)get(setInput); } public BStatusBoolean getOutput() { return (BStatusBoolean)get(output); } public void setSetInput(BStatusBoolean v) { set(setInput, v); } public void setResetInput(BStatusBoolean v) { set(resetInput, v); } public void setOutput(BStatusBoolean v) { set(output, v); } public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } if(property==setInput || property == resetInput){ boolean set = getSetInput().getValue(); boolean reset = getResetInput().getValue(); try{ if(set){ //check reset status, if off, set if(!reset){ //no reset flag, turn on output setOutput(new BStatusBoolean(true)); } } else{ //no set status, check reset if(reset){ //reset true, turn off output setOutput(new BStatusBoolean(false)); } } } catch(Exception e){ System.out.println(BAbsTime.now().toString() + ": Kors Component Error at " + this.getSlotPath().toString() + ":" + e.toString()); } } } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BFlipFlop.class); public Type getType() { return TYPE; } } Node-path: niagara/korsMaster/src/com/korsengineering/niagara/logic/BTrueAnd.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 3418 Text-content-md5: 52861dadadea16a0bfc9b7b5f08d104f Text-content-sha1: 23f6be96de4d7bf27e807f4ec35415c049914064 Content-length: 3428 PROPS-END package com.korsengineering.niagara.logic; import javax.baja.status.*; import javax.baja.sys.*; import javax.baja.control.*; /**Accepts StatusBoolean True / False inputs. *NULL inputs are interpreted as False.*/ public class BTrueAnd extends BComponent{ public boolean testA, testB, testC, testD, testE, allTrue; public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } if (property == inA || property == inB || property == inC || property == inD || property == inE){ doTest(); } } /**Check the inputs for valid boolean values*/ public void doTest() { if (getInA().getStatus().isNull()) { testA = false; } else { testA = getInA().getValue(); } if (getInB().getStatus().isNull()) { testB = false; } else { testB = getInB().getValue(); } if (getInC().getStatus().isNull()) { testC = false; } else { testC = getInC().getValue(); } if (getInD().getStatus().isNull()) { testD = false; } else { testD = getInD().getValue(); } if (getInE().getStatus().isNull()) { testE = false; } else { testE = getInE().getValue(); } if (testA == true && testB == true && testC == true && testD == true && testE == true){ allTrue = true; } else { allTrue = false; } setOutput(new BStatusBoolean(allTrue)); } public final static Property output = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public final static Property inA = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public final static Property inB = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public final static Property inC = newProperty(Flags.SUMMARY, new BStatusBoolean(true)); public final static Property inD = newProperty(Flags.SUMMARY, new BStatusBoolean(true)); public final static Property inE = newProperty(Flags.SUMMARY, new BStatusBoolean(true)); public BStatusBoolean getOutput() { return (BStatusBoolean)get(output); } public BStatusBoolean getInA() { return (BStatusBoolean)get(inA); } public BStatusBoolean getInB() { return (BStatusBoolean)get(inB); } public BStatusBoolean getInC() { return (BStatusBoolean)get(inC); } public BStatusBoolean getInD() { return (BStatusBoolean)get(inD); } public BStatusBoolean getInE() { return (BStatusBoolean)get(inE); } public void setOutput(BStatusBoolean v) { set(output, v); } public void setInA(BStatusBoolean v) { set(inA, v); } public void setInB(BStatusBoolean v) { set(inB, v); } public void setInC(BStatusBoolean v) { set(inC, v); } public void setInD(BStatusBoolean v) { set(inD, v); } public void setInE(BStatusBoolean v) { set(inE, v); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BTrueAnd.class); public Type getType() { return TYPE; } } Node-path: niagara/korsMaster/src/com/korsengineering/niagara/math Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsMaster/src/com/korsengineering/niagara/math/BRoundUp.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 1118 Text-content-md5: fd7154a1991437143614174d63cfa2f2 Text-content-sha1: 17fae1aa4bbb142878538a370ebedb8c41c72d83 Content-length: 1128 PROPS-END package com.korsengineering.niagara.math; import javax.baja.sys.*; import javax.baja.status.*; public class BRoundUp extends BComponent{ public void started(){ try{ if (getSlot("Input").isProperty()){ //Check for slot } } catch(Exception ex){ add("Input", new BStatusNumeric(0), Flags.SUMMARY); add("Output", new BStatusNumeric(0), Flags.SUMMARY); } } public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } if (property == getProperty("Input")){ double a, b; a = ((BStatusNumeric)get(getProperty("Input"))).getValue(); b = Math.ceil(a); set(getProperty("Output"), new BStatusNumeric(b)); } } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BRoundUp.class); public Type getType() { return TYPE; } } Node-path: niagara/korsMaster/src/com/korsengineering/niagara/timer Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsMaster/src/com/korsengineering/niagara/timer/BStationStartTimer.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 4774 Text-content-md5: d7d210e6cc05e87b8024195368333a60 Text-content-sha1: 6765bdeae5859bccce83327f3b98d4ecc3fa2391 Content-length: 4784 PROPS-END package com.korsengineering.niagara.timer; import javax.baja.status.*; import javax.baja.sys.*; import javax.baja.control.*; import java.util.*; /**Uses the module started() function to initiate a delay time.*/ public class BStationStartTimer extends BComponent{ public int delay, period, presetTemp, remain; public BRelTime presetTime, remainTime; public void started(){ setTimerDone(new BStatusBoolean(getOnStartTimerIs().getValue())); delay = 0; period = 1000; setPreset(); remain = presetTemp; setRemain(); final Timer timer = new Timer(); timer.scheduleAtFixedRate(new TimerTask() { public void run() { if (remain > presetTemp){ remain = presetTemp; setRemain(); } if(remain >= 0){ remain -= 1; setRemain(); } if (remain < 0){ remain = 0; setRemain(); setTimerDone(new BStatusBoolean(!getOnStartTimerIs().getValue())); timer.cancel(); } } }, delay, period); } public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } if(property == presetInSeconds){ setPreset(); } if(property == onStartTimerIs){ setTimerDone(new BStatusBoolean(!getOnStartTimerIs().getValue())); } } public void setPreset() { presetTemp = (int)getPresetInSeconds().getValue(); presetTime = BRelTime.makeSeconds(presetTemp); setPreset(presetTime.abs()); } public void setRemain() { remainTime = BRelTime.makeSeconds(remain); setTimeRemaining(remainTime.abs()); setTimeRemainingInSeconds(new BStatusNumeric(remain)); } public void doEndTimer(){ if (remain > 4){ remain = 4; setRemain(); } } /**This action writes a value of 4 seconds to the remaining time*/ public static final Action endTimer = newAction(0); /**This describes what the timerDone state will be when the timer is timing*/ public static final Property onStartTimerIs = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); /**Is set to the opposite of onStartTimerIs value when the timer is complete*/ public static final Property timerDone = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); /**The preset for the timer expressed in total seconds*/ public static final Property presetInSeconds = newProperty(Flags.SUMMARY, new BStatusNumeric(300)); /**The preset represented in relative time*/ public static final Property preset = newProperty(Flags.SUMMARY, BRelTime.DEFAULT); /**The time remaining represented in total seconds*/ public static final Property timeRemainingInSeconds = newProperty(Flags.SUMMARY, new BStatusNumeric(0)); /**The time remaining represented in relative time*/ public static final Property timeRemaining = newProperty(Flags.SUMMARY, BRelTime.DEFAULT); public BStatusBoolean getOnStartTimerIs() { return (BStatusBoolean)get(onStartTimerIs); } public BStatusBoolean getTimerDone() { return (BStatusBoolean)get(timerDone); } public BStatusNumeric getPresetInSeconds() { return (BStatusNumeric)get(presetInSeconds); } public BRelTime getPreset() { return (BRelTime)get(preset); } public BStatusNumeric getTimeRemainingInSeconds() { return (BStatusNumeric)get(timeRemainingInSeconds); } public BRelTime getTimeRemaining() { return (BRelTime)get(timeRemaining); } public void setOnStartTimerIs(BStatusBoolean v) { set(onStartTimerIs, v); } public void setTimerDone(BStatusBoolean v) { set(timerDone, v); } public void setPresetInSeconds(BStatusNumeric v) { set(presetInSeconds, v); } public void setPreset(BRelTime v) { set(preset, v); } public void setTimeRemainingInSeconds(BStatusNumeric v) { set(timeRemainingInSeconds, v); } public void setTimeRemaining(BRelTime v) { set(timeRemaining, v); } public void endTimer() { invoke(endTimer, null, null); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BStationStartTimer.class); public Type getType() { return TYPE; } } Node-path: niagara/korsMaster/src/com/korsengineering/niagara/timer/BTempWrite.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 3597 Text-content-md5: 77e2639c01cdaf2d7191c5d4dc5e865a Text-content-sha1: 4c6cd1e99b7d73e49c0e7e30740e7ff6504b3744 Content-length: 3607 PROPS-END package com.korsengineering.niagara.timer; import javax.baja.status.*; import javax.baja.sys.*; import java.util.*; public class BTempWrite extends BComponent{ boolean fired = false; Clock.Ticket ticket; public void started(){ doSetNull(); } void updateTimer(){ if (ticket != null) ticket.cancel(); ticket = Clock.schedule(this, getWriteDuration(), setNull, null); } public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } if (property == trigger){ //System.out.println(this.asComponent().getNavName() + ':' + getTrigger().getBoolean() + ':' + fired ); if (getTrigger().getValue() && fired == false){ fired = true; getOutput().setValue(getInput().getValue()); getOutput().setStatusNull(false); updateTimer(); } else { fired = false; } } } public void doSetNull(){ this.getOutput().setStatusNull(true); } public void doSetWriteTime(BInteger i){ setWriteDuration(BRelTime.makeSeconds(i.getInt())); } public void doWriteThisValue(BInteger i){ getOutput().setValue(i.getDouble()); this.getOutput().setStatusNull(false); updateTimer(); } // public BValue getActionParameterDefault(Action action) { // if (action == BTempWrite.writeThisValue) { // return getInput().asValue(); // } else { // return action.getParameterDefault(); // } // } public static final Action setWriteTime = newAction(0, BInteger.make(1)); public static final Action writeThisValue = newAction(0,BInteger.make(1)); public static final Action setNull = newAction(0); public static final Property input = newProperty(Flags.SUMMARY, new BStatusNumeric()); public static final Property output = newProperty(Flags.SUMMARY, new BStatusNumeric()); public static final Property writeDuration = newProperty(Flags.SUMMARY, BRelTime.DEFAULT); public BStatusNumeric getInput() { return (BStatusNumeric)get(input); } public BStatusNumeric getOutput() { if (ticket != null){ return (BStatusNumeric)get(output); } else{ return (new BStatusNumeric()); } } public BRelTime getWriteDuration() { return (BRelTime)get(writeDuration); } public void setInput(BStatusNumeric v) { set(input, v); } public void setOutput(BStatusNumeric v) { set(output, v); } public void setWriteDuration(BRelTime v) { set(writeDuration, v); } public void setWriteTime(BInteger x) { invoke(setWriteTime, x, null); } public void writeThisValue( BInteger now) { invoke(writeThisValue, now, null); } public void setNull(){ invoke(setNull,null,null); } public static final Property trigger = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BStatusBoolean getTrigger() { return (BStatusBoolean)get(trigger); } public void setTrigger(BStatusBoolean v) { set(trigger, v); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BTempWrite.class); public Type getType() { return TYPE; } } Node-path: niagara/korsMaster/src/com/korsengineering/niagara/timer/BTimer.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 5299 Text-content-md5: d7e45392e48d9ba38e808bdc2b40a173 Text-content-sha1: 9bc79f7285a6fae97339cb2d4748b2225d7c282e Content-length: 5309 PROPS-END package com.korsengineering.niagara.timer; import javax.baja.status.*; import javax.baja.sys.*; import javax.baja.control.*; import java.util.*; /**A timer that uses a StatusNumeric input of seconds as a preset *and outputs a remaining time also as a StatusNumeric represented in *total seconds*/ public class BTimer extends BComponent{ public int delay, period, presetTemp, remain; public BRelTime presetTime, remainTime; public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } if(property == presetInSeconds){ setPreset(); } if (property == runTimer) { if (!getRunTimer().getValue()){ setTimerDone(new BStatusBoolean(false)); remain = 0; setRemain(); } if (getRunTimer().getValue()){ setTimerDone(new BStatusBoolean(false)); delay = 0; period = 1000; remain = presetTemp; setRemain(); final Timer timer = new Timer(); timer.scheduleAtFixedRate(new TimerTask() { public void run() { if (remain > presetTemp){ remain = presetTemp; setRemain(); } if(remain >= 0){ remain -= 1; setRemain(); } if(!getRunTimer().getValue()) { remain = 0; setRemain(); setTimerDone(new BStatusBoolean(false)); timer.cancel(); } if (remain < 0){ remain = 0; setRemain(); setTimerDone(new BStatusBoolean(true)); timer.cancel(); } } }, delay, period); } } } public void setPreset() { presetTemp = (int)getPresetInSeconds().getValue(); presetTime = BRelTime.makeSeconds(presetTemp); setPreset(presetTime.abs()); } public void setRemain() { remainTime = BRelTime.makeSeconds(remain); setTimeRemaining(remainTime.abs()); setTimeRemainingInSeconds(new BStatusNumeric(remain)); } public void doEndTimer(){ if (remain > 4){ remain = 4; setRemain(); } } /**This action writes a value of 4 seconds to the remaining time*/ public static final Action endTimer = newAction(0); /**When this is True, the timer activates*/ public static final Property runTimer = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); /**Is set to True when the timer completes*/ public static final Property timerDone = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); /**The preset for the timer expressed in total seconds*/ public static final Property presetInSeconds = newProperty(Flags.SUMMARY, new BStatusNumeric(0)); /**The preset represented in relative time*/ public static final Property preset = newProperty(Flags.SUMMARY, BRelTime.DEFAULT); /**The time remaining represented in total seconds*/ public static final Property timeRemainingInSeconds = newProperty(Flags.SUMMARY, new BStatusNumeric(0)); /**The time remaining represented in relative time*/ public static final Property timeRemaining = newProperty(Flags.SUMMARY, BRelTime.DEFAULT); public BStatusBoolean getRunTimer() { return (BStatusBoolean)get(runTimer); } public BStatusBoolean getTimerDone() { return (BStatusBoolean)get(timerDone); } public BStatusNumeric getPresetInSeconds() { return (BStatusNumeric)get(presetInSeconds); } public BRelTime getPreset() { return (BRelTime)get(preset); } public BStatusNumeric getTimeRemainingInSeconds() { return (BStatusNumeric)get(timeRemainingInSeconds); } public BRelTime getTimeRemaining() { return (BRelTime)get(timeRemaining); } public void setRunTimer(BStatusBoolean v) { set(runTimer, v); } public void setTimerDone(BStatusBoolean v) { set(timerDone, v); } public void setPresetInSeconds(BStatusNumeric v) { set(presetInSeconds, v); } public void setPreset(BRelTime v) { set(preset, v); } public void setTimeRemainingInSeconds(BStatusNumeric v) { set(timeRemainingInSeconds, v); } public void setTimeRemaining(BRelTime v) { set(timeRemaining, v); } public void endTimer() { invoke(endTimer, null, null); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BTimer.class); public Type getType() { return TYPE; } } Node-path: niagara/korsMaster/src/com/korsengineering/niagara/triggeredMath Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsMaster/src/com/korsengineering/niagara/triggeredMath/BTrAdd.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 2646 Text-content-md5: 74f8d89cb5c4a376d8356023bcd4dafb Text-content-sha1: 151cb1ce38f311e695884760ebdd851c1ad7191d Content-length: 2656 PROPS-END package com.korsengineering.niagara.triggeredMath; import javax.baja.sys.*; import javax.baja.status.*; public class BTrAdd extends BComponent{ boolean fire = false; public void started(){ try{ if (getSlot("Out").isProperty()){ //Check for slot } } catch(Exception ex){ add("Out", new BStatusNumeric(0), Flags.SUMMARY); add("In$20A", new BStatusNumeric(0), Flags.SUMMARY); add("In$20B", new BStatusNumeric(0), Flags.SUMMARY); add("In$20C", new BStatusNumeric(0), 0); add("In$20D", new BStatusNumeric(0), 0); } } public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } try{ if (property == facets){ setFacets(getSlot("Out"), getFacets()); setFacets(getSlot("In$20A"), getFacets()); setFacets(getSlot("In$20B"), getFacets()); setFacets(getSlot("In$20C"), getFacets()); setFacets(getSlot("In$20D"), getFacets()); } if (property == trigger){ if (getTrigger().getValue() && fire == false){ double a, b, c, d, result; a = ((BStatusNumeric)get(getProperty("In$20A"))).getValue(); b = ((BStatusNumeric)get(getProperty("In$20B"))).getValue(); c = ((BStatusNumeric)get(getProperty("In$20C"))).getValue(); d = ((BStatusNumeric)get(getProperty("In$20D"))).getValue(); result = a + b + c + d; set(getProperty("Out"), new BStatusNumeric(result)); fire = true; } else { fire = false; } } } catch(Exception e){ System.out.println(BAbsTime.now().toString() + ": Kors Component Error at " + this.getSlotPath().toString() + ":" + e.toString()); } } public static final Property facets = newProperty(0, BFacets.makeNumeric(1)); public static final Property trigger = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BFacets getFacets() { return (BFacets)get(facets); } public BStatusBoolean getTrigger() { return (BStatusBoolean)get(trigger); } public void setFacets(BFacets v) { set(facets, v); } public void setTrigger(BStatusBoolean v) { set(trigger, v); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BTrAdd.class); public Type getType() { return TYPE; } } Node-path: niagara/korsMaster/src/com/korsengineering/niagara/triggeredMath/BTrCopy.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 2059 Text-content-md5: 82ee5bb714f780587e97bd99a5a8bed8 Text-content-sha1: 4023025ebd2558c9f768e92279bc622cfffe6cc0 Content-length: 2069 PROPS-END package com.korsengineering.niagara.triggeredMath; import javax.baja.sys.*; import javax.baja.status.*; public class BTrCopy extends BComponent{ boolean fire = false; public void started(){ try{ if (getSlot("Copy").isProperty()){ //Check for slot } } catch(Exception ex){ add("Copy", new BStatusNumeric(0), Flags.SUMMARY); add("Input", new BStatusNumeric(0), Flags.SUMMARY); } } public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } try{ if (property == facets){ setFacets(getSlot("Copy"), getFacets()); setFacets(getSlot("Input"), getFacets()); } if (property == trigger){ if (getTrigger().getValue() && fire == false){ double a; a = ((BStatusNumeric)get(getProperty("Input"))).getValue(); set(getProperty("Copy"), new BStatusNumeric(a)); fire = true; } else { fire = false; } } } catch(Exception e){ System.out.println(BAbsTime.now().toString() + ": Kors Component Error at " + this.getSlotPath().toString() + ":" + e.toString()); } } public static final Property facets = newProperty(0, BFacets.makeNumeric(1)); public static final Property trigger = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BFacets getFacets() { return (BFacets)get(facets); } public BStatusBoolean getTrigger() { return (BStatusBoolean)get(trigger); } public void setFacets(BFacets v) { set(facets, v); } public void setTrigger(BStatusBoolean v) { set(trigger, v); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BTrCopy.class); public Type getType() { return TYPE; } } Node-path: niagara/korsMaster/src/com/korsengineering/niagara/triggeredMath/BTrDivide.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 2432 Text-content-md5: b48202cad414d3941c5b938042039748 Text-content-sha1: 59719c20ee003e2b15f7002951b4cae9a372b977 Content-length: 2442 PROPS-END package com.korsengineering.niagara.triggeredMath; import javax.baja.sys.*; import javax.baja.status.*; public class BTrDivide extends BComponent{ boolean fire = false; public void started(){ try{ if (getSlot("Out").isProperty()){ //Check for slot } } catch(Exception ex){ add("Out", new BStatusNumeric(0), Flags.SUMMARY); add("In$20A", new BStatusNumeric(0), Flags.SUMMARY); add("In$20B", new BStatusNumeric(0), Flags.SUMMARY); } } public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } try{ if (property == facets){ setFacets(getSlot("Out"), getFacets()); setFacets(getSlot("In$20A"), getFacets()); setFacets(getSlot("In$20B"), getFacets()); } if (property == trigger){ if (getTrigger().getValue() && fire == false){ double a, b, result; a = ((BStatusNumeric)get(getProperty("In$20A"))).getValue(); b = ((BStatusNumeric)get(getProperty("In$20B"))).getValue(); if (b != 0){ result = a / b; set(getProperty("Out"), new BStatusNumeric(result)); } else { getTrigger().setStatus(BStatus.fault); } fire = true; } else { fire = false; } } } catch(Exception e){ System.out.println(BAbsTime.now().toString() + ": Kors Component Error at " + this.getSlotPath().toString() + ":" + e.toString()); } } public static final Property facets = newProperty(0, BFacets.makeNumeric(1)); public static final Property trigger = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BFacets getFacets() { return (BFacets)get(facets); } public BStatusBoolean getTrigger() { return (BStatusBoolean)get(trigger); } public void setFacets(BFacets v) { set(facets, v); } public void setTrigger(BStatusBoolean v) { set(trigger, v); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BTrDivide.class); public Type getType() { return TYPE; } } Node-path: niagara/korsMaster/src/com/korsengineering/niagara/triggeredMath/BTrMultiply.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 2305 Text-content-md5: ff5038340d44a8c57b784210ecaa644a Text-content-sha1: 99208dea2f79792f9c40f63978c9e00edd80b301 Content-length: 2315 PROPS-END package com.korsengineering.niagara.triggeredMath; import javax.baja.sys.*; import javax.baja.status.*; public class BTrMultiply extends BComponent{ boolean fire = false; public void started(){ try{ if (getSlot("Out").isProperty()){ //Check for slot } } catch(Exception ex){ add("Out", new BStatusNumeric(0), Flags.SUMMARY); add("In$20A", new BStatusNumeric(0), Flags.SUMMARY); add("In$20B", new BStatusNumeric(0), Flags.SUMMARY); } } public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } try{ if (property == facets){ setFacets(getSlot("Out"), getFacets()); setFacets(getSlot("In$20A"), getFacets()); setFacets(getSlot("In$20B"), getFacets()); } if (property == trigger){ if (getTrigger().getValue() && fire == false){ double a, b, result; a = ((BStatusNumeric)get(getProperty("In$20A"))).getValue(); b = ((BStatusNumeric)get(getProperty("In$20B"))).getValue(); result = a * b; set(getProperty("Out"), new BStatusNumeric(result)); fire = true; } else { fire = false; } } } catch(Exception e){ System.out.println(BAbsTime.now().toString() + ": Kors Component Error at " + this.getSlotPath().toString() + ":" + e.toString()); } } public static final Property facets = newProperty(0, BFacets.makeNumeric(1)); public static final Property trigger = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BFacets getFacets() { return (BFacets)get(facets); } public BStatusBoolean getTrigger() { return (BStatusBoolean)get(trigger); } public void setFacets(BFacets v) { set(facets, v); } public void setTrigger(BStatusBoolean v) { set(trigger, v); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BTrMultiply.class); public Type getType() { return TYPE; } } Node-path: niagara/korsMaster/src/com/korsengineering/niagara/triggeredMath/BTrSubtract.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 2306 Text-content-md5: a59bca77ed4d1e133d946046ef792a00 Text-content-sha1: a0ec7ce96aaf9fde80a47d151768a18a37073abc Content-length: 2316 PROPS-END package com.korsengineering.niagara.triggeredMath; import javax.baja.sys.*; import javax.baja.status.*; public class BTrSubtract extends BComponent{ boolean fire = false; public void started(){ try{ if (getSlot("Out").isProperty()){ //Check for slot } } catch(Exception ex){ add("Out", new BStatusNumeric(0), Flags.SUMMARY); add("In$20A", new BStatusNumeric(0), Flags.SUMMARY); add("In$20B", new BStatusNumeric(0), Flags.SUMMARY); } } public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } try{ if (property == facets){ setFacets(getSlot("Out"), getFacets()); setFacets(getSlot("In$20A"), getFacets()); setFacets(getSlot("In$20B"), getFacets()); } if (property == trigger){ if (getTrigger().getValue() && fire == false){ double a, b, result; a = ((BStatusNumeric)get(getProperty("In$20A"))).getValue(); b = ((BStatusNumeric)get(getProperty("In$20B"))).getValue(); result = a - b; set(getProperty("Out"), new BStatusNumeric(result)); fire = true; } else { fire = false; } } } catch(Exception e){ System.out.println(BAbsTime.now().toString() + ": Kors Component Error at " + this.getSlotPath().toString() + ":" + e.toString()); } } public static final Property facets = newProperty(0, BFacets.makeNumeric(1)); public static final Property trigger = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BFacets getFacets() { return (BFacets)get(facets); } public BStatusBoolean getTrigger() { return (BStatusBoolean)get(trigger); } public void setFacets(BFacets v) { set(facets, v); } public void setTrigger(BStatusBoolean v) { set(trigger, v); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BTrSubtract.class); public Type getType() { return TYPE; } } Node-path: niagara/korsNotification Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsNotification/.classpath Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 3122 Text-content-md5: a8736b9fc4841042b7ddbaa937afeec8 Text-content-sha1: 7a489de5cdceec24f012af3bdfd6c1af6493b9bd Content-length: 3132 PROPS-END Node-path: niagara/korsNotification/.project Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 392 Text-content-md5: ebdc1f73ef5abf67df6991007f95a222 Text-content-sha1: 1d6aa552ab937d72fc2eb668b4687217b6c6d6f7 Content-length: 402 PROPS-END korsNotification org.eclipse.jdt.core.javabuilder org.eclipse.jdt.core.javanature Node-path: niagara/korsNotification/.settings Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsNotification/.settings/org.eclipse.jdt.core.prefs Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 334 Text-content-md5: 8be1eafe5c4c1f81c24d2753841fbe7a Text-content-sha1: 332abb8e8687b72ca928c6fdb47923cb0fe08853 Content-length: 344 PROPS-END #Tue Feb 12 14:02:55 EST 2008 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 org.eclipse.jdt.core.compiler.compliance=1.4 org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning org.eclipse.jdt.core.compiler.source=1.3 Node-path: niagara/korsNotification/.settings/org.eclipse.jdt.ui.prefs Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 179 Text-content-md5: 21dfd4af6902978e1111528722fe4c70 Text-content-sha1: 12764a44802a33255e785e18a06584941ae3f4a7 Content-length: 189 PROPS-END #Fri Jan 25 13:48:36 EST 2008 eclipse.preferences.version=1 org.eclipse.jdt.ui.text.custom_code_templates= Node-path: niagara/korsNotification/build.xml Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 406 Text-content-md5: 1686a8686c787c846263f0537b3805aa Text-content-sha1: 5c4ebaa6b47532f6a9978ca401f4bc38f9097e5a Content-length: 416 PROPS-END Node-path: niagara/korsNotification/module-include.xml Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 375 Text-content-md5: 9a0c18bcbf668863892f7b8b0f272e31 Text-content-sha1: ef92c6c44ad73fb4dae0ff7f384cad9290c790cb Content-length: 385 PROPS-END Node-path: niagara/korsNotification/module.palette Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 200 Text-content-md5: 9641e206ec7dbf04e92f0e119613e4b7 Text-content-sha1: 54405805ce2ebe061ca21edefe7092693c9d15f4 Content-length: 210 PROPS-END

Node-path: niagara/korsNotification/src Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsNotification/src/com Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsNotification/src/com/korsengineering Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsNotification/src/com/korsengineering/niagara Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsNotification/src/com/korsengineering/niagara/notification Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsNotification/src/com/korsengineering/niagara/notification/BPathNotif.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 325 Text-content-md5: 8e28cb21d5ebe719c58b4af361c99129 Text-content-sha1: 2f0a53ae238802baec861154a8253878869920ad Content-length: 335 PROPS-END package com.korsengineering.niagara.notification; import javax.baja.sys.Sys; import javax.baja.sys.Type; import javax.baja.util.BNotification; // Test of SVN public class BPathNotif extends BNotification{ public Type getType() { return TYPE; } public static final Type TYPE = Sys.loadType(BPathNotif.class); } Node-path: niagara/korsNotification/src/com/korsengineering/niagara/notification/BPathNotifHandler.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 2955 Text-content-md5: dc94b00423fc7d0afb49d6d06fbc7f28 Text-content-sha1: b1293b87c405bf44136b304989cdf94e95693457 Content-length: 2965 PROPS-END package com.korsengineering.niagara.notification; import javax.baja.gx.BImage; import javax.baja.sys.BString; import javax.baja.sys.BajaRuntimeException; import javax.baja.sys.Context; import javax.baja.sys.Sys; import javax.baja.sys.Type; import javax.baja.ui.BButton; import javax.baja.ui.BDialog; import javax.baja.ui.BLabel; import javax.baja.ui.BWidget; import javax.baja.ui.Command; import javax.baja.ui.CommandArtifact; import javax.baja.ui.enums.BHalign; import javax.baja.ui.enums.BValign; import javax.baja.ui.pane.BBorderPane; import javax.baja.ui.pane.BGridPane; import javax.baja.ui.util.UiLexicon; import javax.baja.util.BNotification; import javax.baja.util.Lexicon; import javax.baja.workbench.BWbShell; import javax.baja.workbench.util.BNotificationHandler; import com.tridium.ui.theme.Theme; public class BPathNotifHandler extends BNotificationHandler{ public void handle(BWbShell shell, BNotification notify, Context cx) { if (!(notify instanceof BPathNotif)) { throw new BajaRuntimeException("Invalid notification type"); } String sourcePath = ((BString) notify.get("path")).getString().replaceFirst(".*:", ""); String currentPath = shell.getActiveOrd().encodeToString().replaceFirst(".*:", ""); if (!sourcePath.startsWith(currentPath)) { return; } BImage icon = BImage.make("module://icons/x32/warning.png"); BString t = (BString) notify.get("title"); BString m = (BString) notify.get("message"); Lexicon lex = Lexicon.make("workbench", cx); String title = (t != null) ? t.getString() : lex.getText("notify.handler.notification"); String msg = (m != null) ? m.getString() : lex.getText("notify.handler.unknown"); BGridPane grid1 = new BGridPane(1); grid1.add(null, new BLabel(title, Theme.widget().getBoldText())); grid1.add(null, new BLabel(msg + "\n"+"Source path " + sourcePath+"\n"+"Current path " + currentPath, BHalign.left)); BGridPane grid2 = new BGridPane(2); grid2.setColumnGap(10); grid2.setRowAlign(BValign.top); grid2.add(null, new BLabel(icon)); grid2.add(null, grid1); OkCommand ok = new OkCommand(shell); BGridPane grid3; grid3 = new BGridPane(1); grid3.add(null, new BButton(ok)); BGridPane grid4 = new BGridPane(1); grid4.setRowGap(15); grid4.setColumnAlign(BHalign.center); grid4.add(null, grid2); grid4.add(null, grid3); BBorderPane pane = new BBorderPane(grid4); BDialog dlg = new BDialog(shell, title, true, pane); ok.dlg = dlg; dlg.setBoundsCenteredOnOwner(); dlg.open(); } static class OkCommand extends Command { public OkCommand(BWidget owner) { super(owner, UiLexicon.bajaui.getText("action.ok")); } public CommandArtifact doInvoke() { dlg.close(); return null; } BDialog dlg; } public Type getType() { return TYPE; } public static final Type TYPE = Sys.loadType(BPathNotifHandler.class); } Node-path: niagara/korsNotification/src/com/korsengineering/niagara/notification/BPathNotifTrigger.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 2533 Text-content-md5: d40ca900651b13d4af04e337e14646b3 Text-content-sha1: fbc3de3407b0116919299410675c93c3775e1343 Content-length: 2543 PROPS-END package com.korsengineering.niagara.notification; import javax.baja.status.BStatusBoolean; import javax.baja.status.BStatusString; import javax.baja.sys.Action; import javax.baja.sys.BComponent; import javax.baja.sys.BString; import javax.baja.sys.BajaRuntimeException; import javax.baja.sys.Context; import javax.baja.sys.Flags; import javax.baja.sys.Property; import javax.baja.sys.Sys; import javax.baja.sys.Type; public class BPathNotifTrigger extends BComponent{ boolean lastTriggerBroadcastState = false; public void changed(Property property, Context context){ super.changed(property, context); if (property == triggerBroadcast && Sys.atSteadyState()) { try { if (getTriggerBroadcast().getValue() && (lastTriggerBroadcastState == false)) { doBroadcast(); } } catch (Exception ex) { throw new BajaRuntimeException(ex); } finally { lastTriggerBroadcastState = getTriggerBroadcast().getValue(); } } } public static final Property title = newProperty(Flags.SUMMARY, new BStatusString("Path Notification")); public BStatusString getTitle() { return (BStatusString) get(title); } public void setTitle(BStatusString v) { set(title, v); } public static final Property text = newProperty(Flags.SUMMARY, new BStatusString()); public BStatusString getText() { return (BStatusString) get(title); } public void setText(BStatusString v) { set(title, v); } public static final Property triggerBroadcast = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BStatusBoolean getTriggerBroadcast() { return (BStatusBoolean) get(triggerBroadcast); } public void setTriggerBroadcast(BStatusBoolean v) { set(triggerBroadcast, v); } public static final Action broadcast = newAction(0); public void broadcast() { invoke(broadcast, null); } //invokes public void doBroadcast() throws Exception{ BPathNotif x = new BPathNotif(); x.add("title", BString.make(getTitle().getValue())); x.add("message", BString.make(getText().getValue())); x.add("path", BString.make(getNavOrd().encodeToString())); x.raise(true); } public Type getType() { return TYPE; } public static final Type TYPE = Sys.loadType(BPathNotifTrigger.class); } Node-path: niagara/korsOrm Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsOrm/.classpath Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 2762 Text-content-md5: d807d679fd728589f1b9e2511f04c695 Text-content-sha1: 42cdb7835bd129781ed9da2d1af060a877fd8dec Content-length: 2772 PROPS-END Node-path: niagara/korsOrm/.project Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 383 Text-content-md5: 73c075de086706bc0db90e49c408321f Text-content-sha1: 7f36981906a3e024173c516f5d67bdcacdb2a0b5 Content-length: 393 PROPS-END korsOrm org.eclipse.jdt.core.javabuilder org.eclipse.jdt.core.javanature Node-path: niagara/korsOrm/.settings Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsOrm/.settings/org.eclipse.jdt.core.prefs Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 330 Text-content-md5: 48df06ad3bf143e2569b786e7d17409d Text-content-sha1: e1afedc9f8f4191fcd299f5e7e5cf6c50ac8871e Content-length: 340 PROPS-END #Thu Feb 07 13:04:26 EST 2008 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 org.eclipse.jdt.core.compiler.compliance=1.5 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.source=1.5 Node-path: niagara/korsOrm/build.xml Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 460 Text-content-md5: 749c23662db9ccd48a63db2ec0f9f03b Text-content-sha1: dffba66195a9b607010e5ff075293d2e14e6308f Content-length: 470 PROPS-END Node-path: niagara/korsOrm/module-include.xml Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 149 Text-content-md5: e93441212ef9845ff191170df7e1fc23 Text-content-sha1: 4630337afabc71670dc1bc223502d78f799813da Content-length: 159 PROPS-END Node-path: niagara/korsOrm/module-include.xml.bak Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 148 Text-content-md5: 9abec960e56664e2240799e76172d51b Text-content-sha1: 0b641bd44138b34731fd79b510540314546ce400 Content-length: 158 PROPS-END Node-path: niagara/korsOrm/module.palette Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 181 Text-content-md5: 99e1920c3e6ae8e2254198206d2144f1 Text-content-sha1: f7e4ec8ecd774bfb8c00d33649b340b0851bbe8e Content-length: 191 PROPS-END

Node-path: niagara/korsOrm/src Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsOrm/src/com Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsOrm/src/com/korsengineering Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsOrm/src/com/korsengineering/plexus Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/BRecordWriter.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 12119 Text-content-md5: 50afca5fa31ebde47d5e22a74a8c141b Text-content-sha1: b64ec772a562ef6fd2942f7c6f5404c70f4166cb Content-length: 12129 PROPS-END package com.korsengineering.plexus.db.orm; import javax.baja.control.*; import javax.baja.security.BPassword; import javax.baja.status.BStatusBoolean; import javax.baja.sys.Action; import javax.baja.sys.BComponent; import javax.baja.sys.BajaRuntimeException; import javax.baja.sys.Context; import javax.baja.sys.Flags; import javax.baja.sys.Property; import javax.baja.sys.Sys; import javax.baja.sys.Type; import java.sql.*; /** * @author Roman Ivanov */ public class BRecordWriter extends BComponent { protected boolean lastTriggerState = false; public void changed(Property property, Context context) { super.changed(property, context); if (property == saveTrigger) { try { if (getSaveTrigger().getValue() && lastTriggerState == false) { setQuery(getCurrentQuery()); doSave(); } } catch (Exception ex) { throw new BajaRuntimeException(ex); } finally { lastTriggerState = getSaveTrigger().getValue(); } } } public String getCurrentQuery() { String query = "INSERT INTO " + getDbTable() + " "; String keys = ""; String values = ""; Property[] properties = getDynamicPropertiesArray(); for (int i = 0; i < properties.length; i++) { String value = ""; if (properties[i].getType() == BStringWritable.TYPE) { value = ((BStringWritable) get(properties[i])).getOut() .getValue(); } else if (properties[i].getType() == BNumericWritable.TYPE) { value = Double.toString(((BNumericWritable) get(properties[i])) .getOut().getValue()); } else if (properties[i].getType() == BBooleanWritable.TYPE) { value = ((BBooleanWritable) get(properties[i])).getOut() .getValue() ? "1" : "0"; } else { continue; } values += "'" + value + "'"; keys += properties[i].getName(); if (i != properties.length - 1) { values += ", "; keys += ", "; } } if (keys.isEmpty()) { return ""; } query += "(" + keys + ") VALUES (" + values + ")"; return query; } public void doGenerateQuery() { setQuery(getCurrentQuery()); } public void doSave() throws SQLException { DB db = new DB(); Connection conn = db.dbConnect("jdbc:mysql://" + getDbHost() + ":" + getDbPort() + "/" + getDbName(), getDbLogin(), getDbPass() .getString()); Statement statement = conn.createStatement(); statement.execute(getQuery()); } /*- class BRecordWriter { properties { dbHost: String flags { summary } default {[ "localhost" ]} dbPort: String flags { summary } default {[ "3306" ]} dbName: String flags { summary } default {[ "" ]} dbLogin: String flags { summary } default {[ "root" ]} dbPass: BPassword flags { summary } default {[ BPassword.DEFAULT ]} dbTable: String flags { summary } default {[ "dbName" ]} query: String flags { summary , readonly } default {[ "" ]} saveTrigger : BStatusBoolean flags { summary } default {[ new BStatusBoolean(false) ]} } actions { save() generateQuery() } } -*/ /* + ------------ BEGIN BAJA AUTO GENERATED CODE ------------ + */ /* @ $com.korsengineering.plexus.db.orm.BRecordWriter(1561583425)1.0$ @ */ /* * Generated Fri Feb 08 13:01:34 EST 2008 by Slot-o-Matic 2000 (c) Tridium, * Inc. 2000 */ // ////////////////////////////////////////////////////////////// // Property "dbHost" // ////////////////////////////////////////////////////////////// /** * Slot for the dbHost property. * * @see com.korsengineering.plexus.db.orm.BRecordWriter#getDbHost * @see com.korsengineering.plexus.db.orm.BRecordWriter#setDbHost */ public static final Property dbHost = newProperty(Flags.SUMMARY, "localhost", null); /** * Get the dbHost property. * * @see com.korsengineering.plexus.db.orm.BRecordWriter#dbHost */ public String getDbHost() { return getString(dbHost); } /** * Set the dbHost property. * * @see com.korsengineering.plexus.db.orm.BRecordWriter#dbHost */ public void setDbHost(String v) { setString(dbHost, v, null); } // ////////////////////////////////////////////////////////////// // Property "dbPort" // ////////////////////////////////////////////////////////////// /** * Slot for the dbPort property. * * @see com.korsengineering.plexus.db.orm.BRecordWriter#getDbPort * @see com.korsengineering.plexus.db.orm.BRecordWriter#setDbPort */ public static final Property dbPort = newProperty(Flags.SUMMARY, "3306", null); /** * Get the dbPort property. * * @see com.korsengineering.plexus.db.orm.BRecordWriter#dbPort */ public String getDbPort() { return getString(dbPort); } /** * Set the dbPort property. * * @see com.korsengineering.plexus.db.orm.BRecordWriter#dbPort */ public void setDbPort(String v) { setString(dbPort, v, null); } // ////////////////////////////////////////////////////////////// // Property "dbName" // ////////////////////////////////////////////////////////////// /** * Slot for the dbName property. * * @see com.korsengineering.plexus.db.orm.BRecordWriter#getDbName * @see com.korsengineering.plexus.db.orm.BRecordWriter#setDbName */ public static final Property dbName = newProperty(Flags.SUMMARY, "", null); /** * Get the dbName property. * * @see com.korsengineering.plexus.db.orm.BRecordWriter#dbName */ public String getDbName() { return getString(dbName); } /** * Set the dbName property. * * @see com.korsengineering.plexus.db.orm.BRecordWriter#dbName */ public void setDbName(String v) { setString(dbName, v, null); } // ////////////////////////////////////////////////////////////// // Property "dbLogin" // ////////////////////////////////////////////////////////////// /** * Slot for the dbLogin property. * * @see com.korsengineering.plexus.db.orm.BRecordWriter#getDbLogin * @see com.korsengineering.plexus.db.orm.BRecordWriter#setDbLogin */ public static final Property dbLogin = newProperty(Flags.SUMMARY, "root", null); /** * Get the dbLogin property. * * @see com.korsengineering.plexus.db.orm.BRecordWriter#dbLogin */ public String getDbLogin() { return getString(dbLogin); } /** * Set the dbLogin property. * * @see com.korsengineering.plexus.db.orm.BRecordWriter#dbLogin */ public void setDbLogin(String v) { setString(dbLogin, v, null); } // ////////////////////////////////////////////////////////////// // Property "dbPass" // ////////////////////////////////////////////////////////////// /** * Slot for the dbPass property. * * @see com.korsengineering.plexus.db.orm.BRecordWriter#getDbPass * @see com.korsengineering.plexus.db.orm.BRecordWriter#setDbPass */ public static final Property dbPass = newProperty(Flags.SUMMARY, BPassword.DEFAULT, null); /** * Get the dbPass property. * * @see com.korsengineering.plexus.db.orm.BRecordWriter#dbPass */ public BPassword getDbPass() { return (BPassword) get(dbPass); } /** * Set the dbPass property. * * @see com.korsengineering.plexus.db.orm.BRecordWriter#dbPass */ public void setDbPass(BPassword v) { set(dbPass, v, null); } // ////////////////////////////////////////////////////////////// // Property "dbTable" // ////////////////////////////////////////////////////////////// /** * Slot for the dbTable property. * * @see com.korsengineering.plexus.db.orm.BRecordWriter#getDbTable * @see com.korsengineering.plexus.db.orm.BRecordWriter#setDbTable */ public static final Property dbTable = newProperty(Flags.SUMMARY, "dbName", null); /** * Get the dbTable property. * * @see com.korsengineering.plexus.db.orm.BRecordWriter#dbTable */ public String getDbTable() { return getString(dbTable); } /** * Set the dbTable property. * * @see com.korsengineering.plexus.db.orm.BRecordWriter#dbTable */ public void setDbTable(String v) { setString(dbTable, v, null); } // ////////////////////////////////////////////////////////////// // Property "query" // ////////////////////////////////////////////////////////////// /** * Slot for the query property. * * @see com.korsengineering.plexus.db.orm.BRecordWriter#getQuery * @see com.korsengineering.plexus.db.orm.BRecordWriter#setQuery */ public static final Property query = newProperty(Flags.SUMMARY | Flags.READONLY, "", null); /** * Get the query property. * * @see com.korsengineering.plexus.db.orm.BRecordWriter#query */ public String getQuery() { return getString(query); } /** * Set the query property. * * @see com.korsengineering.plexus.db.orm.BRecordWriter#query */ public void setQuery(String v) { setString(query, v, null); } // ////////////////////////////////////////////////////////////// // Property "saveTrigger" // ////////////////////////////////////////////////////////////// /** * Slot for the saveTrigger property. * * @see com.korsengineering.plexus.db.orm.BRecordWriter#getSaveTrigger * @see com.korsengineering.plexus.db.orm.BRecordWriter#setSaveTrigger */ public static final Property saveTrigger = newProperty(Flags.SUMMARY, new BStatusBoolean(false), null); /** * Get the saveTrigger property. * * @see com.korsengineering.plexus.db.orm.BRecordWriter#saveTrigger */ public BStatusBoolean getSaveTrigger() { return (BStatusBoolean) get(saveTrigger); } /** * Set the saveTrigger property. * * @see com.korsengineering.plexus.db.orm.BRecordWriter#saveTrigger */ public void setSaveTrigger(BStatusBoolean v) { set(saveTrigger, v, null); } // ////////////////////////////////////////////////////////////// // Action "save" // ////////////////////////////////////////////////////////////// /** * Slot for the save action. * * @see com.korsengineering.plexus.db.orm.BRecordWriter#save() */ public static final Action save = newAction(0, null); /** * Invoke the save action. * * @see com.korsengineering.plexus.db.orm.BRecordWriter#save */ public void save() { invoke(save, null, null); } // ////////////////////////////////////////////////////////////// // Action "generateQuery" // ////////////////////////////////////////////////////////////// /** * Slot for the generateQuery action. * * @see com.korsengineering.plexus.db.orm.BRecordWriter#generateQuery() */ public static final Action generateQuery = newAction(0, null); /** * Invoke the generateQuery action. * * @see com.korsengineering.plexus.db.orm.BRecordWriter#generateQuery */ public void generateQuery() { invoke(generateQuery, null, null); } // ////////////////////////////////////////////////////////////// // Type // ////////////////////////////////////////////////////////////// public Type getType() { return TYPE; } public static final Type TYPE = Sys.loadType(BRecordWriter.class); /* + ------------ END BAJA AUTO GENERATED CODE -------------- + */ } class DB { public DB() { } public Connection dbConnect(String db_connect_string, String db_userid, String db_password) { try { Class.forName("com.mysql.jdbc.Driver").newInstance(); Connection conn = DriverManager.getConnection(db_connect_string, db_userid, db_password); return conn; } catch (Exception e) { e.printStackTrace(); return null; } } }; Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/.classpath Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 604 Text-content-md5: f5348192825da157a39a76b584af69fb Text-content-sha1: 819764de8696f73720611273ccd4968408f4269e Content-length: 614 PROPS-END Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/.project Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 386 Text-content-md5: 8dd2041d1ef134ce2f6e350fa1c5143f Text-content-sha1: b46802943760d9e9dfdb57fb1c8c95246df80fb9 Content-length: 396 PROPS-END korsMaster org.eclipse.jdt.core.javabuilder org.eclipse.jdt.core.javanature Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/build.xml Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 1007 Text-content-md5: ccf9006c1dd5cec5b423544b291c3e4b Text-content-sha1: 0c0919d49a3f0ab291fbb7591cf8f7e1828462cb Content-length: 1017 PROPS-END Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/module-include.xml Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 2025 Text-content-md5: 323fae5ea314bc832e152d198187ddb7 Text-content-sha1: 55f1f1b82c293f5bcb015ed5cbf64cb42c9b4a4b Content-length: 2035 PROPS-END Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/module.palette Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 1851 Text-content-md5: 28a94ae38baf8292ed523e80fd5ea4d7 Text-content-sha1: 3aced0a736381b2c675a238e3c8a89886affce3c Content-length: 1861 PROPS-END

Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com/korsengineering Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com/korsengineering/niagara Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com/korsengineering/niagara/BQL Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com/korsengineering/niagara/BQL/BIndirectEnum.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 9755 Text-content-md5: c785a48b024452877b3022f0b4010e9a Text-content-sha1: 53c06ac1b719a17ad1339b215d722445c17489a3 Content-length: 9765 PROPS-END package com.korsengineering.niagara.BQL; import java.io.IOException; import java.util.*; import javax.baja.status.*; import javax.baja.sys.*; import javax.baja.control.*; import javax.baja.bql.*; import javax.baja.naming.*; import javax.baja.collection.*; import javax.baja.util.*; public class BIndirectEnum extends BComponent{ public BLink[] linked; public String[] enumTags, enumNames; public int[] enumOrdinals, ordinalList; public int ordEnd, highOrdinal, ordinalIndex, enumNumber, enumTagIndex; public String ordStr, enumTemp, enumStr, enumString, enumStringParse, compName; public static final int RANGESTART = 7; public static String imageFile; public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } if (property == indexIn || property == enumStringIn){ enumTagIndex = 0; try { if (this.getLinks(this.getSlot("enumMasterIn")).length > 0) { linked = new BLink[this.getLinks(this.getSlot("enumMasterIn")).length]; linked = this.getLinks(this.getSlot("enumMasterIn")); for (int x = 0; x < linked.length; ++x) { BComponent bCom = new BComponent(); bCom = linked[x].getSourceComponent(); compName = bCom.getNavDisplayName(bCom.getProperties().getContext()); setMasterEnumName(compName); ordEnd = bCom.getNavOrd().toString().indexOf(bCom.getName()); ordStr = bCom.getNavOrd().toString().substring(7,ordEnd - 1); setMasterEnumAddress(ordStr); BOrd ord = BOrd.make(ordStr + "|bql:select from control:ControlPoint where displayName = '" + compName + "'"); BICollection result = (BICollection)ord.resolve().get(); Cursor c = result.cursor(); while (c.next()){ setMasterEnumFacetList(((BEnumWritable)c.get()).getEnumFacets().toString()); enumTemp = ((BEnumWritable)c.get()).getEnumFacets().toString(); if (enumTemp.indexOf('}') > RANGESTART){ enumStr = enumTemp.substring(RANGESTART, enumTemp.indexOf('}')); StringTokenizer st = new StringTokenizer(enumStr, ","); enumTags = new String[st.countTokens()]; for (int y = 0; st.hasMoreTokens(); ++y) { enumTags[y] = st.nextToken(); } //end for ordinalIndex = enumTags[enumTags.length - 1].indexOf('=') + 1; highOrdinal = Integer.parseInt(enumTags[enumTags.length - 1] .substring(ordinalIndex)); enumOrdinals = new int[enumTags.length]; enumNames = new String[enumTags.length]; ordinalList = new int[enumTags.length]; for (int z = 0; z <= highOrdinal; ++z){ ordinalList[enumTagIndex] = Integer.parseInt(enumTags[enumTagIndex] .substring(enumTags[enumTagIndex].indexOf('=') + 1)); if (z == ordinalList[enumTagIndex]){ enumOrdinals[enumTagIndex] = ordinalList[enumTagIndex]; enumNames[enumTagIndex] = enumTags[enumTagIndex] .substring(0, enumTags[enumTagIndex] .indexOf('=')); enumTagIndex += 1; } } BEnumRange ber = BEnumRange.make(enumOrdinals, enumNames); enumNumber = (int)getIndexIn().getValue(); enumString = ""; enumStringParse = getEnumStringIn().getValue().toString(); if (enumStringParse.length() > 0) { StringTokenizer stp = new StringTokenizer(enumStringParse, " "); if (stp.hasMoreTokens()) { enumString = stp.nextToken(); for (int ps = 0; stp.hasMoreTokens(); ++ps) { enumString = enumString.concat("$20" + stp.nextToken()); } } else { enumString = enumStringParse; } } if (ber.isOrdinal(enumNumber)){ setEnumStringOut(new BStatusString(ber.get(enumNumber).toString())); } else { if (property == indexIn) { setEnumStringOut(new BStatusString( Integer.toString(enumNumber) + " is Undefined")); getEnumStringOut().setStatus(BStatus.FAULT); } else { setEnumStringOut(new BStatusString("")); } } if (ber.isTag(enumString)) { setEnumNumberOut(new BStatusNumeric(ber.get(enumString).getOrdinal())); } else { if (property == enumStringIn) { setEnumNumberOut(new BStatusNumeric(0)); getEnumNumberOut().setStatus(BStatus.FAULT); } else { setEnumNumberOut(new BStatusNumeric(0)); } } } else { setEnumStringOut(new BStatusString("Master Facet Table Error")); getEnumStringOut().setStatus(BStatus.FAULT); } } } } else { setEnumStringOut(new BStatusString("Master Link Error")); getEnumStringOut().setStatus(BStatus.FAULT); } } catch (Exception ex){ System.out.println(BAbsTime.now().toString() + ": Kors Component Error at " + this.getSlotPath().toString() + ":" + ex.toString()); } } } public static final Property enumMasterIn = newProperty(Flags.SUMMARY, new BStatusEnum()); public static final Property indexIn = newProperty(Flags.SUMMARY, new BStatusNumeric(0)); public static final Property enumStringIn = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property masterEnumName = newProperty(Flags.SUMMARY, ""); public static final Property masterEnumAddress = newProperty(Flags.SUMMARY, ""); public static final Property masterEnumFacetList = newProperty(0, ""); public static final Property enumStringOut = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property enumNumberOut = newProperty(Flags.SUMMARY, new BStatusNumeric(0)); public BStatusEnum getEnumMasterIn() { return (BStatusEnum)get(enumMasterIn); } public BStatusNumeric getIndexIn() { return (BStatusNumeric)get(indexIn); } public BStatusString getEnumStringIn() { return (BStatusString)get(enumStringIn); } public String getMasterEnumName() { return getString(masterEnumName); } public String getMasterEnumAddress() { return getString(masterEnumAddress); } public String getMasterEnumFacetList() { return getString(masterEnumFacetList); } public BStatusString getEnumStringOut() { return (BStatusString)get(enumStringOut); } public BStatusNumeric getEnumNumberOut() { return (BStatusNumeric)get(enumNumberOut); } public void setEnumMasterIn(BStatusEnum v) { set(enumMasterIn, v); } public void setIndexIn(BStatusNumeric v) { set(indexIn, v); } public void setEnumStringIn(BStatusString v) { set(enumStringIn, v); } public void setMasterEnumName(String v) { setString(masterEnumName, v); } public void setMasterEnumAddress(String v) { setString(masterEnumAddress, v); } public void setMasterEnumFacetList(String v) { setString(masterEnumFacetList, v); } public void setEnumStringOut(BStatusString v) { set(enumStringOut, v); } public void setEnumNumberOut(BStatusNumeric v) { set(enumNumberOut, v); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BIndirectEnum.class); public Type getType() { return TYPE; } } Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com/korsengineering/niagara/BQL/BIndirectTag.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 9650 Text-content-md5: c303821bdc97b2df645cf8b47ef89e79 Text-content-sha1: d1f58c8245f60a236f5641e926093d9c0d6d64d9 Content-length: 9660 PROPS-END package com.korsengineering.niagara.BQL; import java.io.IOException; import java.util.*; import javax.baja.status.*; import javax.baja.sys.*; import javax.baja.control.*; import javax.baja.bql.*; import javax.baja.naming.*; import javax.baja.collection.*; import javax.baja.util.*; public class BIndirectTag extends BComponent { public BLink[] linked; public static String [] slotNames; public static int oldSlotNumber = 0; public static boolean runOnce = false; public static final int MINSLOTS = 0; public static final int MAXSLOTS = 31; public void started(){ if (runOnce == false) { slotNames = new String[MAXSLOTS]; for (int x = 0; x < slotNames.length; ++x) { if ( x < 10) { slotNames[x] = "Slot0" + Integer.toString(x); } else { slotNames[x] = "Slot" + Integer.toString(x); } } runOnce = true; } } public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } if (property == numberOfSlots){ int numberInput = (int)getNumberOfSlots().getValue(); if (numberInput >= MINSLOTS && numberInput oldSlotNumber) { for (int x = 0; x < numberInput; ++x){ if (this.getSlot(slotNames[x])==null){ this.add(slotNames[x], new BStatusString(), Flags.SUMMARY); } } oldSlotNumber = numberInput; } if (numberInput < oldSlotNumber) { for (int x = oldSlotNumber; x > numberInput - 1; --x) { if (this.getSlot(slotNames[x])!=null) { this.remove(slotNames[x]); } } oldSlotNumber = numberInput; } } } if (property == rootIndex) { try{ if (this.getLinks(this.getSlot("rootOrdLink")).length > 0) { linked = new BLink[this.getLinks(this.getSlot("rootOrdLink")).length]; linked = this.getLinks(this.getSlot("rootOrdLink")); for (int x = 0; x < linked.length; ++x) { BComponent bCom = new BComponent(); bCom = linked[x].getSourceComponent(); int ordEnd = bCom.getNavOrd().toString().indexOf(bCom.getName()); String ordStr = bCom.getNavOrd().toString().substring(7, ordEnd - 1); for (int y = 0; y < slotNames.length; ++y) { String compName = slotNames[y]; String ordPath = ordStr + getRootFolder().getValue() + getRootIndex().getValue(); setRootOrdPath(new BStatusString(ordPath)); BOrd ord = BOrd.make(ordPath + "|bql:select from control:ControlPoint where displayName = '" + compName + "'"); BICollection result = (BICollection)ord.resolve().get(); Cursor c = result.cursor(); while (c.next()) { BControlPoint point = (BControlPoint)c.get(); point.lease(); } c = result.cursor(); String value = ""; int count = 0; Object lock = new Object(); while (c.next()) { BControlPoint point = (BControlPoint)c.get(); synchronized (lock) { while (point.getStatus().isStale() && count < 20) { try { lock.wait(100); } catch (Exception ex) { ex.printStackTrace(); } count++; } } BStatusValue out = point.getOutStatusValue(); if (out instanceof BStatusString) { value = ((BStatusString) out).getValue(); this.set(this.getProperty(slotNames[y]), new BStatusString(value)); } else if (out instanceof BStatusBoolean) { value = (((BStatusBoolean) out).getValue() ? "true" : "false"); this.set(this.getProperty(slotNames[y]), new BStatusString(value)); } else if (out instanceof BStatusNumeric) { value = Double.toString(((BStatusNumeric) out).getValue()); //String units = point.getFacets().gets(BFacets.UNITS, ""); //if (!units.equals("null")) { // value += units; //} this.set(this.getProperty(slotNames[y]), new BStatusString(value)); } else if (out instanceof BStatusEnum) { value = ((BEnumRange) point.getFacets().get(BFacets.RANGE)) .getTag(((BStatusEnum) out).getEnum().getOrdinal()); this.set(this.getProperty(slotNames[y]), new BStatusString(value)); } else { System.out.println("Unknown out type: " + out.getClass().getName()); value = "No Such Point"; } } } } } } catch(Exception ex){ //ex.printStackTrace(); } } } public void doUpdateSlotName() { int numberInput = (int)getRenameSlotNumber().getValue(); String slotNameInput = getNewSlotName().getValue(); this.rename(this.getProperty(slotNames[numberInput]), slotNameInput); slotNames[numberInput] = slotNameInput; } public static final Action updateSlotName = newAction(0); public static final Property numberOfSlots = newProperty(Flags.SUMMARY, new BStatusNumeric(0)); public static final Property renameSlotNumber = newProperty(Flags.SUMMARY, new BStatusNumeric(0)); public static final Property newSlotName = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property rootOrdLink = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property rootOrdPath = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property rootFolder = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property rootIndex = newProperty(Flags.SUMMARY, new BStatusString()); public BStatusNumeric getNumberOfSlots() { return (BStatusNumeric)get(numberOfSlots); } public BStatusNumeric getRenameSlotNumber() { return (BStatusNumeric)get(renameSlotNumber); } public BStatusString getNewSlotName() { return (BStatusString)get(newSlotName); } public BStatusString getRootOrdLink() { return (BStatusString)get(rootOrdLink); } public BStatusString getRootOrdPath() { return (BStatusString)get(rootOrdPath); } public BStatusString getRootFolder() { return (BStatusString)get(rootFolder); } public BStatusString getRootIndex() { return (BStatusString)get(rootIndex); } public void setNumberOfSlots(BStatusNumeric v) { set(numberOfSlots, v); } public void setRenameSlotNumber(BStatusNumeric v) { set(renameSlotNumber, v); } public void setNewSlotName(BStatusString v) { set(newSlotName, v); } public void setRootOrdLink(BStatusString v) { set(rootOrdLink, v); } public void setRootOrdPath(BStatusString v) { set(rootOrdPath, v); } public void setRootFolder(BStatusString v) { set(rootFolder, v); } public void setRootIndex(BStatusString v) { set(rootIndex, v); } public void updateSlotName() { invoke(updateSlotName, null, null); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BIndirectTag.class); public Type getType() { return TYPE; } } Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com/korsengineering/niagara/XML Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com/korsengineering/niagara/XML/BXMLTextFormatter.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 4333 Text-content-md5: 68108180f61f3ab687b95531ff1c770c Text-content-sha1: 562f4857f82f7e3b13c83e5ccd2a1134f0973c17 Content-length: 4343 PROPS-END package com.korsengineering.niagara.XML; import javax.baja.status.*; import javax.baja.sys.*; import javax.baja.control.*; import javax.baja.xml.*; public class BXMLTextFormatter extends BComponent{ public String strIn, strCON, strOut; public int depthCount; public boolean tagStart, tagText; public XParser pointer; public void changed(Property property, Context context){ super.changed(property, context); if (property == xmlIn){ strCON = ""; depthCount = 0; tagStart = tagText = false; strIn = getXmlIn().getValue(); try { pointer = XParser.make(strIn); } catch (Exception ex) { ex.printStackTrace(); } try { if (pointer.next() != XParser.EOF) { conStr(pointer.elem().toString(), 0); depthCount = pointer.depth(); } while (pointer.next() != XParser.EOF){ if (pointer.depth() > depthCount) { tagStart = true; doStartTag(true); } if (pointer.depth() < depthCount) { tagStart = tagText = false; doEndTag(true); } if (pointer.depth() == depthCount) { if (!tagStart) { doStartTag(false); tagStart = true; } else { if (!tagText) { doText(); tagText = true; } else { doEndTag(false); tagStart = tagText = false; } } } depthCount = pointer.depth(); } } catch (Exception ex) { System.out.println(BAbsTime.now().toString() + ": Kors Component Error at " + this.getSlotPath().toString() + ":" + ex.toString()); ex.printStackTrace(); } setTextOut(strCON); setXmlOut(new BStatusString(strCON)); } } public void doStartTag(boolean doReturn) { if (doReturn) doReturn(); conStr("<" + pointer.elem().name() + ">", pointer.depth()); } public void doText() { conStr("" + pointer.text(), 0); } public void doEndTag(boolean space) { if (space) { conStr("", pointer.depth()); } else { conStr("", 0); } doReturn(); } public void conStr(String strAdd, int spaceCount){ String Space = ""; if (spaceCount > 0){ for (int x = 1; x < spaceCount; ++x){ Space = Space.concat(" "); } strCON = strCON.concat(Space); } strCON = strCON.concat(strAdd); } public void doReturn(){ strCON = strCON.concat("\r"); } public static final Property xmlIn = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property xmlOut = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property textOut = newProperty(Flags.SUMMARY, ""); public BStatusString getXmlIn() { return (BStatusString)get(xmlIn); } public BStatusString getXmlOut() { return (BStatusString)get(xmlOut); } public String getTextOut() { return getString(textOut); } public void setXmlIn(BStatusString v) { set(xmlIn, v); } public void setXmlOut(BStatusString v) { set(xmlOut, v); } public void setTextOut(String v) { setString(textOut, v); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BXMLTextFormatter.class); public Type getType() { return TYPE; } } Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com/korsengineering/niagara/conversion Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com/korsengineering/niagara/conversion/BAbsTimeToDateParts.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 5528 Text-content-md5: e93dbf53ff031609b0f639f737087904 Text-content-sha1: deeddf4755f534bca61a73501aaf526922b792e0 Content-length: 5538 PROPS-END /** * */ package com.korsengineering.niagara.conversion; import javax.baja.status.*; import javax.baja.sys.*; import javax.baja.control.*; import javax.baja.units.*; /** * @author ARNOTTM * */ public class BAbsTimeToDateParts extends BComponent { public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } if (property == timeIn){ setSecondsOut(new BStatusNumeric(getTimeIn().getSecond())); setHoursOut(new BStatusNumeric(getTimeIn().getHour())); setDayOut(new BStatusNumeric(getTimeIn().getDay())); setMonthOut(new BStatusNumeric(getTimeIn().getMonth().getMonthOfYear())); setYearOut(new BStatusNumeric(getTimeIn().getYear())); BMonth myMonth = getTimeIn().getMonth(); String stMonth = new String(myMonth.toString()); setLongMonthOut(new BStatusString(stMonth)); setShortMonthOut(new BStatusString(stMonth.substring(0,3))); BWeekday myDay = getTimeIn().getWeekday(); setLongDayOut(new BStatusString(myDay.toString())); String stDay = myDay.toString().substring(0,3); setShortDayOut(new BStatusString(stDay)); } } /**Relative Time Input*/ public final static Property timeIn = newProperty(Flags.SUMMARY, BAbsTime.DEFAULT); public void setTimeIn(BAbsTime v) { set(timeIn, v); } public BAbsTime getTimeIn() { return (BAbsTime)get(timeIn); } public static BUnit mySecs = BUnit.getUnit("second"); public static BUnit myMins = BUnit.getUnit("minute"); public static BUnit myHours = BUnit.getUnit("hour"); /**StatusNumeric value out representing time in seconds*/ public final static Property secondsOut = newProperty(Flags.SUMMARY,new BStatusNumeric(),BFacets.makeNumeric(mySecs,0)); public BStatusNumeric getSecondsOut() { return (BStatusNumeric)get(secondsOut); } public void setSecondsOut(BStatusNumeric v) { set(secondsOut, v); } /**StatusNumeric value out representing time in minutes*/ public final static Property minutesOut = newProperty(Flags.SUMMARY,new BStatusNumeric(),BFacets.makeNumeric(myMins,0)); public BStatusNumeric getMinutesOut() { return (BStatusNumeric)get(minutesOut); } public void setMinutesOut(BStatusNumeric v) { set(minutesOut, v); } /**StatusNumeric value out representing time in hours*/ public final static Property hoursOut = newProperty(Flags.SUMMARY,new BStatusNumeric(),BFacets.makeNumeric(myHours,0)); public BStatusNumeric getHoursOut() { return (BStatusNumeric)get(hoursOut); } public void setHoursOut(BStatusNumeric v) { set(hoursOut, v); } /**StatusNumeric value out representing time in day of month*/ public final static Property dayOut = newProperty(Flags.SUMMARY,new BStatusNumeric(),BFacets.makeNumeric(0)); public BStatusNumeric getDayOut() { return (BStatusNumeric)get(dayOut); } public void setDayOut(BStatusNumeric v) { set(dayOut, v); } /**StatusNumeric value out representing time in month*/ public final static Property monthOut = newProperty(Flags.SUMMARY,new BStatusNumeric(),BFacets.makeNumeric(0)); public BStatusNumeric getMonthOut() { return (BStatusNumeric)get(monthOut); } public void setMonthOut(BStatusNumeric v) { set(monthOut, v); } /**StatusNumeric value out representing time in years*/ public final static Property yearOut = newProperty(Flags.SUMMARY,new BStatusNumeric(),BFacets.makeNumeric(0)); public BStatusNumeric getYearOut() { return (BStatusNumeric)get(yearOut); } public void setYearOut(BStatusNumeric v) { set(yearOut, v); } /**StatusString value out representing time in short month*/ public final static Property shortMonthOut = newProperty(Flags.SUMMARY,new BStatusString()); public BStatusString getShortMonthOut() { return (BStatusString)get(shortMonthOut); } public void setShortMonthOut(BStatusString v) { set(shortMonthOut, v); } /**StatusString value out representing time in long month*/ public final static Property longMonthOut = newProperty(Flags.SUMMARY,new BStatusString()); public BStatusString getLongMonthOut() { return (BStatusString)get(longMonthOut); } public void setLongMonthOut(BStatusString v) { set(longMonthOut, v); } /**StatusString value out representing time in short day*/ public final static Property shortDayOut = newProperty(Flags.SUMMARY,new BStatusString()); public BStatusString getShortDayOut() { return (BStatusString)get(shortDayOut); } public void setShortDayOut(BStatusString v) { set(shortDayOut, v); } /**StatusString value out representing time in long Day*/ public final static Property longDayOut = newProperty(Flags.SUMMARY,new BStatusString()); public BStatusString getLongDayOut() { return (BStatusString)get(longDayOut); } public void setLongDayOut(BStatusString v) { set(longDayOut, v); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BAbsTimeToDateParts.class); public Type getType() { return TYPE; } } Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com/korsengineering/niagara/conversion/BStatusEnumToStatusString.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 1560 Text-content-md5: 90be6995ae528eb3b19cfc70490836ad Text-content-sha1: 2f8c575e0bb6575cfafcfdfe4ed069c59bf39a03 Content-length: 1570 PROPS-END package com.korsengineering.niagara.conversion; import javax.baja.status.*; import javax.baja.sys.*; import javax.baja.control.*; /**Converts a StatusEnum input to a Status String */ public class BStatusEnumToStatusString extends BComponent{ public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } if (property == enumIn) { BStatusString tmp = new BStatusString(); tmp.setValue(getEnumIn().getEnum().getTag()); setStringOut(tmp); } } //Property Declarations, Gets, and Sets //Enum Input public static final Property enumIn = newProperty(Flags.SUMMARY, new BStatusEnum()); /**String Output*/ public static final Property stringOut = newProperty(Flags.SUMMARY, new BStatusString()); //Get methods public BStatusEnum getEnumIn() { return (BStatusEnum)get(enumIn); } public BStatusString getStringOut() { return (BStatusString)get(stringOut);} //Set Methods public void setEnumIn(BStatusEnum v) { set(enumIn, v); } public void setStringOut(BStatusString v) {set(stringOut,v);} public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BStatusEnumToStatusString.class); public Type getType() { return TYPE; } } Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com/korsengineering/niagara/conversion/BStatusNumericToRelTime.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 1575 Text-content-md5: cf268a53968e1086d3ca183f67bba561 Text-content-sha1: cb3eac6975157b0c9786d4c9d8077ce6b753f57c Content-length: 1585 PROPS-END package com.korsengineering.niagara.conversion; import javax.baja.status.*; import javax.baja.sys.*; import javax.baja.control.*; /**Converts a StatusNumeric input of time in seconds to a relative time output*/ public class BStatusNumericToRelTime extends BComponent{ public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } if (property == secondsIn){ int secs = (int)getSecondsIn().getValue(); BRelTime inTime = BRelTime.makeSeconds(secs); setTimeOut(inTime.abs()); } } /**StatusNumeric value in representing total time in seconds*/ public final static Property secondsIn = newProperty(Flags.SUMMARY,new BStatusNumeric()); /**Relative Time Out*/ public final static Property timeOut = newProperty(Flags.SUMMARY, BRelTime.DEFAULT); public BStatusNumeric getSecondsIn() { return (BStatusNumeric)get(secondsIn); } public BRelTime getTimeOut() { return (BRelTime)get(timeOut); } public void setSecondsIn(BStatusNumeric v) { set(secondsIn, v); } public void setTimeOut(BRelTime v) { set(timeOut, v); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BStatusNumericToRelTime.class); public Type getType() { return TYPE; } } Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com/korsengineering/niagara/conversion/BStatusNumericToStatusBoolean.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 7948 Text-content-md5: b88a574a904ceb5c9f34a67b8350bdde Text-content-sha1: 3de52af118c79fbf32a8ba6ef4c602a5a4a4b71d Content-length: 7958 PROPS-END package com.korsengineering.niagara.conversion; import javax.baja.status.*; import javax.baja.sys.*; import javax.baja.control.*; /**Converts a StatusNumeric input to a 16 bit word represented *by 16 StatusBoolean outputs*/ public class BStatusNumericToStatusBoolean extends BComponent{ public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } String binStr = ""; double getNum; int castNum; if (property == numberIn) { //Convert decimal to binary getNum = getNumberIn().getValue(); if (getNum <= 65535 && getNum >= 0) { castNum = (int)getNum; binStr = toBinaryString(castNum); } setStringBinary(new BStatusString(binStr)); setBinaryOut00(new BStatusBoolean((binStr.charAt(15) == '1'))); setBinaryOut01(new BStatusBoolean((binStr.charAt(14) == '1'))); setBinaryOut02(new BStatusBoolean((binStr.charAt(13) == '1'))); setBinaryOut03(new BStatusBoolean((binStr.charAt(12) == '1'))); setBinaryOut04(new BStatusBoolean((binStr.charAt(11) == '1'))); setBinaryOut05(new BStatusBoolean((binStr.charAt(10) == '1'))); setBinaryOut06(new BStatusBoolean((binStr.charAt(9) == '1'))); setBinaryOut07(new BStatusBoolean((binStr.charAt(8) == '1'))); setBinaryOut08(new BStatusBoolean((binStr.charAt(7) == '1'))); setBinaryOut09(new BStatusBoolean((binStr.charAt(6) == '1'))); setBinaryOut10(new BStatusBoolean((binStr.charAt(5) == '1'))); setBinaryOut11(new BStatusBoolean((binStr.charAt(4) == '1'))); setBinaryOut12(new BStatusBoolean((binStr.charAt(3) == '1'))); setBinaryOut13(new BStatusBoolean((binStr.charAt(2) == '1'))); setBinaryOut14(new BStatusBoolean((binStr.charAt(1) == '1'))); setBinaryOut15(new BStatusBoolean((binStr.charAt(0) == '1'))); } } //Property Declarations, Gets, and Sets //Integer Input public static final Property numberIn = newProperty(Flags.SUMMARY, new BStatusNumeric()); /**Binary Outputs*/ public static final Property binaryOut00 = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public static final Property binaryOut01 = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public static final Property binaryOut02 = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public static final Property binaryOut03 = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public static final Property binaryOut04 = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public static final Property binaryOut05 = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public static final Property binaryOut06 = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public static final Property binaryOut07 = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public static final Property binaryOut08 = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public static final Property binaryOut09 = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public static final Property binaryOut10 = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public static final Property binaryOut11 = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public static final Property binaryOut12 = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public static final Property binaryOut13 = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public static final Property binaryOut14 = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public static final Property binaryOut15 = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); /**String Output*/ public static final Property stringBinary = newProperty(Flags.SUMMARY, new BStatusString()); //Get methods public BStatusNumeric getNumberIn() { return (BStatusNumeric)get(numberIn); } public BStatusBoolean getBinaryOut00() { return (BStatusBoolean)get(binaryOut00); } public BStatusBoolean getBinaryOut01() { return (BStatusBoolean)get(binaryOut01); } public BStatusBoolean getBinaryOut02() { return (BStatusBoolean)get(binaryOut02); } public BStatusBoolean getBinaryOut03() { return (BStatusBoolean)get(binaryOut03); } public BStatusBoolean getBinaryOut04() { return (BStatusBoolean)get(binaryOut04); } public BStatusBoolean getBinaryOut05() { return (BStatusBoolean)get(binaryOut05); } public BStatusBoolean getBinaryOut06() { return (BStatusBoolean)get(binaryOut06); } public BStatusBoolean getBinaryOut07() { return (BStatusBoolean)get(binaryOut07); } public BStatusBoolean getBinaryOut08() { return (BStatusBoolean)get(binaryOut08); } public BStatusBoolean getBinaryOut09() { return (BStatusBoolean)get(binaryOut09); } public BStatusBoolean getBinaryOut10() { return (BStatusBoolean)get(binaryOut10); } public BStatusBoolean getBinaryOut11() { return (BStatusBoolean)get(binaryOut11); } public BStatusBoolean getBinaryOut12() { return (BStatusBoolean)get(binaryOut12); } public BStatusBoolean getBinaryOut13() { return (BStatusBoolean)get(binaryOut13); } public BStatusBoolean getBinaryOut14() { return (BStatusBoolean)get(binaryOut14); } public BStatusBoolean getBinaryOut15() { return (BStatusBoolean)get(binaryOut15); } public BStatusString getStringBinary() { return (BStatusString)get(stringBinary); } //Set Methods public void setNumberIn(BStatusNumeric v) { set(numberIn, v); } public void setBinaryOut00(BStatusBoolean v) { set(binaryOut00, v); } public void setBinaryOut01(BStatusBoolean v) { set(binaryOut01, v); } public void setBinaryOut02(BStatusBoolean v) { set(binaryOut02, v); } public void setBinaryOut03(BStatusBoolean v) { set(binaryOut03, v); } public void setBinaryOut04(BStatusBoolean v) { set(binaryOut04, v); } public void setBinaryOut05(BStatusBoolean v) { set(binaryOut05, v); } public void setBinaryOut06(BStatusBoolean v) { set(binaryOut06, v); } public void setBinaryOut07(BStatusBoolean v) { set(binaryOut07, v); } public void setBinaryOut08(BStatusBoolean v) { set(binaryOut08, v); } public void setBinaryOut09(BStatusBoolean v) { set(binaryOut09, v); } public void setBinaryOut10(BStatusBoolean v) { set(binaryOut10, v); } public void setBinaryOut11(BStatusBoolean v) { set(binaryOut11, v); } public void setBinaryOut12(BStatusBoolean v) { set(binaryOut12, v); } public void setBinaryOut13(BStatusBoolean v) { set(binaryOut13, v); } public void setBinaryOut14(BStatusBoolean v) { set(binaryOut14, v); } public void setBinaryOut15(BStatusBoolean v) { set(binaryOut15, v); } public void setStringBinary(BStatusString v) { set(stringBinary, v); } /**Converts binary value to a string representation of the bit word*/ public String toBinaryString(int numberIn) { String binStr = Integer.toBinaryString(numberIn); if (binStr.length() < 16) { //pad to 16 characters int charsToPad = 16 - binStr.length(); char [] buf = new char[charsToPad]; for (int i = 0; i < charsToPad; i++) { buf[i] = '0'; } binStr = new String(buf) + binStr; } return binStr; } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BStatusNumericToStatusBoolean.class); public Type getType() { return TYPE; } } Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com/korsengineering/niagara/energy Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com/korsengineering/niagara/energy/BScoreCard.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 7711 Text-content-md5: 0e0266f3cdc5384b7f8504645e385854 Text-content-sha1: 15db9891cbcaf72b877ba868916d3b4c6fec387d Content-length: 7721 PROPS-END package com.korsengineering.niagara.energy; import java.util.Timer; import java.util.TimerTask; import javax.baja.status.*; import javax.baja.sys.*; import javax.baja.control.*; import javax.baja.bql.*; import javax.baja.naming.*; import javax.baja.collection.*; import javax.baja.util.*; import com.korsengineering.niagara.list.BDynamicList; public class BScoreCard extends BComponent { public int delay, period, presetTemp, remain; private double minDemand = 0.0; private double maxDemand = 0.0; private boolean bitInMinRange = false; private boolean bitInMaxRange = false; public void started(){ //build timer delay = 0; period = 60000; final Timer timer = new Timer(); timer.scheduleAtFixedRate(new TimerTask() { public void run() { //check to see if current dtime in accepted range BAbsTime getTime = BAbsTime.now(); BTimeRange tMinRange = getInMinimumDemandTimeWindow(); BDaysOfWeekBits bMinDays = getInMinimumDemandTimeDay(); //update the minimum demand if in window if( bMinDays.includes(getTime)) {//today is included, now check time window if(tMinRange.includes(getTime)) {//now is included, check to see if current value is less than stored value if(!bitInMinRange) {//this is the first time in range, so automatically use the current value minDemand =getInNumeric().getNumeric(); bitInMinRange = true; } else {//not the first, so check for 0, < double tmp = getInNumeric().getNumeric(); if((minDemand > tmp) || (minDemand == 0)) {//get status of in numeric BStatus inStatus = getInNumeric().getStatus(); if(inStatus.isOk()) { //ok to update value minDemand = tmp; } } } //set output to min value setOutMin(new BStatusNumeric(minDemand)); } else {//now not included, if bit is true, set to false bitInMinRange = false; } } else {//now not included, if bit is true, set to false bitInMinRange = false; } //now check to see if max time is in range BTimeRange tMaxRange = getInMaximumDemandTimeWindow(); BDaysOfWeekBits bMaxDays = getInMaximumDemandTimeDay(); if( bMaxDays.includes(getTime)) {//today is included, now check time window if(tMaxRange.includes(getTime)) {//now is included, check to see if current value is less than stored value BStatus inStatus = getInNumeric().getStatus(); if(!bitInMaxRange) {//this is the first time in range, so automatically use the current value if(inStatus.isOk()) { //ok to update value maxDemand = getInNumeric().getNumeric(); } else { maxDemand = 0; } bitInMaxRange = true; } else {//not the first, so check for 0, > double tmp = getInNumeric().getNumeric(); if((maxDemand < tmp) || (maxDemand == 0)) {//get status of in numeric if(inStatus.isOk()) { //ok to update value maxDemand = tmp; } } } //set output to max value setOutMax(new BStatusNumeric(maxDemand)); } else {//now not included, if bit is true, set to false if(bitInMaxRange) {//is just out of max range, calculate and set score if((minDemand>0)&&(maxDemand>0)) { setOutScore(new BStatusNumeric(minDemand / maxDemand * 100)); } else { setOutScore(new BStatusNumeric(100)); } } bitInMaxRange = false; } } else {//now not included, if bit is true, set to false if(bitInMaxRange) {//is just out of max range, calculate and set score if((minDemand>0)&&(maxDemand>0)) { setOutScore(new BStatusNumeric(minDemand / maxDemand * 100)); } else { setOutScore(new BStatusNumeric(100)); } } bitInMaxRange = false; } } }, delay, period); } public static final Property inNumeric = newProperty(Flags.SUMMARY, new BStatusNumeric()); public BStatusNumeric getInNumeric() { return (BStatusNumeric)get(inNumeric); } public void setInNumeric(BStatusNumeric v) { set(inNumeric, v); } public static final Property outScore = newProperty(Flags.SUMMARY, new BStatusNumeric(), BFacets.makeNumeric(2)); public BStatusNumeric getOutScore() { return (BStatusNumeric)get(outScore); } public void setOutScore(BStatusNumeric v) { set(outScore, v); } public static final Property outMin = newProperty(Flags.SUMMARY, new BStatusNumeric(), BFacets.makeNumeric(2)); public BStatusNumeric getOutMin() { return (BStatusNumeric)get(outMin); } public void setOutMin(BStatusNumeric v) { set(outMin, v); } public static final Property outMax = newProperty(Flags.SUMMARY, new BStatusNumeric(), BFacets.makeNumeric(2)); public BStatusNumeric getOutMax() { return (BStatusNumeric)get(outMax); } public void setOutMax(BStatusNumeric v) { set(outMax, v); } public static final Property inMinimumDemandTimeDay = newProperty(Flags.SUMMARY, BDaysOfWeekBits.sunday); public BDaysOfWeekBits getInMinimumDemandTimeDay() { return (BDaysOfWeekBits)get("inMinimumDemandTimeDay"); } public void setInMinimumDemandTimeDay(javax.baja.util.BDaysOfWeekBits v) { set("inMinimumDemandTimeDay", v); } public static final Property inMinimumDemandTimeWindow = newProperty(Flags.SUMMARY, new BTimeRange()); public BTimeRange getInMinimumDemandTimeWindow() { return (BTimeRange)get("inMinimumDemandTimeWindow"); } public void setInMinimumDemandTimeWindow(javax.baja.util.BTimeRange v) { set("inMinimumDemandTimeWindow", v); } public static final Property inMaximumDemandTimeDay = newProperty(Flags.SUMMARY, BDaysOfWeekBits.tuesday); public BDaysOfWeekBits getInMaximumDemandTimeDay() { return (BDaysOfWeekBits)get("inMaximumDemandTimeDay"); } public void setInMaximumDemandTimeDay(javax.baja.util.BDaysOfWeekBits v) { set("inMaximumDemandTimeDay", v); } public static final Property inMaximumDemandTimeWindow = newProperty(Flags.SUMMARY, new BTimeRange()); public BTimeRange getInMaximumDemandTimeWindow() { return (BTimeRange)get("inMaximumDemandTimeWindow"); } public void setInMaximumDemandTimeWindow(javax.baja.util.BTimeRange v) { set("inMaximumDemandTimeWindow", v); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BScoreCard.class); public Type getType() { return TYPE; } } Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com/korsengineering/niagara/graphics Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com/korsengineering/niagara/graphics/korsLogo.png Node-kind: file Node-action: add Prop-content-length: 59 Text-content-length: 1472 Text-content-md5: 0b979731f91a4c0f34a6760a30ef9190 Text-content-sha1: e5780469e3e892b273104424030dea3641026d96 Content-length: 1531 K 13 svn:mime-type V 24 application/octet-stream PROPS-END PNG  IHDR_*? pHYsgRgAMA|Q cHRMz%u0`:o_FPLTEt UK,mdC|uFwGxTblnotuxu~{ʶK@MBHxJzO~TV|dhegprsqtswuwzs|{}|xƯNAB6A5B7RG%cX1tiK{kǻQA*rdP_p{¼¼9,6*At}ҿeQ,wd=pk+wb-yd\^q¹:mP}]bxfquȺŵvrVtRNSJ MIDATxbAf-bpZb`ph [bYwq= bPo,?~aaА6rfcZU@PY H*h^ߪFMhx4  H=O 7'P)@wxA.T~ '.  V d'7I +]^a-b oQY  !iDU·mIENDB` Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com/korsengineering/niagara/list Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com/korsengineering/niagara/list/BDynamicList.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 3719 Text-content-md5: 6e47f4aef350fe01b30f1e37e4275b9f Text-content-sha1: 0dbf47b9a07e79a02b6c13845dd8f03b670c8665 Content-length: 3729 PROPS-END package com.korsengineering.niagara.list; import javax.baja.status.*; import javax.baja.sys.*; import javax.baja.control.*; import javax.baja.bql.*; import javax.baja.naming.*; import javax.baja.collection.*; import javax.baja.util.*; public class BDynamicList extends BComponent{ public static String [] slotNames; public static int oldSlotNumber = 0; public static boolean runOnce = false; public static final int MINSLOTS = 0; public static final int MAXSLOTS = 31; public void started(){ if (runOnce == false) { slotNames = new String[MAXSLOTS]; for (int x = 0; x < slotNames.length; ++x) { if ( x < 10) { slotNames[x] = "Input0" + Integer.toString(x); } else { slotNames[x] = "Input" + Integer.toString(x); } } runOnce = true; } } public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } if (property == numberOfItems){ int numberInput = (int)getNumberOfItems().getValue(); if (numberInput >= MINSLOTS && numberInput oldSlotNumber) { for (int x = 0; x < numberInput; ++x){ if (this.getSlot(slotNames[x])==null){ this.add(slotNames[x], new BStatusNumeric(), Flags.SUMMARY); } } oldSlotNumber = numberInput; } if (numberInput < oldSlotNumber) { for (int x = oldSlotNumber; x > numberInput - 1; --x) { if (this.getSlot(slotNames[x])!=null) { this.remove(slotNames[x]); } } oldSlotNumber = numberInput; } } } } public void doUpdateSlotName() { int numberInput = (int)getRenameSlotNumber().getValue(); String slotNameInput = getNewSlotName().getValue(); double dd = 99; this.rename(this.getProperty(slotNames[numberInput]), slotNameInput); slotNames[numberInput] = slotNameInput; } public static final Action updateSlotName = newAction(0); public static final Property numberOfItems = newProperty(Flags.SUMMARY, new BStatusNumeric(0)); public static final Property renameSlotNumber = newProperty(Flags.SUMMARY, new BStatusNumeric(0)); public static final Property newSlotName = newProperty(Flags.SUMMARY, new BStatusString()); public BStatusNumeric getNumberOfItems() { return (BStatusNumeric)get(numberOfItems); } public BStatusNumeric getRenameSlotNumber() { return (BStatusNumeric)get(renameSlotNumber); } public BStatusString getNewSlotName() { return (BStatusString)get(newSlotName); } public void setNumberOfItems(BStatusNumeric v) { set(numberOfItems, v); } public void setRenameSlotNumber(BStatusNumeric v) { set(renameSlotNumber, v); } public void setNewSlotName(BStatusString v) { set(newSlotName, v); } public void updateSlotName() { invoke(updateSlotName, null, null); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BDynamicList.class); public Type getType() { return TYPE; } } Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com/korsengineering/niagara/list/BStatusNumericFifo.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 9004 Text-content-md5: b3e1e5a3e84cc021ee59adf8c460fb92 Text-content-sha1: 06d322f1589b829afaa91f796205dfb71ef6b30e Content-length: 9014 PROPS-END package com.korsengineering.niagara.list; import javax.baja.status.*; import javax.baja.sys.*; import javax.baja.control.*; import javax.baja.bql.*; import javax.baja.naming.*; import javax.baja.collection.*; import javax.baja.units.BUnit; import javax.baja.util.*; public class BStatusNumericFifo extends BComponent { boolean fire = false; static String [] slotNames; final int MAXSLOTS = 33; BLink [] linked; BUnit degrees; BFacets bfc; static final String INPUT = "Input", MAX = "Max$20Value", MIN = "Min$20Value", AVG = "Average"; static BStatusNumeric bsn; public void started(){ try{ slotNames = new String[MAXSLOTS]; setNames(); if (!getSlot(INPUT).isProperty()){ //Slot Does not Exist add(INPUT, new BStatusNumeric(0), Flags.SUMMARY); add(MAX, new BStatusNumeric(0), Flags.SUMMARY); add(MIN, new BStatusNumeric(0), Flags.SUMMARY); add(AVG, new BStatusNumeric(0), Flags.SUMMARY); addSlots(); } } catch(NullPointerException en){ add(INPUT, new BStatusNumeric(0), Flags.SUMMARY); add(MAX, new BStatusNumeric(0), Flags.SUMMARY); add(MIN, new BStatusNumeric(0), Flags.SUMMARY); add(AVG, new BStatusNumeric(0), Flags.SUMMARY); addSlots(); } catch(Exception ex){ System.out.println(BAbsTime.now().toString() + ": Kors Component Error at " + this.getSlotPath().toString() + ":" + ex.toString()); } } private void setNames(){ for (int x = 0; x < slotNames.length; ++x) { if ( x < 10) { slotNames[x] = "Output$200" + Integer.toString(x); } else { slotNames[x] = "Output$20" + Integer.toString(x); } } } private void addSlots(){ for (int x = 0; x < slotNames.length; ++x) { if(slotNames[x]==null){ setNames(); } if ( x < 10) { add(slotNames[x], new BStatusNumeric(0)); } else { add(slotNames[x], new BStatusNumeric(0)); } } } public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } for (int x = 0; x < slotNames.length; ++x) { if(slotNames[x]==null){ setNames(); } } if (property == trigger && getTrigger().getValue() && fire == false){ //linked = new BLink[getLinks(getSlot("input")).length]; //linked = getLinks(getSlot("input")); try{ linked = new BLink[getLinks(getSlot(INPUT)).length]; linked = getLinks(getSlot(INPUT)); for (int x = 0; x < linked.length; ++x) { BComponent bCom = new BComponent(); bCom = linked[x].getSourceComponent(); int ordEnd = bCom.getNavOrd().toString().indexOf(bCom.getName()); String ordStr = bCom.getNavOrd().toString().substring(7, ordEnd - 1); BOrd ord = BOrd.make(ordStr + "|bql:select from control:ControlPoint where displayName = '" + bCom.getName() + "'"); BICollection result = (BICollection)ord.resolve().get(); Cursor c = result.cursor(); while (c.next()) { BControlPoint point = (BControlPoint)c.get(); BStatusValue out = point.getOutStatusValue(); if (out instanceof BStatusString) { ((BStatusNumeric)get(getProperty(INPUT))).setStatus(BStatus.fault); } if (out instanceof BStatusBoolean) { ((BStatusNumeric)get(getProperty(INPUT))).setStatus(BStatus.fault); } if (out instanceof BStatusEnum) { ((BStatusNumeric)get(getProperty(INPUT))).setStatus(BStatus.fault); } if (out instanceof BStatusNumeric) { double value = ((BStatusNumeric)out).getValue(); BFacets bfc = point.getFacets(); System.out.println(bfc == null); if(bfc == null){ shiftData(value); minData(); maxData(); avgData(); } else{ shiftData(value, bfc); minData(bfc); maxData(bfc); avgData(bfc); } } } } } catch(Exception e){ System.out.println(BAbsTime.now().toString() + ": Kors Component Error at " + this.getSlotPath().toString() + ":" + e.toString()); } finally{ fire = true; } } else { fire = false; } } private void shiftData(double value, BFacets bfc){ double tempVal; for (int x = slotNames.length - 2; x >= 0; --x){ tempVal = ((BStatusNumeric)get(getProperty(slotNames[x]))).getValue(); set(getProperty(slotNames[x + 1]), new BStatusNumeric(tempVal)); setFacets(getSlot(slotNames[x + 1]), bfc); } set(getProperty(slotNames[0]), new BStatusNumeric(value)); setFacets(getSlot(INPUT), bfc); setFacets(getSlot(slotNames[0]), bfc); } private void shiftData(double value){ double tempVal; for (int x = slotNames.length - 2; x >= 0; --x){ tempVal = ((BStatusNumeric)get(getProperty(slotNames[x]))).getValue(); set(getProperty(slotNames[x + 1]), new BStatusNumeric(tempVal)); } set(getProperty(slotNames[0]), new BStatusNumeric(value)); } private void minData(BFacets bfc){ double tempVal, minVal; tempVal = minVal = 0; for (int x = 0; x < slotNames.length; ++x){ tempVal = ((BStatusNumeric)get(getProperty(slotNames[x]))).getValue(); if (minVal == 0){ minVal = tempVal; } else { if (tempVal > 0 && tempVal < minVal){ minVal = tempVal; } } } set(getProperty(MIN), new BStatusNumeric(minVal)); setFacets(getSlot(MIN), bfc); } private void minData(){ double tempVal, minVal; tempVal = minVal = 0; for (int x = 0; x < slotNames.length; ++x){ tempVal = ((BStatusNumeric)get(getProperty(slotNames[x]))).getValue(); if (minVal == 0){ minVal = tempVal; } else { if (tempVal > 0 && tempVal < minVal){ minVal = tempVal; } } } set(getProperty(MIN), new BStatusNumeric(minVal)); } private void maxData(BFacets bfc){ double tempVal, maxVal; tempVal = maxVal = 0; for (int x = 0; x < slotNames.length; ++x){ tempVal = ((BStatusNumeric)get(getProperty(slotNames[x]))).getValue(); if (maxVal == 0){ maxVal = tempVal; } else { if (tempVal > 0 && tempVal > maxVal){ maxVal = tempVal; } } } set(getProperty(MAX), new BStatusNumeric(maxVal)); setFacets(getSlot(MAX), bfc); } private void maxData(){ double tempVal, maxVal; tempVal = maxVal = 0; for (int x = 0; x < slotNames.length; ++x){ tempVal = ((BStatusNumeric)get(getProperty(slotNames[x]))).getValue(); if (maxVal == 0){ maxVal = tempVal; } else { if (tempVal > 0 && tempVal > maxVal){ maxVal = tempVal; } } } set(getProperty(MAX), new BStatusNumeric(maxVal)); } private void avgData(BFacets bfc){ double tempVal, avgVal, checkVal, goodVals; tempVal = avgVal = checkVal = goodVals = 0; for (int x = 0; x < slotNames.length; ++x){ checkVal = ((BStatusNumeric)get(getProperty(slotNames[x]))).getValue(); tempVal += checkVal; if (checkVal > 0){ goodVals += 1; } } avgVal = tempVal / goodVals; set(getProperty(AVG), new BStatusNumeric(avgVal)); setFacets(getSlot(AVG), bfc); } private void avgData(){ double tempVal, avgVal, checkVal, goodVals; tempVal = avgVal = checkVal = goodVals = 0; for (int x = 0; x < slotNames.length; ++x){ checkVal = ((BStatusNumeric)get(getProperty(slotNames[x]))).getValue(); tempVal += checkVal; if (checkVal > 0){ goodVals += 1; } } avgVal = tempVal / goodVals; set(getProperty(AVG), new BStatusNumeric(avgVal)); } public static final Property trigger = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BStatusBoolean getTrigger() { return (BStatusBoolean)get(trigger); } public void setTrigger(BStatusBoolean v) { set(trigger, v); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BStatusNumericFifo.class); public Type getType() { return TYPE; } } Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com/korsengineering/niagara/logic Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com/korsengineering/niagara/logic/BFlipFlop.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 2196 Text-content-md5: f2f236d790b703b73212fdf9dad92c94 Text-content-sha1: e3b2eef6e7f81a16e6a74d22b342d72268dc5550 Content-length: 2206 PROPS-END package com.korsengineering.niagara.logic; import javax.baja.status.*; import javax.baja.sys.*; import javax.baja.control.*; public class BFlipFlop extends BComponent{ public final static Property setInput = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public final static Property resetInput = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public final static Property output = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BStatusBoolean getResetInput() { return (BStatusBoolean)get(resetInput); } public BStatusBoolean getSetInput() { return (BStatusBoolean)get(setInput); } public BStatusBoolean getOutput() { return (BStatusBoolean)get(output); } public void setSetInput(BStatusBoolean v) { set(setInput, v); } public void setResetInput(BStatusBoolean v) { set(resetInput, v); } public void setOutput(BStatusBoolean v) { set(output, v); } public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } if(property==setInput || property == resetInput){ boolean set = getSetInput().getValue(); boolean reset = getResetInput().getValue(); try{ if(set){ //check reset status, if off, set if(!reset){ //no reset flag, turn on output setOutput(new BStatusBoolean(true)); } } else{ //no set status, check reset if(reset){ //reset true, turn off output setOutput(new BStatusBoolean(false)); } } } catch(Exception e){ System.out.println(BAbsTime.now().toString() + ": Kors Component Error at " + this.getSlotPath().toString() + ":" + e.toString()); } } } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BFlipFlop.class); public Type getType() { return TYPE; } } Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com/korsengineering/niagara/logic/BTrueAnd.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 3418 Text-content-md5: 52861dadadea16a0bfc9b7b5f08d104f Text-content-sha1: 23f6be96de4d7bf27e807f4ec35415c049914064 Content-length: 3428 PROPS-END package com.korsengineering.niagara.logic; import javax.baja.status.*; import javax.baja.sys.*; import javax.baja.control.*; /**Accepts StatusBoolean True / False inputs. *NULL inputs are interpreted as False.*/ public class BTrueAnd extends BComponent{ public boolean testA, testB, testC, testD, testE, allTrue; public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } if (property == inA || property == inB || property == inC || property == inD || property == inE){ doTest(); } } /**Check the inputs for valid boolean values*/ public void doTest() { if (getInA().getStatus().isNull()) { testA = false; } else { testA = getInA().getValue(); } if (getInB().getStatus().isNull()) { testB = false; } else { testB = getInB().getValue(); } if (getInC().getStatus().isNull()) { testC = false; } else { testC = getInC().getValue(); } if (getInD().getStatus().isNull()) { testD = false; } else { testD = getInD().getValue(); } if (getInE().getStatus().isNull()) { testE = false; } else { testE = getInE().getValue(); } if (testA == true && testB == true && testC == true && testD == true && testE == true){ allTrue = true; } else { allTrue = false; } setOutput(new BStatusBoolean(allTrue)); } public final static Property output = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public final static Property inA = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public final static Property inB = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public final static Property inC = newProperty(Flags.SUMMARY, new BStatusBoolean(true)); public final static Property inD = newProperty(Flags.SUMMARY, new BStatusBoolean(true)); public final static Property inE = newProperty(Flags.SUMMARY, new BStatusBoolean(true)); public BStatusBoolean getOutput() { return (BStatusBoolean)get(output); } public BStatusBoolean getInA() { return (BStatusBoolean)get(inA); } public BStatusBoolean getInB() { return (BStatusBoolean)get(inB); } public BStatusBoolean getInC() { return (BStatusBoolean)get(inC); } public BStatusBoolean getInD() { return (BStatusBoolean)get(inD); } public BStatusBoolean getInE() { return (BStatusBoolean)get(inE); } public void setOutput(BStatusBoolean v) { set(output, v); } public void setInA(BStatusBoolean v) { set(inA, v); } public void setInB(BStatusBoolean v) { set(inB, v); } public void setInC(BStatusBoolean v) { set(inC, v); } public void setInD(BStatusBoolean v) { set(inD, v); } public void setInE(BStatusBoolean v) { set(inE, v); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BTrueAnd.class); public Type getType() { return TYPE; } } Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com/korsengineering/niagara/math Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com/korsengineering/niagara/math/BRoundUp.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 1118 Text-content-md5: fd7154a1991437143614174d63cfa2f2 Text-content-sha1: 17fae1aa4bbb142878538a370ebedb8c41c72d83 Content-length: 1128 PROPS-END package com.korsengineering.niagara.math; import javax.baja.sys.*; import javax.baja.status.*; public class BRoundUp extends BComponent{ public void started(){ try{ if (getSlot("Input").isProperty()){ //Check for slot } } catch(Exception ex){ add("Input", new BStatusNumeric(0), Flags.SUMMARY); add("Output", new BStatusNumeric(0), Flags.SUMMARY); } } public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } if (property == getProperty("Input")){ double a, b; a = ((BStatusNumeric)get(getProperty("Input"))).getValue(); b = Math.ceil(a); set(getProperty("Output"), new BStatusNumeric(b)); } } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BRoundUp.class); public Type getType() { return TYPE; } } Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com/korsengineering/niagara/timer Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com/korsengineering/niagara/timer/BStationStartTimer.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 4774 Text-content-md5: d7d210e6cc05e87b8024195368333a60 Text-content-sha1: 6765bdeae5859bccce83327f3b98d4ecc3fa2391 Content-length: 4784 PROPS-END package com.korsengineering.niagara.timer; import javax.baja.status.*; import javax.baja.sys.*; import javax.baja.control.*; import java.util.*; /**Uses the module started() function to initiate a delay time.*/ public class BStationStartTimer extends BComponent{ public int delay, period, presetTemp, remain; public BRelTime presetTime, remainTime; public void started(){ setTimerDone(new BStatusBoolean(getOnStartTimerIs().getValue())); delay = 0; period = 1000; setPreset(); remain = presetTemp; setRemain(); final Timer timer = new Timer(); timer.scheduleAtFixedRate(new TimerTask() { public void run() { if (remain > presetTemp){ remain = presetTemp; setRemain(); } if(remain >= 0){ remain -= 1; setRemain(); } if (remain < 0){ remain = 0; setRemain(); setTimerDone(new BStatusBoolean(!getOnStartTimerIs().getValue())); timer.cancel(); } } }, delay, period); } public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } if(property == presetInSeconds){ setPreset(); } if(property == onStartTimerIs){ setTimerDone(new BStatusBoolean(!getOnStartTimerIs().getValue())); } } public void setPreset() { presetTemp = (int)getPresetInSeconds().getValue(); presetTime = BRelTime.makeSeconds(presetTemp); setPreset(presetTime.abs()); } public void setRemain() { remainTime = BRelTime.makeSeconds(remain); setTimeRemaining(remainTime.abs()); setTimeRemainingInSeconds(new BStatusNumeric(remain)); } public void doEndTimer(){ if (remain > 4){ remain = 4; setRemain(); } } /**This action writes a value of 4 seconds to the remaining time*/ public static final Action endTimer = newAction(0); /**This describes what the timerDone state will be when the timer is timing*/ public static final Property onStartTimerIs = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); /**Is set to the opposite of onStartTimerIs value when the timer is complete*/ public static final Property timerDone = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); /**The preset for the timer expressed in total seconds*/ public static final Property presetInSeconds = newProperty(Flags.SUMMARY, new BStatusNumeric(300)); /**The preset represented in relative time*/ public static final Property preset = newProperty(Flags.SUMMARY, BRelTime.DEFAULT); /**The time remaining represented in total seconds*/ public static final Property timeRemainingInSeconds = newProperty(Flags.SUMMARY, new BStatusNumeric(0)); /**The time remaining represented in relative time*/ public static final Property timeRemaining = newProperty(Flags.SUMMARY, BRelTime.DEFAULT); public BStatusBoolean getOnStartTimerIs() { return (BStatusBoolean)get(onStartTimerIs); } public BStatusBoolean getTimerDone() { return (BStatusBoolean)get(timerDone); } public BStatusNumeric getPresetInSeconds() { return (BStatusNumeric)get(presetInSeconds); } public BRelTime getPreset() { return (BRelTime)get(preset); } public BStatusNumeric getTimeRemainingInSeconds() { return (BStatusNumeric)get(timeRemainingInSeconds); } public BRelTime getTimeRemaining() { return (BRelTime)get(timeRemaining); } public void setOnStartTimerIs(BStatusBoolean v) { set(onStartTimerIs, v); } public void setTimerDone(BStatusBoolean v) { set(timerDone, v); } public void setPresetInSeconds(BStatusNumeric v) { set(presetInSeconds, v); } public void setPreset(BRelTime v) { set(preset, v); } public void setTimeRemainingInSeconds(BStatusNumeric v) { set(timeRemainingInSeconds, v); } public void setTimeRemaining(BRelTime v) { set(timeRemaining, v); } public void endTimer() { invoke(endTimer, null, null); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BStationStartTimer.class); public Type getType() { return TYPE; } } Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com/korsengineering/niagara/timer/BTempWrite.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 3597 Text-content-md5: 77e2639c01cdaf2d7191c5d4dc5e865a Text-content-sha1: 4c6cd1e99b7d73e49c0e7e30740e7ff6504b3744 Content-length: 3607 PROPS-END package com.korsengineering.niagara.timer; import javax.baja.status.*; import javax.baja.sys.*; import java.util.*; public class BTempWrite extends BComponent{ boolean fired = false; Clock.Ticket ticket; public void started(){ doSetNull(); } void updateTimer(){ if (ticket != null) ticket.cancel(); ticket = Clock.schedule(this, getWriteDuration(), setNull, null); } public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } if (property == trigger){ //System.out.println(this.asComponent().getNavName() + ':' + getTrigger().getBoolean() + ':' + fired ); if (getTrigger().getValue() && fired == false){ fired = true; getOutput().setValue(getInput().getValue()); getOutput().setStatusNull(false); updateTimer(); } else { fired = false; } } } public void doSetNull(){ this.getOutput().setStatusNull(true); } public void doSetWriteTime(BInteger i){ setWriteDuration(BRelTime.makeSeconds(i.getInt())); } public void doWriteThisValue(BInteger i){ getOutput().setValue(i.getDouble()); this.getOutput().setStatusNull(false); updateTimer(); } // public BValue getActionParameterDefault(Action action) { // if (action == BTempWrite.writeThisValue) { // return getInput().asValue(); // } else { // return action.getParameterDefault(); // } // } public static final Action setWriteTime = newAction(0, BInteger.make(1)); public static final Action writeThisValue = newAction(0,BInteger.make(1)); public static final Action setNull = newAction(0); public static final Property input = newProperty(Flags.SUMMARY, new BStatusNumeric()); public static final Property output = newProperty(Flags.SUMMARY, new BStatusNumeric()); public static final Property writeDuration = newProperty(Flags.SUMMARY, BRelTime.DEFAULT); public BStatusNumeric getInput() { return (BStatusNumeric)get(input); } public BStatusNumeric getOutput() { if (ticket != null){ return (BStatusNumeric)get(output); } else{ return (new BStatusNumeric()); } } public BRelTime getWriteDuration() { return (BRelTime)get(writeDuration); } public void setInput(BStatusNumeric v) { set(input, v); } public void setOutput(BStatusNumeric v) { set(output, v); } public void setWriteDuration(BRelTime v) { set(writeDuration, v); } public void setWriteTime(BInteger x) { invoke(setWriteTime, x, null); } public void writeThisValue( BInteger now) { invoke(writeThisValue, now, null); } public void setNull(){ invoke(setNull,null,null); } public static final Property trigger = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BStatusBoolean getTrigger() { return (BStatusBoolean)get(trigger); } public void setTrigger(BStatusBoolean v) { set(trigger, v); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BTempWrite.class); public Type getType() { return TYPE; } } Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com/korsengineering/niagara/timer/BTimer.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 5299 Text-content-md5: d7e45392e48d9ba38e808bdc2b40a173 Text-content-sha1: 9bc79f7285a6fae97339cb2d4748b2225d7c282e Content-length: 5309 PROPS-END package com.korsengineering.niagara.timer; import javax.baja.status.*; import javax.baja.sys.*; import javax.baja.control.*; import java.util.*; /**A timer that uses a StatusNumeric input of seconds as a preset *and outputs a remaining time also as a StatusNumeric represented in *total seconds*/ public class BTimer extends BComponent{ public int delay, period, presetTemp, remain; public BRelTime presetTime, remainTime; public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } if(property == presetInSeconds){ setPreset(); } if (property == runTimer) { if (!getRunTimer().getValue()){ setTimerDone(new BStatusBoolean(false)); remain = 0; setRemain(); } if (getRunTimer().getValue()){ setTimerDone(new BStatusBoolean(false)); delay = 0; period = 1000; remain = presetTemp; setRemain(); final Timer timer = new Timer(); timer.scheduleAtFixedRate(new TimerTask() { public void run() { if (remain > presetTemp){ remain = presetTemp; setRemain(); } if(remain >= 0){ remain -= 1; setRemain(); } if(!getRunTimer().getValue()) { remain = 0; setRemain(); setTimerDone(new BStatusBoolean(false)); timer.cancel(); } if (remain < 0){ remain = 0; setRemain(); setTimerDone(new BStatusBoolean(true)); timer.cancel(); } } }, delay, period); } } } public void setPreset() { presetTemp = (int)getPresetInSeconds().getValue(); presetTime = BRelTime.makeSeconds(presetTemp); setPreset(presetTime.abs()); } public void setRemain() { remainTime = BRelTime.makeSeconds(remain); setTimeRemaining(remainTime.abs()); setTimeRemainingInSeconds(new BStatusNumeric(remain)); } public void doEndTimer(){ if (remain > 4){ remain = 4; setRemain(); } } /**This action writes a value of 4 seconds to the remaining time*/ public static final Action endTimer = newAction(0); /**When this is True, the timer activates*/ public static final Property runTimer = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); /**Is set to True when the timer completes*/ public static final Property timerDone = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); /**The preset for the timer expressed in total seconds*/ public static final Property presetInSeconds = newProperty(Flags.SUMMARY, new BStatusNumeric(0)); /**The preset represented in relative time*/ public static final Property preset = newProperty(Flags.SUMMARY, BRelTime.DEFAULT); /**The time remaining represented in total seconds*/ public static final Property timeRemainingInSeconds = newProperty(Flags.SUMMARY, new BStatusNumeric(0)); /**The time remaining represented in relative time*/ public static final Property timeRemaining = newProperty(Flags.SUMMARY, BRelTime.DEFAULT); public BStatusBoolean getRunTimer() { return (BStatusBoolean)get(runTimer); } public BStatusBoolean getTimerDone() { return (BStatusBoolean)get(timerDone); } public BStatusNumeric getPresetInSeconds() { return (BStatusNumeric)get(presetInSeconds); } public BRelTime getPreset() { return (BRelTime)get(preset); } public BStatusNumeric getTimeRemainingInSeconds() { return (BStatusNumeric)get(timeRemainingInSeconds); } public BRelTime getTimeRemaining() { return (BRelTime)get(timeRemaining); } public void setRunTimer(BStatusBoolean v) { set(runTimer, v); } public void setTimerDone(BStatusBoolean v) { set(timerDone, v); } public void setPresetInSeconds(BStatusNumeric v) { set(presetInSeconds, v); } public void setPreset(BRelTime v) { set(preset, v); } public void setTimeRemainingInSeconds(BStatusNumeric v) { set(timeRemainingInSeconds, v); } public void setTimeRemaining(BRelTime v) { set(timeRemaining, v); } public void endTimer() { invoke(endTimer, null, null); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BTimer.class); public Type getType() { return TYPE; } } Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com/korsengineering/niagara/triggeredMath Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com/korsengineering/niagara/triggeredMath/BTrAdd.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 2646 Text-content-md5: 74f8d89cb5c4a376d8356023bcd4dafb Text-content-sha1: 151cb1ce38f311e695884760ebdd851c1ad7191d Content-length: 2656 PROPS-END package com.korsengineering.niagara.triggeredMath; import javax.baja.sys.*; import javax.baja.status.*; public class BTrAdd extends BComponent{ boolean fire = false; public void started(){ try{ if (getSlot("Out").isProperty()){ //Check for slot } } catch(Exception ex){ add("Out", new BStatusNumeric(0), Flags.SUMMARY); add("In$20A", new BStatusNumeric(0), Flags.SUMMARY); add("In$20B", new BStatusNumeric(0), Flags.SUMMARY); add("In$20C", new BStatusNumeric(0), 0); add("In$20D", new BStatusNumeric(0), 0); } } public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } try{ if (property == facets){ setFacets(getSlot("Out"), getFacets()); setFacets(getSlot("In$20A"), getFacets()); setFacets(getSlot("In$20B"), getFacets()); setFacets(getSlot("In$20C"), getFacets()); setFacets(getSlot("In$20D"), getFacets()); } if (property == trigger){ if (getTrigger().getValue() && fire == false){ double a, b, c, d, result; a = ((BStatusNumeric)get(getProperty("In$20A"))).getValue(); b = ((BStatusNumeric)get(getProperty("In$20B"))).getValue(); c = ((BStatusNumeric)get(getProperty("In$20C"))).getValue(); d = ((BStatusNumeric)get(getProperty("In$20D"))).getValue(); result = a + b + c + d; set(getProperty("Out"), new BStatusNumeric(result)); fire = true; } else { fire = false; } } } catch(Exception e){ System.out.println(BAbsTime.now().toString() + ": Kors Component Error at " + this.getSlotPath().toString() + ":" + e.toString()); } } public static final Property facets = newProperty(0, BFacets.makeNumeric(1)); public static final Property trigger = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BFacets getFacets() { return (BFacets)get(facets); } public BStatusBoolean getTrigger() { return (BStatusBoolean)get(trigger); } public void setFacets(BFacets v) { set(facets, v); } public void setTrigger(BStatusBoolean v) { set(trigger, v); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BTrAdd.class); public Type getType() { return TYPE; } } Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com/korsengineering/niagara/triggeredMath/BTrCopy.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 2059 Text-content-md5: 82ee5bb714f780587e97bd99a5a8bed8 Text-content-sha1: 4023025ebd2558c9f768e92279bc622cfffe6cc0 Content-length: 2069 PROPS-END package com.korsengineering.niagara.triggeredMath; import javax.baja.sys.*; import javax.baja.status.*; public class BTrCopy extends BComponent{ boolean fire = false; public void started(){ try{ if (getSlot("Copy").isProperty()){ //Check for slot } } catch(Exception ex){ add("Copy", new BStatusNumeric(0), Flags.SUMMARY); add("Input", new BStatusNumeric(0), Flags.SUMMARY); } } public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } try{ if (property == facets){ setFacets(getSlot("Copy"), getFacets()); setFacets(getSlot("Input"), getFacets()); } if (property == trigger){ if (getTrigger().getValue() && fire == false){ double a; a = ((BStatusNumeric)get(getProperty("Input"))).getValue(); set(getProperty("Copy"), new BStatusNumeric(a)); fire = true; } else { fire = false; } } } catch(Exception e){ System.out.println(BAbsTime.now().toString() + ": Kors Component Error at " + this.getSlotPath().toString() + ":" + e.toString()); } } public static final Property facets = newProperty(0, BFacets.makeNumeric(1)); public static final Property trigger = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BFacets getFacets() { return (BFacets)get(facets); } public BStatusBoolean getTrigger() { return (BStatusBoolean)get(trigger); } public void setFacets(BFacets v) { set(facets, v); } public void setTrigger(BStatusBoolean v) { set(trigger, v); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BTrCopy.class); public Type getType() { return TYPE; } } Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com/korsengineering/niagara/triggeredMath/BTrDivide.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 2432 Text-content-md5: b48202cad414d3941c5b938042039748 Text-content-sha1: 59719c20ee003e2b15f7002951b4cae9a372b977 Content-length: 2442 PROPS-END package com.korsengineering.niagara.triggeredMath; import javax.baja.sys.*; import javax.baja.status.*; public class BTrDivide extends BComponent{ boolean fire = false; public void started(){ try{ if (getSlot("Out").isProperty()){ //Check for slot } } catch(Exception ex){ add("Out", new BStatusNumeric(0), Flags.SUMMARY); add("In$20A", new BStatusNumeric(0), Flags.SUMMARY); add("In$20B", new BStatusNumeric(0), Flags.SUMMARY); } } public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } try{ if (property == facets){ setFacets(getSlot("Out"), getFacets()); setFacets(getSlot("In$20A"), getFacets()); setFacets(getSlot("In$20B"), getFacets()); } if (property == trigger){ if (getTrigger().getValue() && fire == false){ double a, b, result; a = ((BStatusNumeric)get(getProperty("In$20A"))).getValue(); b = ((BStatusNumeric)get(getProperty("In$20B"))).getValue(); if (b != 0){ result = a / b; set(getProperty("Out"), new BStatusNumeric(result)); } else { getTrigger().setStatus(BStatus.fault); } fire = true; } else { fire = false; } } } catch(Exception e){ System.out.println(BAbsTime.now().toString() + ": Kors Component Error at " + this.getSlotPath().toString() + ":" + e.toString()); } } public static final Property facets = newProperty(0, BFacets.makeNumeric(1)); public static final Property trigger = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BFacets getFacets() { return (BFacets)get(facets); } public BStatusBoolean getTrigger() { return (BStatusBoolean)get(trigger); } public void setFacets(BFacets v) { set(facets, v); } public void setTrigger(BStatusBoolean v) { set(trigger, v); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BTrDivide.class); public Type getType() { return TYPE; } } Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com/korsengineering/niagara/triggeredMath/BTrMultiply.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 2305 Text-content-md5: ff5038340d44a8c57b784210ecaa644a Text-content-sha1: 99208dea2f79792f9c40f63978c9e00edd80b301 Content-length: 2315 PROPS-END package com.korsengineering.niagara.triggeredMath; import javax.baja.sys.*; import javax.baja.status.*; public class BTrMultiply extends BComponent{ boolean fire = false; public void started(){ try{ if (getSlot("Out").isProperty()){ //Check for slot } } catch(Exception ex){ add("Out", new BStatusNumeric(0), Flags.SUMMARY); add("In$20A", new BStatusNumeric(0), Flags.SUMMARY); add("In$20B", new BStatusNumeric(0), Flags.SUMMARY); } } public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } try{ if (property == facets){ setFacets(getSlot("Out"), getFacets()); setFacets(getSlot("In$20A"), getFacets()); setFacets(getSlot("In$20B"), getFacets()); } if (property == trigger){ if (getTrigger().getValue() && fire == false){ double a, b, result; a = ((BStatusNumeric)get(getProperty("In$20A"))).getValue(); b = ((BStatusNumeric)get(getProperty("In$20B"))).getValue(); result = a * b; set(getProperty("Out"), new BStatusNumeric(result)); fire = true; } else { fire = false; } } } catch(Exception e){ System.out.println(BAbsTime.now().toString() + ": Kors Component Error at " + this.getSlotPath().toString() + ":" + e.toString()); } } public static final Property facets = newProperty(0, BFacets.makeNumeric(1)); public static final Property trigger = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BFacets getFacets() { return (BFacets)get(facets); } public BStatusBoolean getTrigger() { return (BStatusBoolean)get(trigger); } public void setFacets(BFacets v) { set(facets, v); } public void setTrigger(BStatusBoolean v) { set(trigger, v); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BTrMultiply.class); public Type getType() { return TYPE; } } Node-path: niagara/korsOrm/src/com/korsengineering/plexus/db/orm/korsMaster/src/com/korsengineering/niagara/triggeredMath/BTrSubtract.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 2306 Text-content-md5: a59bca77ed4d1e133d946046ef792a00 Text-content-sha1: a0ec7ce96aaf9fde80a47d151768a18a37073abc Content-length: 2316 PROPS-END package com.korsengineering.niagara.triggeredMath; import javax.baja.sys.*; import javax.baja.status.*; public class BTrSubtract extends BComponent{ boolean fire = false; public void started(){ try{ if (getSlot("Out").isProperty()){ //Check for slot } } catch(Exception ex){ add("Out", new BStatusNumeric(0), Flags.SUMMARY); add("In$20A", new BStatusNumeric(0), Flags.SUMMARY); add("In$20B", new BStatusNumeric(0), Flags.SUMMARY); } } public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } try{ if (property == facets){ setFacets(getSlot("Out"), getFacets()); setFacets(getSlot("In$20A"), getFacets()); setFacets(getSlot("In$20B"), getFacets()); } if (property == trigger){ if (getTrigger().getValue() && fire == false){ double a, b, result; a = ((BStatusNumeric)get(getProperty("In$20A"))).getValue(); b = ((BStatusNumeric)get(getProperty("In$20B"))).getValue(); result = a - b; set(getProperty("Out"), new BStatusNumeric(result)); fire = true; } else { fire = false; } } } catch(Exception e){ System.out.println(BAbsTime.now().toString() + ": Kors Component Error at " + this.getSlotPath().toString() + ":" + e.toString()); } } public static final Property facets = newProperty(0, BFacets.makeNumeric(1)); public static final Property trigger = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BFacets getFacets() { return (BFacets)get(facets); } public BStatusBoolean getTrigger() { return (BStatusBoolean)get(trigger); } public void setFacets(BFacets v) { set(facets, v); } public void setTrigger(BStatusBoolean v) { set(trigger, v); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BTrSubtract.class); public Type getType() { return TYPE; } } Node-path: niagara/korsPlexus Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsPlexus/.classpath Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 2799 Text-content-md5: 05a75d212c144e8dbfcbcce7f7f1313e Text-content-sha1: 40152757ff2e5565f142f634502c4e6ab0728b90 Content-length: 2809 PROPS-END Node-path: niagara/korsPlexus/.project Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 380 Text-content-md5: 0a71cce6ff90bd02b88e73bf9f879a33 Text-content-sha1: 482ef60eebb76acba1ba2d83f70699650d988c28 Content-length: 390 PROPS-END kors org.eclipse.jdt.core.javabuilder org.eclipse.jdt.core.javanature Node-path: niagara/korsPlexus/.settings Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsPlexus/.settings/org.eclipse.jdt.core.prefs Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 334 Text-content-md5: 273263cbe74aa6557bffec6bbf7c0b51 Text-content-sha1: e066a58e4525ce31a06778b4660f254956d0feb8 Content-length: 344 PROPS-END #Thu Oct 18 16:37:20 EDT 2007 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 org.eclipse.jdt.core.compiler.compliance=1.4 org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning org.eclipse.jdt.core.compiler.source=1.3 Node-path: niagara/korsPlexus/.settings/org.eclipse.wst.validation.prefs Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 798 Text-content-md5: 6c504fd8947feb16f95e6a73072f14d1 Text-content-sha1: a5e0692128efd5776169ac20688b3e0fd1964a88 Content-length: 808 PROPS-END #Thu Oct 18 17:02:54 EDT 2007 DELEGATES_PREFERENCE=delegateValidatorListorg.eclipse.wst.xsd.core.internal.validation.eclipse.XSDDelegatingValidator\=org.eclipse.wst.xsd.core.internal.validation.eclipse.Validator; USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.wst.dtd.core.internal.validation.eclipse.Validator;org.eclipse.wst.xsd.core.internal.validation.eclipse.XSDDelegatingValidator;org.eclipse.wst.xml.core.internal.validation.eclipse.Validator; USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.wst.dtd.core.internal.validation.eclipse.Validator;org.eclipse.wst.xsd.core.internal.validation.eclipse.XSDDelegatingValidator;org.eclipse.wst.xml.core.internal.validation.eclipse.Validator; USER_PREFERENCE=overrideGlobalPreferencesfalse eclipse.preferences.version=1 Node-path: niagara/korsPlexus/POLtoPLC.txt Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 371 Text-content-md5: 1bb2ef887edadaf365cf7cb106bdb997 Text-content-sha1: 1787b218aa89ad0b5d5525822137b53299307f50 Content-length: 381 PROPS-END LineB_Op5 Start 1 Machine01 Message Production:Automatic 203 Node-path: niagara/korsPlexus/build.xml Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 645 Text-content-md5: c8b4dc390421548c8f7078a62b989a12 Text-content-sha1: 5fcc68ea89abbb599e4a6a241c514bd1e285a281 Content-length: 655 PROPS-END Node-path: niagara/korsPlexus/module-include.xml Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 932 Text-content-md5: 81a5f4008126a56ee875368bc2bd083e Text-content-sha1: 3e84a8196a3653ecb7bc086903b3331496252bf5 Content-length: 942 PROPS-END Node-path: niagara/korsPlexus/module.lexicon Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 0 Text-content-md5: d41d8cd98f00b204e9800998ecf8427e Text-content-sha1: da39a3ee5e6b4b0d3255bfef95601890afd80709 Content-length: 10 PROPS-END Node-path: niagara/korsPlexus/module.palette Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 612 Text-content-md5: 02b4c74055e18d59f933c92713e2b481 Text-content-sha1: 30c76d165758c625574a00d9bc1120c1f334a8c3 Content-length: 622 PROPS-END

Node-path: niagara/korsPlexus/responce.txt Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 346 Text-content-md5: d5bcfa46b26633796ae1302777cb9419 Text-content-sha1: 3866d5897daca50531cf625bf8ee9b1e7ae6c014 Content-length: 356 PROPS-END LineB_Op5 AddProduction 2 Serial No already exists Node-path: niagara/korsPlexus/src Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsPlexus/src/com Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsPlexus/src/com/korsengineering Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsPlexus/src/com/korsengineering/http Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsPlexus/src/com/korsengineering/http/HttpSender.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 1729 Text-content-md5: bd5fe3c02ee3b9ae093f47fc1c2b98c6 Text-content-sha1: b97c0f298c476d141c0be8925f3780d704b552a6 Content-length: 1739 PROPS-END package com.korsengineering.http; import java.io.*; import java.net.*; import javax.baja.io.Base64; /** * @author Roman Ivanov * Generic HTTP sender, which can deal with simple authentication. */ public class HttpSender{ /** * This class is simply a container for static methods. */ private HttpSender(){} /** * @param destination * @param login * @param password * @param xml Body of the request that will be made. * @return String with the response body. * @throws IOException */ public static String send(URL destination, String login, String password, String xml) throws IOException { HttpURLConnection connection = (HttpURLConnection) destination.openConnection(); connection.setRequestMethod("POST"); connection.setRequestProperty("Host", destination.getHost()); String authCode = Base64.encode((login + ":" + password).getBytes()); connection.setRequestProperty("Authorization", "Basic " + authCode); connection.setDoOutput(true); connection.connect(); OutputStream out = connection.getOutputStream(); byte[] xmlBytes = xml.getBytes(); out.write(xmlBytes, 0, xmlBytes.length); String inString = ""; try { BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); String inBuffer = ""; while ((inBuffer = in.readLine()) != null) { inString += inBuffer + "\n"; } } catch (IOException ex) { ex.printStackTrace(); } connection.disconnect(); return inString; } } Node-path: niagara/korsPlexus/src/com/korsengineering/niagara Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsPlexus/src/com/korsengineering/niagara/plexus Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsPlexus/src/com/korsengineering/niagara/plexus/BAddProduction.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 803 Text-content-md5: 7818fc2db13e74b194a26fbe2a4baf3f Text-content-sha1: 12e2ffdaeab4ebf715b1ef4874087e4d523c7550 Content-length: 813 PROPS-END package com.korsengineering.niagara.plexus; import javax.baja.status.BStatusString; import javax.baja.sys.Flags; import javax.baja.sys.Property; import javax.baja.sys.Sys; import javax.baja.sys.Type; /** * @author Roman Ivanov * */ public class BAddProduction extends BPoster{ public String getAction(){ return "AddProduction"; } public static final Property serialNo = newProperty(Flags.SUMMARY | Flags.USER_DEFINED_1, new BStatusString()); public BStatusString getSerialNo() { return (BStatusString) get(serialNo); } public void setSerialNo(BStatusString v) { set(serialNo, v); } public static final Type TYPE = Sys.loadType(BAddProduction.class); public Type getType() { return TYPE; } } Node-path: niagara/korsPlexus/src/com/korsengineering/niagara/plexus/BCompleteOperation.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 818 Text-content-md5: a443fcca781faade4f4989169c0c123d Text-content-sha1: dc500c69ba906187323c0f50f6069835124ccab4 Content-length: 828 PROPS-END package com.korsengineering.niagara.plexus; import javax.baja.status.BStatusString; import javax.baja.sys.Flags; import javax.baja.sys.Property; import javax.baja.sys.Sys; import javax.baja.sys.Type; /** * @author Roman Ivanov * */ public class BCompleteOperation extends BPoster{ public String getAction(){ return "CompleteOperation"; } public static final Property serialNo = newProperty(Flags.SUMMARY | Flags.USER_DEFINED_1, new BStatusString()); public BStatusString getSerialNo() { return (BStatusString) get(serialNo); } public void setSerialNo(BStatusString v) { set(serialNo, v); } public static final Type TYPE = Sys.loadType(BCompleteOperation.class); public Type getType() { return TYPE; } } Node-path: niagara/korsPlexus/src/com/korsengineering/niagara/plexus/BJobUpdate.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 1152 Text-content-md5: bad150b2bf6699530f918fb5866741f4 Text-content-sha1: 5a21ffec61bae186584827d7e2c9f0e45460a1be Content-length: 1162 PROPS-END package com.korsengineering.niagara.plexus; import javax.baja.status.BStatusString; import javax.baja.sys.Flags; import javax.baja.sys.Property; import javax.baja.sys.Sys; import javax.baja.sys.Type; /** * @author Roman Ivanov * */ public class BJobUpdate extends BPoster{ public String getAction(){ return "JobUpdate"; } public static final Property partsProduced = newProperty(Flags.SUMMARY | Flags.USER_DEFINED_1, new BStatusString(), null); public BStatusString getPartsProduced() { return (BStatusString) get(partsProduced); } public void setPartsProduced(BStatusString v) { set(partsProduced, v, null); } public static final Property partNumber = newProperty(Flags.SUMMARY | Flags.USER_DEFINED_1, new BStatusString(), null); public BStatusString getPartNumber() { return (BStatusString) get(partNumber); } public void setPartNumber(BStatusString v) { set(partNumber, v, null); } public static final Type TYPE = Sys.loadType(BJobUpdate.class); public Type getType() { return TYPE; } } Node-path: niagara/korsPlexus/src/com/korsengineering/niagara/plexus/BPoster.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 11969 Text-content-md5: b1b9341bf73a84d8a1ad5c75b680a61a Text-content-sha1: 3acee7d14b9e3efd97a4e2f59955c4d4a1d273e7 Content-length: 11979 PROPS-END package com.korsengineering.niagara.plexus; import com.korsengineering.http.HttpSender; import java.io.*; import java.net.*; import java.text.SimpleDateFormat; import java.util.Date; import javax.baja.naming.SyntaxException; import javax.baja.security.BPassword; import javax.baja.sys.*; import javax.baja.xml.XElem; import javax.baja.xml.XParser; import com.tridium.util.FileLock; import javax.baja.status.*; import javax.baja.xml.XException; /** * This class models and sends requests to Plexus. All slots that are maked as * "USER_DEFINED_1" in subclasses will be used as fields in the body XML. * @author Roman Ivanov */ public abstract class BPoster extends BComponent{ protected File buffer; protected boolean lastTriggerState = false; protected URL destinationUrl; public void started() throws Exception{ buffer = new File(Sys.getStationHome().getAbsolutePath() + "/plex-buffer.xml"); setGoodTransactions(new BStatusNumeric(0)); setBadTransactions(new BStatusNumeric(0)); } /** * Reacts to changes in destination and trigger slots. */ public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } if (property == destination) { try { if (getDestination().getValue().equals("") || getDestination().getValue() == null) { destinationUrl = new URL("http:127.0.0.1"); } else { destinationUrl = new URL(getDestination().getValue()); } } catch (MalformedURLException ex) { throw new SyntaxException(ex); } } else if (property == trigger) { try { if (getTrigger().getValue() && (lastTriggerState == false)) { //set start time of transaction BAbsTime bt = BAbsTime.now(); doSend(); BRelTime at = bt.delta(BAbsTime.now()); setTimeLastTransaction(new BStatusNumeric(at.getMillis())); } } catch (Exception ex) { throw new BajaRuntimeException(ex); } finally { lastTriggerState = getTrigger().getValue(); } } } //Boilerplate code: /** * URL for the future requests. */ public static final Property destination = newProperty(Flags.SUMMARY, new BStatusString()); public BStatusString getDestination() { return (BStatusString) get(destination); } public void setDestination(BStatusString v) { set(destination, v); } /** * Http login. */ public static final Property login = newProperty(Flags.SUMMARY, new BStatusString()); public BStatusString getLogin() { return (BStatusString) get(login); } public void setLogin(BStatusString v) { set(login, v); } /** * Http password. */ public static final Property password = newProperty(Flags.SUMMARY, BPassword.DEFAULT); public BPassword getPassword() { return (BPassword) get(password); } public void setPassword(BPassword v) { set(password, v); } /** * ID of this machine (for Plexus). */ public static final Property machineId = newProperty(Flags.SUMMARY, new BStatusString()); public BStatusString getMachineId() { return (BStatusString) get(machineId); } public void setMachineId(BStatusString v) { set(machineId, v); } /** * When set to true from false state, triggers doSend(). */ public static final Property trigger = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BStatusBoolean getTrigger() { return (BStatusBoolean) get(trigger); } public void setTrigger(BStatusBoolean v) { set(trigger, v); } /** * Whether re last request was successfull. Account for low-level errors, * as well as responce status from Plexus. */ public static final Property result = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BStatusBoolean getResult() { return (BStatusBoolean) get(result); } public void setResult(BStatusBoolean v) { set(result, v); } /** * Set to true if IO exception was thrown while sending data. */ public static final Property internetFailure = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BStatusBoolean getInternetFailure() { return (BStatusBoolean) get(internetFailure); } public void setInternetFailure(BStatusBoolean v) { set(internetFailure, v); } /** * When set to true, transaction that failed due to low-level errors (IO) * will be buffered in plex-biffer.xml. * @see com.korsengineering.niagara.plexus.BRepeater */ public static final Property useBuffer = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BStatusBoolean getUseBuffer() { return (BStatusBoolean) get(useBuffer); } public void setUseBuffer(BStatusBoolean v) { set(useBuffer, v); } public static final Property verbose = newProperty(0, false); public boolean getVerbose() { return getBoolean(verbose); } public void setVerbose(boolean v) { setBoolean(verbose, v); } public static final Property lastRequest = newProperty(0, new BStatusString()); public BStatusString getLastRequest() { return (BStatusString)get(lastRequest); } public void setLastRequest(BStatusString v) { set(lastRequest, v); } public static final Property lastResponse = newProperty(0, new BStatusString()); public BStatusString getLastResponse() { return (BStatusString)get(lastResponse); } public void setLastResponse(BStatusString v) { set(lastResponse, v); } public static final Property goodTransactions = newProperty(Flags.SUMMARY, new BStatusNumeric(0)); public BStatusNumeric getGoodTransactions() { return (BStatusNumeric) get(goodTransactions); } public void setGoodTransactions(BStatusNumeric v) { set(goodTransactions, v); } public static final Property badTransactions = newProperty(Flags.SUMMARY, new BStatusNumeric(0)); public BStatusNumeric getBadTransactions() { return (BStatusNumeric) get(badTransactions); } public void setBadTransactions(BStatusNumeric v) { set(badTransactions, v); } private static javax.baja.units.BUnit msecs = javax.baja.units.BUnit.getUnit("millisecond"); public static final Property timeLastTransaction = newProperty(Flags.SUMMARY, new BStatusNumeric(0),BFacets.makeNumeric(msecs, 0)); public BStatusNumeric getTimeLastTransaction() { return (BStatusNumeric) get(timeLastTransaction); } public void setTimeLastTransaction(BStatusNumeric v) { set(timeLastTransaction, v); } protected String getAction(){ return this.getClass().getName().substring(1); } public static final Action send = newAction(0); public void send() { invoke(send, null); } //invokes /** * Generates XML request from the fields of the object, and sends it to * http://www.plexus-online.com/PLC via HttpSender. Sets result slot * appropriately. If the request fails due to IO error and buffering is * enabled, this method buffers the request via addToBuffer(). * @see com.korsengineering.niagara.plexus.BPoster#addToBuffer() * @throws Exception */ public void doSend() throws Exception{ Date now = new Date(); SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy"); SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss"); String xml = "" + "" + "" + getMachineId().getValue() + "" + "" + getAction() + "" + "" + "" + dateFormat.format(now) + "" + ""; SlotCursor properties = getProperties(); int contentLength = 0; while (properties.next()) { Property property = properties.property(); if (!Flags.isUserDefined1(this, property)) { continue; } String valueString = ""; if (get(property) instanceof BStatusString) { valueString = ((BStatusString) get(property)).getValue(); } else { continue; } String name = property.getName().substring(0, 1).toUpperCase() + property.getName().substring(1); xml += "<"+name+">"+valueString+""; contentLength += valueString.length(); } xml += "" + "" + ""; if (getVerbose()) { System.out.println("Request: \n" + xml); } boolean sent = false; setLastRequest(new BStatusString(xml)); if (contentLength>0) { try { String response = HttpSender.send(destinationUrl, getLogin().getValue(), getPassword().getString(), xml); setInternetFailure(new BStatusBoolean(false)); setLastResponse(new BStatusString(response)); if (getVerbose()) { System.out.println("Response: \n" + response); } sent = response.indexOf("0") != -1; setLastResponse(new BStatusString(response)); } catch (IOException ex) { setInternetFailure(new BStatusBoolean(true)); setLastResponse(new BStatusString("Error: " + ex)); addToBuffer(xml, "io"); throw ex; } finally { if (sent) { setGoodTransactions(new BStatusNumeric(getGoodTransactions().getValue() + 1)); } else { setBadTransactions(new BStatusNumeric(getBadTransactions().getValue() + 1)); } setResult(new BStatusBoolean(sent)); } } } /** * Buffers failed requests in plex-buffer.xml file, located in station home folder. * @param value Failed request XML. (Not parsed.) * @param reason Reason of failure. Currently, only "io" is used. * @throws Exception */ public void addToBuffer(String value, String reason) throws Exception{ XElem root = new XElem("buffer"); if (!buffer.exists()) { if (!buffer.createNewFile()) { throw new IOException("Could not create the buffer file"); } } FileLock fl = FileLock.lock(buffer); try { if (buffer.length() != 0) { root = XParser.make(buffer).parse(); } XElem error = new XElem("error"); error.addAttr("times", "1"); error.addAttr("reason", reason); error.addContent(XParser.make(value).parse()); root.addContent(error); root.write(buffer); } catch (XException ex) { buffer.delete(); throw ex; } finally { fl.unlock(); } } public static final Type TYPE = Sys.loadType(BPoster.class); public Type getType() { return TYPE; } } Node-path: niagara/korsPlexus/src/com/korsengineering/niagara/plexus/BPressStatus.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 1595 Text-content-md5: 06875a6065a98a7fb761057c9046a61f Text-content-sha1: 8104f5adba35994a001b136adaea19f1e02d162f Content-length: 1605 PROPS-END /* * PressStatus.java * * Created on May 21, 2007, 2:25 PM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package com.korsengineering.niagara.plexus; import javax.baja.status.BStatusString; import javax.baja.sys.Flags; import javax.baja.sys.Property; import javax.baja.sys.Sys; import javax.baja.sys.Type; /** * * @author Roman Ivanov */ public class BPressStatus extends BPoster{ public String getAction(){ return "PressStatus"; } public static final Property newStatus = newProperty(Flags.SUMMARY | Flags.USER_DEFINED_1, new BStatusString()); public BStatusString getNewStatus() { return (BStatusString) get(newStatus); } public void setNewStatus(BStatusString v) { set(newStatus, v); } public static final Property reason = newProperty(Flags.SUMMARY | Flags.USER_DEFINED_1, new BStatusString()); public BStatusString getReason() { return (BStatusString) get(reason); } public void setReason(BStatusString v) { set(reason, v); } public static final Property description = newProperty(Flags.SUMMARY | Flags.USER_DEFINED_1, new BStatusString()); public BStatusString getDescription() { return (BStatusString) get(description); } public void setDescription(BStatusString v) { set(description, v); } public static final Type TYPE = Sys.loadType(BPressStatus.class); public Type getType() { return TYPE; } } Node-path: niagara/korsPlexus/src/com/korsengineering/niagara/plexus/BReceiver.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 15726 Text-content-md5: 3ab903e3e5d052de45dbb1dfcf67d807 Text-content-sha1: 9cbb1f5f13b23530604636f35742c9a8a2eeb368 Content-length: 15736 PROPS-END package com.korsengineering.niagara.plexus; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.text.SimpleDateFormat; import java.util.Date; import javax.baja.collection.BICollection; import javax.baja.control.*; import javax.baja.naming.BOrd; import javax.baja.status.*; import javax.baja.sys.*; import javax.baja.web.*; import javax.baja.xml.*; import javax.servlet.http.*; /** * Servlet that responds to Plexus xml requests. * @author Roman Ivanov */ public class BReceiver extends BWebServlet{ public void doPost(WebOp op) throws Exception{ if (getVerbose()) { System.out.println("Started servicing request"); } String response = ""; HttpServletRequest request = op.getRequest(); BufferedReader br = request.getReader(); String buffer = ""; String subBuffer = ""; while ((subBuffer = br.readLine()) != null) { buffer += subBuffer; } if (getVerbose()) { System.out.println("Request: " + buffer); } setLastRequest(new BStatusString(buffer)); XElem result = handleXml(buffer); ByteArrayOutputStream baos = new ByteArrayOutputStream(); XWriter xw = new XWriter(baos); result.write(xw); xw.flush(); baos.flush(); response = baos.toString(); if (getVerbose()) { System.out.println("Response: " + response); } setLastResponse(new BStatusString(response)); op.getHtmlWriter().println(response); if (getVerbose()) { System.out.println("Finished servicing request"); } } /** * Parses the request XML, deduces the points that need to be set, sets them, and sends back a reply. * @param xml * @return * @throws Exception */ public XElem handleXml(String xml) throws Exception{ XElem response = new XElem("", "http://www.plexus-online.com/PLC", "RespondCommand"); XElem root = XParser.make(xml).parse(); XElem[] events = root.elems("Event"); if (events.length == 0) { throw new BajaException("No events supplied in XML"); } for (int i = 0; i < events.length; i++) { XElem event = events[i]; String plc = event.elem("PLC").text().string(); String action = event.elem("Action").text().string(); event.removeContent(event.elem("PLC")); event.removeContent(event.elem("Action")); XElem[] data = event.elem("Data").elems(); XElem responseEvent = new XElem("Event"); responseEvent.addContent(new XElem("Plc").addText(plc)); responseEvent.addContent(new XElem("Action").addText(action)); boolean problems = false; String errors = ""; //check to see if transaction enabled String enabled = getEnabled(plc, action); if(enabled == ""){ if (action.equals("RequestUpdate")) { try { return handleRequestUpdate(plc); } catch (Exception e) { problems = true; errors = e.getMessage(); } } else { for (int j = 0; j < data.length; j++) { try { setPoints(plc, action, data[j].name(), data[j]); } catch (BajaException ex) { problems = true; errors += ex.getMessage() + "\r\n"; } } } } else{ //not enabled, return error code problems = true; errors = enabled; setLastRejection(plc,action); } XElem responseData = new XElem("Data"); if (!problems) { responseData.addContent(new XElem("Status").addText("1")); responseData.addContent(new XElem("StatusMsg").addText("Download Completed Successfuly")); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); Cursor cursor = getPointsByBql("select from control:StringWritable where slotPath like '%/"+plc+"/"+action+"/LastSuccessfulUpdate'"); if (cursor.next()) { ((BStringWritable) cursor.get()).setIn10(new BStatusString(format.format(new Date()))); } else { if (getVerbose()) { System.out.println("No '%/"+plc+"/"+action+"/LastSuccessfulUpdate' slot"); } } //((BStringWritable) BOrd.make("station:|slot:/"+plc+"/LastSuccessfulUpdate").resolve().get()).setIn10(new BStatusString(format.format(new Date()))); } else { responseData.addContent(new XElem("Status").addText("0")); responseData.addContent(new XElem("StatusMsg").addText("Errors: \n\r" + errors)); } responseEvent.addContent(responseData); response.addContent(responseEvent); } return response; } public void setLastSuccessful(String plc,String action){ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); Cursor cursor = getPointsByBql("select from control:StringWritable where slotPath like '%/"+plc+"/"+action+"/LastSuccessfulUpdate'"); if (cursor.next()) { ((BStringWritable) cursor.get()).setIn10(new BStatusString(format.format(new Date()))); } else { if (getVerbose()) { System.out.println("No '%/"+plc+"/"+action+"/LastSuccessfulUpdate' slot"); } } } public void setLastRejection(String plc,String action){ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); Cursor cursor = getPointsByBql("select from control:StringWritable where slotPath like '%/"+plc+"/"+action+"/LastRejectedUpdate'"); if (cursor.next()) { ((BStringWritable) cursor.get()).setIn10(new BStatusString(format.format(new Date()))); } else { if (getVerbose()) { System.out.println("No '%/"+plc+"/"+action+"/LastRejectedUpdate' slot"); } } } /** * Handles RequestUpdate requests, which is a special case as far as requests go. * @param plc * @return */ public XElem handleRequestUpdate(String plc){ Date now = new Date(); SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy"); SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss"); XElem response = new XElem("", "http://www.plexus-online.com/PLC", "RespondCommand"); XElem responseEvent = new XElem("Event"); responseEvent.addContent(new XElem("Plc").addText(plc)); responseEvent.addContent(new XElem("Action").addText("RequestUpdate")); Cursor cursor; XElem responseData = new XElem("Data"); cursor = getPointsByBql("select from control:NumericWritable where slotPath like '%/"+plc+"/RequestUpdate/PartsProduced'"); cursor.next(); BStatusNumeric partsProduced = ((BNumericWritable) cursor.get()).getOut(); if (partsProduced.getStatus().isOk()) { responseData.addContent(new XElem("DataQuality").addText("Good")); responseData.addContent(new XElem("Date").addText(dateFormat.format(now))); responseData.addContent(new XElem("Time").addText(timeFormat.format(now))); cursor = getPointsByBql("select from control:StringWritable where slotPath like '%/"+plc+"/RequestUpdate/PartNumber'"); if (!cursor.next()) { throw new BajaRuntimeException("No such slot"); } BStatusString partNumber = ((BStringWritable) cursor.get()).getOut(); cursor = getPointsByBql("select from control:NumericWritable where slotPath like '%/"+plc+"/RequestUpdate/PartsInBin'"); if (!cursor.next()) { throw new BajaRuntimeException("No such slot"); } BStatusNumeric partsInBin = ((BNumericWritable) cursor.get()).getOut(); cursor = getPointsByBql("select from control:NumericWritable where slotPath like '%/"+plc+"/RequestUpdate/HitsOnTool'"); if (!cursor.next()) { throw new BajaRuntimeException("No such slot"); } BStatusNumeric hitsOnTool = ((BNumericWritable) cursor.get()).getOut(); /* BStatusString partNumber = ((BStringWritable) BOrd.make("station:|slot:/"+plc+"/RequestUpdate/PartNumber").resolve().get()).getOut(); BStatusNumeric partsInBin = ((BNumericWritable) BOrd.make("station:|slot:/"+plc+"/RequestUpdate/PartsInBin").resolve().get()).getOut(); BStatusNumeric hitsOnTool = ((BNumericWritable) BOrd.make("station:|slot:/"+plc+"/RequestUpdate/HitsOnTool").resolve().get()).getOut(); */ responseData.addContent(new XElem("PartsProduced").addText(Double.toString(partsProduced.getValue()))); responseData.addContent(new XElem("PartNumber").addText(partNumber.getValue())); responseData.addContent(new XElem("PartsInBin").addText(Double.toString(partsInBin.getValue()))); responseData.addContent(new XElem("HitsOnTool").addText(Double.toString(hitsOnTool.getValue()))); responseData.addContent(new XElem("Status").addText("1")); responseData.addContent(new XElem("StatusMsg").addText("Download Completed Successfully")); setLastSuccessful(plc,"RequestUpdate"); } else { responseData.addContent(new XElem("DataQuality").addText("Bad")); responseData.addContent(new XElem("Date").addText(dateFormat.format(now))); responseData.addContent(new XElem("Time").addText(timeFormat.format(now))); responseData.addContent(new XElem("Status").addText("0")); responseData.addContent(new XElem("StatusMsg").addText("PLC Data Point Status BAD")); } responseEvent.addContent(responseData); response.addContent(responseEvent); return response; } /** * @param plc * @param action * @param name * @param point * @throws BajaException */ public void setPoints(String plc, String action, String name, XElem point) throws BajaException { XElem[] subpoints = point.elems(); String errors = ""; boolean problems = false; if (subpoints.length != 0) { for (int i = 0; i < subpoints.length; i++) { try { setPoints(plc, action, name + "/" + subpoints[i].name(), subpoints[i]); } catch (BajaException ex) { problems = true; errors += ex.getMessage() + "\r\n"; } } } else { System.out.println(plc); System.out.println(action); System.out.println(name); if(point.text()!=null) { System.out.println(point.text().length()); setPoint(plc, action, name, point.text().string()); } else { setPoint(plc, action, name, ""); } } if (problems) { throw new BajaException(errors); } } /** * @param plc * @param action * @param point * @param value * @throws BajaException */ public void setPoint(String plc, String action, String point, String value) throws BajaException{ System.out.println("Trying to set a point: /" +plc+"/"+action+"/"+point); if (value == null) { value = ""; } /*BOrd ord = BOrd.make("station:|slot:|bql:select from control:StringWritable where slotPath like '%/"+plc+"/"+action+"/"+point+"'"); BICollection result = (BICollection) ord.resolve().get(); Cursor cursor = result.cursor();*/ boolean changedSomething = false; Cursor cursor = getPointsByBql("select from control:StringWritable where slotPath like '%/"+plc+"/"+action+"/"+point+"'"); while (cursor.next()) { ((BStringWritable) cursor.get()).setIn10(new BStatusString(value)); changedSomething = true; } if (!changedSomething) { throw new BajaException("Tag not found: /"+plc+"/"+action+"/"+point); } } public String getEnabled(String plc, String action){ //this method checks for a "Enabled" bit in the action folder //if it exists and is false, checks for a "ResposeString" to return String resp = ""; try{ Cursor cursor = getPointsByBql("select from control:BooleanWritable where slotPath like '%/"+plc+"/"+action+"/Enabled'"); if(cursor!=null){ cursor.next(); BBooleanWritable b = ((BBooleanWritable) cursor.get()); //b.setValue(((BStatusBoolean) cursor.get()).getBoolean()); if(!b.getBoolean()){ //action is disabled, get the reason code to return to POL Cursor cursorS = getPointsByBql("select from control:StringWritable where slotPath like '%/"+plc+"/"+action+"/ResponseString'"); if(cursorS!=null){ cursorS.next(); resp = ((BStringWritable) cursorS.get()).getOut().getValue(); } } } } catch (Exception e){ //if error, just return "" System.out.println(e.toString()); resp = ""; } return resp; } /** * Utility method. * @param bql * @return Cursor with the points found by the given BQL statement. */ public Cursor getPointsByBql(String bql){ BOrd ord = BOrd.make("station:|slot:|bql:"+bql); BICollection result = (BICollection) ord.resolve().get(); return result.cursor(); } /** * When set to true, allows the obejct to output various debugging information (mostly errors) into the console. */ public static final Property verbose = newProperty(0, false); public boolean getVerbose() { return getBoolean(verbose); } public void setVerbose(boolean v) { setBoolean(verbose, v); } /** * Contents of the last request (i.e. request sent by Plexus side). */ public static final Property lastRequest = newProperty(0, new BStatusString()); public BStatusString getLastRequest() { return (BStatusString)get(lastRequest); } public void setLastRequest(BStatusString v) { set(lastRequest, v); } /** * Contents of the last response (i.e. reply send by this class). */ public static final Property lastResponse = newProperty(0, new BStatusString()); public BStatusString getLastResponse() { return (BStatusString)get(lastResponse); } public void setLastResponse(BStatusString v) { set(lastResponse, v); } public static final Type TYPE = Sys.loadType(BReceiver.class); public Type getType() { return TYPE; } } Node-path: niagara/korsPlexus/src/com/korsengineering/niagara/plexus/BRepeater.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 5465 Text-content-md5: 730be54e172e95cbb79bf829e4414920 Text-content-sha1: f9057ca00fc12f62ad11de47d2efe7d79f7b9677 Content-length: 5475 PROPS-END /* * BPlexusRepeater.java * * Created on May 10, 2007, 1:12 PM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package com.korsengineering.niagara.plexus; import com.korsengineering.http.HttpSender; import javax.baja.security.BPassword; import javax.baja.sys.*; import javax.baja.xml.*; import com.tridium.util.FileLock; import java.io.*; import java.net.*; import javax.baja.naming.SyntaxException; import javax.baja.status.BStatusNumeric; import javax.baja.status.BStatusString; /** * This class tries-to resend those requests that were attempted earlier by * BPoster, failed due to IO errors, and thus were buffered in plex-buffer.xml. * @author Roman Ivanov */ public class BRepeater extends BComponent{ protected File buffer; protected URL destinationUrl; public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } if (property == destination) { try { destinationUrl = new URL(getDestination().getValue()); } catch (MalformedURLException ex) { throw new SyntaxException(ex); } } } public void started() throws Exception{ buffer = new File(Sys.getStationHome().getAbsolutePath() + "/plex-buffer.xml"); } //public void changed(Property property, Context context){} public static final Action repeat = newAction(0); public void repeat() { invoke(repeat, null); } //invokes /** * This method tries to repeat the request by BPoster that failed earlier. It reads * the information about those request from plex-buffer.xml in the station * home folder. If the request fails again, then fail counter is inremented. * If the counter exceeds the specified value, then the request is deleted * from the file. If the file is corrupt, it is deleted entirely. * @throws Exception */ public void doRepeat() throws Exception{ if (!buffer.exists() || buffer.length() == 0) { return; } FileLock fl = FileLock.lock(buffer); try { XElem root = XParser.make(buffer).parse(); XElem[] errors = root.elems("error"); for (int i = 0; i < errors.length; i++) {//prunning int times = errors[i].geti("times"); if (times >= getDropAfterIOErrors().getValue()) { root.removeContent(errors[i]); } } errors = root.elems("error"); for (int i = 0; i < errors.length; i++) { //sending ByteArrayOutputStream baos = new ByteArrayOutputStream(); XWriter xw = new XWriter(baos); errors[i].content(0).write(xw); xw.flush(); baos.flush(); String xml = baos.toString(); boolean sent = false; //boolean ioError = false; try { String response = HttpSender.send(destinationUrl, getLogin().getValue(), getPassword().getString(), xml); sent = response.indexOf("Success") != -1; } catch (IOException ex) { //ioError = true; sent = false; } if (sent) { root.removeContent(errors[i]); } else { //System.out.println(Integer.toString(errors[i].geti("times"))); errors[i].setAttr("times", Integer.toString(errors[i].geti("times") + 1)); } } root.write(buffer); } catch (XException ex) { buffer.delete(); throw ex; } finally { fl.unlock(); } } public static final Property destination = newProperty(Flags.SUMMARY, new BStatusString()); public BStatusString getDestination() { return (BStatusString) get(destination); } public void setDestination(BStatusString v) { set(destination, v); } public static final Property login = newProperty(Flags.SUMMARY, new BStatusString()); public BStatusString getLogin() { return (BStatusString) get(login); } public void setLogin(BStatusString v) { set(login, v); } public static final Property password = newProperty(Flags.SUMMARY, BPassword.DEFAULT); public BPassword getPassword() { return (BPassword) get(password); } public void setPassword(BPassword v) { set(password, v); } /** * The number of attempts this class should make to re-send the request * before dropping it. */ public static final Property dropAfterIOErrors = newProperty(0, new BStatusNumeric(5)); public BStatusNumeric getDropAfterIOErrors() { return (BStatusNumeric) get(dropAfterIOErrors); } public void setDropAfterIOErrors(BStatusNumeric v) { set(dropAfterIOErrors, v); } public static final Type TYPE = Sys.loadType(BRepeater.class); public Type getType() { return TYPE; } } Node-path: niagara/korsPlexus/src/com/korsengineering/niagara/plexus/BScrap.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 728 Text-content-md5: ee6e0531364cfc434c091fc5ee353bff Text-content-sha1: 6681b4e82828b50ddcec1867ab7faec7bd749e35 Content-length: 738 PROPS-END package com.korsengineering.niagara.plexus; import javax.baja.status.BStatusString; import javax.baja.sys.Flags; import javax.baja.sys.Property; import javax.baja.sys.Sys; import javax.baja.sys.Type; public class BScrap extends BPoster{ public String getAction(){ return "Scrap"; } public static final Property scrap = newProperty(Flags.SUMMARY | Flags.USER_DEFINED_1, new BStatusString()); public BStatusString getScrap() { return (BStatusString) get(scrap); } public void setScrap(BStatusString v) { set(scrap, v); } public static final Type TYPE = Sys.loadType(BScrap.class); public Type getType() { return TYPE; } } Node-path: niagara/korsPlexus/src/com/korsengineering/niagara/plexus/test Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsPlexus/src/com/korsengineering/niagara/plexus/test/Tester.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 589 Text-content-md5: d7c0b85d7c5287d401f0032b3e758c98 Text-content-sha1: d2506b58dded9cb2ad0bfaf70e5df52d82ae161b Content-length: 599 PROPS-END package com.korsengineering.niagara.plexus.test; import com.korsengineering.http.*; import java.net.URL; public class Tester { public static void main(String[] args) throws Exception{ System.out.println("Beginning sending..."); URL dest = new URL("http://127.0.0.1:302/test"); String xml = "Press17Start1"; String response = HttpSender.send(dest, "KorsWS@plex.com", "3reJUpudcc", xml); System.out.println("Response: " + response); } } Node-path: niagara/korsPlexus/src/com/korsengineering/niagara/printing Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsPlexus/src/com/korsengineering/niagara/printing/BPrinter.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 3461 Text-content-md5: 5a82fb600b056ebe12693e3635ad5a68 Text-content-sha1: 1561b3bdcb07281bd05ffa53e89d7e3b99d830a6 Content-length: 3471 PROPS-END package com.korsengineering.niagara.printing; import java.io.*; import javax.baja.status.BStatusString; import javax.baja.sys.Action; import javax.baja.sys.BComponent; import javax.baja.sys.Flags; import javax.baja.sys.Property; import javax.baja.sys.Sys; import javax.baja.sys.Type; import javax.print.*; import javax.print.attribute.*; import javax.print.attribute.standard.*; import javax.print.attribute.AttributeSetUtilities.*; import javax.baja.status.BStatusString; import javax.baja.sys.Flags; import javax.baja.sys.Property; import javax.baja.sys.Sys; import javax.baja.sys.Type; import com.korsengineering.niagara.plexus.BScrap; import java.net.*; public class BPrinter extends BComponent{ public static boolean printSomething (String pName, byte[] pArray){ boolean bResult = false; String sPrinterName = null; PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null); for (int i = 0; i < services.length; i++) { PrintServiceAttribute attr = services[i].getAttribute(PrinterName.class); sPrinterName = ((PrinterName)attr).getValue(); if (sPrinterName.indexOf(pName)>=0){ System.out.println("Found printer: " + sPrinterName ); //found printer, now send byte array to it try { DocPrintJob job = services[i].createPrintJob(); DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE; Doc doc = new SimpleDoc(pArray, flavor, null); job.print(doc, null); bResult = true; } catch (PrintException e) { e.printStackTrace(); } } else { System.out.println("not printer: " + sPrinterName ); } } System.out.println("Finshed\n"); return bResult; } public String getAction(){ return "PrintString"; } public void doPrintString() { //attempt to send input string to partial printer name BStatusString inp = getPrintString(); BStatusString prt = getPrinterName(); if(prt.toString().length()>0) { //have a printer name, now check string if (inp.getValue().length()>0) { boolean pf = printSomething(prt.getValue(),inp.getValue().getBytes()); } } } public static final Action PrintString = newAction(0); public void PrintString() { invoke(PrintString, null); } public static final Property printString = newProperty (Flags.SUMMARY , new BStatusString()); public BStatusString getPrintString() { return (BStatusString) get(printString); } public void setPrintString(BStatusString v) { set(printString, v); } public static final Property printerName = newProperty (Flags.SUMMARY , new BStatusString()); public BStatusString getPrinterName() { return (BStatusString) get(printerName); } public void setPrinterName(BStatusString v) { set(printerName, v); } public static final Type TYPE = Sys.loadType(BPrinter.class); public Type getType() { return TYPE; } } Node-path: niagara/korsPlexus/src/com/korsengineering/niagara/shape Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsPlexus/src/com/korsengineering/niagara/utils Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsPlexus/src/com/korsengineering/niagara/utils/time Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsPlexus/src/com/korsengineering/niagara/utils/time/BTimestamp.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 1237 Text-content-md5: b223ac2dfe00b191765677c45134a566 Text-content-sha1: c4120161ac5e0dfd10275db96ff455d617847757 Content-length: 1247 PROPS-END package com.korsengineering.niagara.utils.time; import javax.baja.sys.Action; import javax.baja.sys.BAbsTime; import javax.baja.sys.BComponent; import javax.baja.sys.Flags; import javax.baja.sys.Property; import javax.baja.sys.Sys; import javax.baja.sys.Type; public class BTimestamp extends BComponent{ public static final Property text = newProperty(Flags.SUMMARY | Flags.READONLY, ""); public String getText() { return getString(text); } public void setText(String v) { setString(text, v); } public static final Property time = newProperty(Flags.SUMMARY | Flags.READONLY, BAbsTime.make(0)); public BAbsTime getTime() { return (BAbsTime) get(time); } public void setTime(BAbsTime v) { set(time, v); } public static final Action stamp = newAction(0); public void stamp() { invoke(stamp, null); } //invokes public void doStamp() throws Exception{ BAbsTime now = BAbsTime.now(); setTime(now); setText(now.encodeToString()); } public static final Type TYPE = Sys.loadType(BTimestamp.class); public Type getType() { return TYPE; } } Revision-number: 2 Prop-content-length: 99 Content-length: 99 K 7 svn:log V 0 K 10 svn:author V 5 roman K 8 svn:date V 27 2008-02-22T22:06:14.255547Z PROPS-END Node-path: niagara/korsNotification/src/com/korsengineering/niagara/notification/BPathNotif.java Node-kind: file Node-action: change Text-content-length: 311 Text-content-md5: a751655bb06f5599d967bd74c980e951 Text-content-sha1: 53e034031fa7ee8e41901622e4dd62f0109fa37e Content-length: 311 package com.korsengineering.niagara.notification; import javax.baja.sys.Sys; import javax.baja.sys.Type; import javax.baja.util.BNotification; public class BPathNotif extends BNotification{ public Type getType() { return TYPE; } public static final Type TYPE = Sys.loadType(BPathNotif.class); } Revision-number: 3 Prop-content-length: 98 Content-length: 98 K 7 svn:log V 0 K 10 svn:author V 4 nate K 8 svn:date V 27 2008-02-25T18:48:41.137035Z PROPS-END Node-path: niagara/korsMaster/src/com/korsengineering/niagara/XML/BXMLTextFormatter.java Node-kind: file Node-action: change Text-content-length: 4341 Text-content-md5: 299275ca8a7c803befc52a1d3868cbad Text-content-sha1: 0e8699953fb2295cf52a68fb842206c924af5ccd Content-length: 4341 //test package com.korsengineering.niagara.XML; import javax.baja.status.*; import javax.baja.sys.*; import javax.baja.control.*; import javax.baja.xml.*; public class BXMLTextFormatter extends BComponent{ public String strIn, strCON, strOut; public int depthCount; public boolean tagStart, tagText; public XParser pointer; public void changed(Property property, Context context){ super.changed(property, context); if (property == xmlIn){ strCON = ""; depthCount = 0; tagStart = tagText = false; strIn = getXmlIn().getValue(); try { pointer = XParser.make(strIn); } catch (Exception ex) { ex.printStackTrace(); } try { if (pointer.next() != XParser.EOF) { conStr(pointer.elem().toString(), 0); depthCount = pointer.depth(); } while (pointer.next() != XParser.EOF){ if (pointer.depth() > depthCount) { tagStart = true; doStartTag(true); } if (pointer.depth() < depthCount) { tagStart = tagText = false; doEndTag(true); } if (pointer.depth() == depthCount) { if (!tagStart) { doStartTag(false); tagStart = true; } else { if (!tagText) { doText(); tagText = true; } else { doEndTag(false); tagStart = tagText = false; } } } depthCount = pointer.depth(); } } catch (Exception ex) { System.out.println(BAbsTime.now().toString() + ": Kors Component Error at " + this.getSlotPath().toString() + ":" + ex.toString()); ex.printStackTrace(); } setTextOut(strCON); setXmlOut(new BStatusString(strCON)); } } public void doStartTag(boolean doReturn) { if (doReturn) doReturn(); conStr("<" + pointer.elem().name() + ">", pointer.depth()); } public void doText() { conStr("" + pointer.text(), 0); } public void doEndTag(boolean space) { if (space) { conStr("", pointer.depth()); } else { conStr("", 0); } doReturn(); } public void conStr(String strAdd, int spaceCount){ String Space = ""; if (spaceCount > 0){ for (int x = 1; x < spaceCount; ++x){ Space = Space.concat(" "); } strCON = strCON.concat(Space); } strCON = strCON.concat(strAdd); } public void doReturn(){ strCON = strCON.concat("\r"); } public static final Property xmlIn = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property xmlOut = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property textOut = newProperty(Flags.SUMMARY, ""); public BStatusString getXmlIn() { return (BStatusString)get(xmlIn); } public BStatusString getXmlOut() { return (BStatusString)get(xmlOut); } public String getTextOut() { return getString(textOut); } public void setXmlIn(BStatusString v) { set(xmlIn, v); } public void setXmlOut(BStatusString v) { set(xmlOut, v); } public void setTextOut(String v) { setString(textOut, v); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BXMLTextFormatter.class); public Type getType() { return TYPE; } } Revision-number: 4 Prop-content-length: 98 Content-length: 98 K 7 svn:log V 0 K 10 svn:author V 4 nate K 8 svn:date V 27 2008-02-25T19:24:02.425409Z PROPS-END Node-path: niagara/korsMaster/module-include.xml Node-kind: file Node-action: change Text-content-length: 2103 Text-content-md5: f7a01e05b41dbf040d076bebaa7c66b4 Text-content-sha1: 06be26927914584f129b83fc8ee452c9b3166506 Content-length: 2103 Node-path: niagara/korsMaster/module.palette Node-kind: file Node-action: change Text-content-length: 1913 Text-content-md5: 62da935ed52247098a83d65f0b405715 Text-content-sha1: d91308fd8a2cfa8bf29dc1913410ae17a68067f5 Content-length: 1913

Node-path: niagara/korsMaster/src/com/korsengineering/niagara/XML/BXMLTextFormatter.java Node-kind: file Node-action: change Text-content-length: 4333 Text-content-md5: 68108180f61f3ab687b95531ff1c770c Text-content-sha1: 562f4857f82f7e3b13c83e5ccd2a1134f0973c17 Content-length: 4333 package com.korsengineering.niagara.XML; import javax.baja.status.*; import javax.baja.sys.*; import javax.baja.control.*; import javax.baja.xml.*; public class BXMLTextFormatter extends BComponent{ public String strIn, strCON, strOut; public int depthCount; public boolean tagStart, tagText; public XParser pointer; public void changed(Property property, Context context){ super.changed(property, context); if (property == xmlIn){ strCON = ""; depthCount = 0; tagStart = tagText = false; strIn = getXmlIn().getValue(); try { pointer = XParser.make(strIn); } catch (Exception ex) { ex.printStackTrace(); } try { if (pointer.next() != XParser.EOF) { conStr(pointer.elem().toString(), 0); depthCount = pointer.depth(); } while (pointer.next() != XParser.EOF){ if (pointer.depth() > depthCount) { tagStart = true; doStartTag(true); } if (pointer.depth() < depthCount) { tagStart = tagText = false; doEndTag(true); } if (pointer.depth() == depthCount) { if (!tagStart) { doStartTag(false); tagStart = true; } else { if (!tagText) { doText(); tagText = true; } else { doEndTag(false); tagStart = tagText = false; } } } depthCount = pointer.depth(); } } catch (Exception ex) { System.out.println(BAbsTime.now().toString() + ": Kors Component Error at " + this.getSlotPath().toString() + ":" + ex.toString()); ex.printStackTrace(); } setTextOut(strCON); setXmlOut(new BStatusString(strCON)); } } public void doStartTag(boolean doReturn) { if (doReturn) doReturn(); conStr("<" + pointer.elem().name() + ">", pointer.depth()); } public void doText() { conStr("" + pointer.text(), 0); } public void doEndTag(boolean space) { if (space) { conStr("", pointer.depth()); } else { conStr("", 0); } doReturn(); } public void conStr(String strAdd, int spaceCount){ String Space = ""; if (spaceCount > 0){ for (int x = 1; x < spaceCount; ++x){ Space = Space.concat(" "); } strCON = strCON.concat(Space); } strCON = strCON.concat(strAdd); } public void doReturn(){ strCON = strCON.concat("\r"); } public static final Property xmlIn = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property xmlOut = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property textOut = newProperty(Flags.SUMMARY, ""); public BStatusString getXmlIn() { return (BStatusString)get(xmlIn); } public BStatusString getXmlOut() { return (BStatusString)get(xmlOut); } public String getTextOut() { return getString(textOut); } public void setXmlIn(BStatusString v) { set(xmlIn, v); } public void setXmlOut(BStatusString v) { set(xmlOut, v); } public void setTextOut(String v) { setString(textOut, v); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BXMLTextFormatter.class); public Type getType() { return TYPE; } } Node-path: niagara/korsMaster/src/com/korsengineering/niagara/math/BModulo.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 1756 Text-content-md5: f6651d9f03d0aa7cba27e348e5abdae9 Text-content-sha1: 527a6a0e2bff4238f2c818dbbd3329acbfb38097 Content-length: 1766 PROPS-END package com.korsengineering.niagara.math; import javax.baja.sys.*; import javax.baja.status.*; public class BModulo extends BComponent{ public void started(){ } public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } if (property == getProperty("dividend")){ if(getDivisor().getValue()>0){ getRemainder().setValue(getDividend().getValue()%getDivisor().getValue()); } else{ getRemainder().setValue(0); } } } /**The dividend*/ public static final Property dividend = newProperty(Flags.SUMMARY, new BStatusNumeric()); public void setDividend(BStatusNumeric v) { set(dividend, v); } public BStatusNumeric getDividend() { return (BStatusNumeric)get(dividend); } /**The divisor*/ public static final Property divisor = newProperty(Flags.SUMMARY, new BStatusNumeric()); public void setDivisor(BStatusNumeric v) { set(divisor, v); } public BStatusNumeric getDivisor() { return (BStatusNumeric)get(divisor); } /**The remainder*/ public static final Property remainder = newProperty(Flags.SUMMARY, new BStatusNumeric()); public void setRemainder(BStatusNumeric v) { set(remainder, v); } public BStatusNumeric getRemainder() { return (BStatusNumeric)get(remainder); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BModulo.class); public Type getType() { return TYPE; } } Revision-number: 5 Prop-content-length: 99 Content-length: 99 K 7 svn:log V 0 K 10 svn:author V 5 roman K 8 svn:date V 27 2008-03-04T18:52:03.965342Z PROPS-END Node-path: niagara/korsPlexusWs Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsPlexusWs/src Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsPlexusWs/src/com Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsPlexusWs/src/com/korsengineering Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsPlexusWs/src/com/korsengineering/niagara Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsPlexusWs/src/com/korsengineering/niagara/plexus Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsPlexusWs/src/com/korsengineering/niagara/plexus/ws Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: niagara/korsPlexusWs/src/com/korsengineering/niagara/plexus/ws/BRecordProduction.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 8645 Text-content-md5: f49e85d40daf753b8f15ebc1f37b7ee2 Text-content-sha1: ec4174d31efda5c97bb5496e15967e79afe4fc48 Content-length: 8655 PROPS-END package com.korsengineering.niagara.plexus.ws; import java.net.Authenticator; import java.net.PasswordAuthentication; import java.net.URL; import java.util.NoSuchElementException; import javax.baja.io.Base64; import javax.baja.status.BStatusBoolean; import javax.baja.status.BStatusNumeric; import javax.baja.status.BStatusString; import javax.baja.sys.Action; import javax.baja.sys.BComponent; import javax.baja.sys.BajaRuntimeException; import javax.baja.sys.Context; import javax.baja.sys.Flags; import javax.baja.sys.Property; import javax.baja.sys.Sys; import javax.baja.sys.Type; import javax.xml.namespace.QName; import javax.xml.soap.MessageFactory; import javax.xml.soap.MimeHeaders; import javax.xml.soap.SOAPBody; import javax.xml.soap.SOAPConstants; import javax.xml.soap.SOAPElement; import javax.xml.soap.SOAPEnvelope; import javax.xml.soap.SOAPHeader; import javax.xml.soap.SOAPMessage; import javax.xml.soap.SOAPPart; import javax.xml.ws.Dispatch; import javax.xml.ws.Service; import javax.xml.ws.soap.SOAPBinding; public class BRecordProduction extends BComponent{ boolean lastTriggerSendState = false; public void changed(Property property, Context context){ super.changed(property, context); if (property == triggerSend && Sys.atSteadyState()) { try { if (getTriggerSend().getValue() && (lastTriggerSendState == false)) { doSend(); } } catch (Exception ex) { throw new BajaRuntimeException(ex); } finally { lastTriggerSendState = getTriggerSend().getValue(); } } } public static final Property triggerSend = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BStatusBoolean getTriggerSend() { return (BStatusBoolean) get(triggerSend); } public void setTriggerSend(BStatusBoolean v) { set(triggerSend, v); } public static final Property inSerialNo = newProperty(Flags.SUMMARY, new BStatusString()); public BStatusString getInSerialNo() { return (BStatusString) get(inSerialNo); } public void setInSerialNo(BStatusString v) { set(inSerialNo, v); } public static final Property inPLCName = newProperty(Flags.SUMMARY, new BStatusString()); public BStatusString getInPLCName() { return (BStatusString) get(inPLCName); } public void setInPLCName(BStatusString v) { set(inPLCName, v); } public static final Property inIPAddress = newProperty(Flags.SUMMARY, new BStatusString()); public BStatusString getInIPAddress() { return (BStatusString) get(inIPAddress); } public void setInIPAddress(BStatusString v) { set(inIPAddress, v); } public static final Property outResult = newProperty(Flags.SUMMARY, new BStatusString()); public BStatusString getOutResult() { return (BStatusString) get(outResult); } public void setOutResult(BStatusString v) { set(outResult, v); } public static final Property inEndpoint = newProperty(0, new BStatusString()); public BStatusString getInEndpoint() { return (BStatusString) get(inEndpoint); } public void setInEndpoint(BStatusString v) { set(inEndpoint, v); } public static final Property inWsdl = newProperty(0, new BStatusString()); public BStatusString getInWsdl() { return (BStatusString) get(inWsdl); } public void setInWsdl(BStatusString v) { set(inWsdl, v); } public static final Property outResponse = newProperty(Flags.SUMMARY, new BStatusString()); public BStatusString getOutResponse() { return (BStatusString) get(outResponse); } public void setOutResponse(BStatusString v) { set(outResponse, v); } public static final Property outError = newProperty(Flags.SUMMARY, new BStatusBoolean()); public BStatusBoolean getOutError() { return (BStatusBoolean) get(outError); } public void setOutError(BStatusBoolean v) { set(outError, v); } public static final Property outErrorNo = newProperty(Flags.SUMMARY, new BStatusNumeric()); public BStatusNumeric getOutErrorNo() { return (BStatusNumeric) get(outErrorNo); } public void setOutErrorNo(BStatusNumeric v) { set(outErrorNo, v); } public static final Property outErrorMessage = newProperty(Flags.SUMMARY, new BStatusString()); public BStatusString getOutErrorMessage() { return (BStatusString) get(outErrorMessage); } public void setOutErrorMessage(BStatusString v) { set(outErrorMessage, v); } String endpointUrl = "https://hermes.plexus-online.com/Production/Service.asmx"; //String wsdlUrl = "https://hermes.plexus-online.com/Production/Service.asmx?WSDL"; QName serviceName = new QName("http://www.plexus-online.com/Production", "Service"); QName portName = new QName("http://www.plexus-online.com/Production", "RecordProduction"); public static final Action send = newAction(0); public void send(){ invoke(send, null); } //invokes public void doSend() throws Exception{ //URL wsdlLocation = new URL(wsdlUrl); //Service service = Service.create(wsdlLocation, serviceName); Service service = Service.create(serviceName); service.addPort(portName, SOAPBinding.SOAP12HTTP_BINDING, endpointUrl); Dispatch dispatch = service.createDispatch(portName, SOAPMessage.class, Service.Mode.MESSAGE); MessageFactory mf = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL); // Create a message. This example works with the SOAPPART. SOAPMessage request = mf.createMessage(); MimeHeaders headers = request.getMimeHeaders(); System.out.println(headers.getAllHeaders()); String authCode = Base64.encode(("BatesvilleWS@plex.com" + ":" + "RasWup5s").getBytes()); headers.addHeader("Authorization", "Basic " + authCode); SOAPPart part = request.getSOAPPart(); // Obtain the SOAPEnvelope and header and body elements. SOAPEnvelope env = part.getEnvelope(); SOAPHeader header = env.getHeader(); SOAPBody body = env.getBody(); // Construct the message payload. SOAPElement operation = body.addChildElement(portName); SOAPElement input = operation.addChildElement("RecordProductionInput"); SOAPElement container = input.addChildElement("Container"); container.addChildElement("SerialNo").addTextNode(getInSerialNo().getValue()); SOAPElement workcenter = input.addChildElement("Workcenter"); workcenter.addChildElement("PLCName").addTextNode(getInPLCName().getValue()); workcenter.addChildElement("IPAddress").addTextNode(getInIPAddress().getValue()); request.saveChanges(); SOAPMessage response = dispatch.invoke(request); response.writeTo(System.out); SOAPElement rpr = (SOAPElement) response.getSOAPBody().getChildElements(new QName("http://www.plexus-online.com/Production", "RecordProductionResponse")).next(); SOAPElement rpres = (SOAPElement) rpr.getChildElements(new QName("http://www.plexus-online.com/Production","RecordProductionResult")).next(); try { String error = ((SOAPElement) rpres.getChildElements(new QName("http://www.plexus-online.com/Production", "Error")).next()).getTextContent(); String errorNo = ((SOAPElement) rpres.getChildElements(new QName("http://www.plexus-online.com/Production", "ErrorNo")).next()).getTextContent(); String message = ((SOAPElement) rpres.getChildElements(new QName("http://www.plexus-online.com/Production", "Message")).next()).getTextContent(); setOutError(new BStatusBoolean(true)); setOutErrorNo(new BStatusNumeric(Integer.valueOf(errorNo))); setOutErrorMessage(new BStatusString(message)); return; } catch (NoSuchElementException e) { //do nothing } setOutError(new BStatusBoolean(false)); setOutErrorNo(new BStatusNumeric(0)); setOutErrorMessage(new BStatusString("")); SOAPElement label = (SOAPElement) rpres.getChildElements(new QName("http://www.plexus-online.com/Production","Label")).next(); setOutResult(new BStatusString(label.getTextContent())); } public static final Type TYPE = Sys.loadType(BRecordProduction.class); public Type getType() { return TYPE; } } Revision-number: 6 Prop-content-length: 99 Content-length: 99 K 7 svn:log V 0 K 10 svn:author V 5 roman K 8 svn:date V 27 2008-03-04T19:07:40.603721Z PROPS-END Node-path: niagara/korsPlexusWs/build.xml Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 343 Text-content-md5: d44e73cc74ef1591d840376c38cbd19f Text-content-sha1: 332afceeb1f3385657c71bd6d1a7f222769630eb Content-length: 353 PROPS-END Node-path: niagara/korsPlexusWs/module-include.xml Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 116 Text-content-md5: ea768cd1a6a3d24ce1582d0ee9a24d39 Text-content-sha1: 004ce5e31bf02b64f8eea1712016354269787924 Content-length: 126 PROPS-END Node-path: niagara/korsPlexusWs/module.palette Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 192 Text-content-md5: 04fb005f74b879bdef4bb90de7bb42b5 Text-content-sha1: bbad74026cf5aab2d62710ccd18276fa66dea271 Content-length: 202 PROPS-END

Revision-number: 7 Prop-content-length: 143 Content-length: 143 K 7 svn:log V 44 Added tempwrite boolean and tempwrite string K 10 svn:author V 4 mike K 8 svn:date V 27 2008-03-06T17:19:36.291591Z PROPS-END Node-path: niagara/korsMaster/src/com/korsengineering/niagara/timer/BTempWriteBoolean.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 3615 Text-content-md5: 76aabcfeb9ed2b037abe6e356c0d30c9 Text-content-sha1: 7f2e6684f00708c37a67270af0dc5ba0119fa255 Content-length: 3625 PROPS-END package com.korsengineering.niagara.timer; import javax.baja.status.*; import javax.baja.sys.*; import java.util.*; public class BTempWriteBoolean extends BComponent{ boolean fired = false; Clock.Ticket ticket; public void started(){ doSetNull(); } void updateTimer(){ if (ticket != null) ticket.cancel(); ticket = Clock.schedule(this, getWriteDuration(), setNull, null); } public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } if (property == trigger){ //System.out.println(this.asComponent().getNavName() + ':' + getTrigger().getBoolean() + ':' + fired ); if (getTrigger().getValue() && fired == false){ fired = true; getOutput().setValue(getInput().getValue()); getOutput().setStatusNull(false); updateTimer(); } else { fired = false; } } } public void doSetNull(){ this.getOutput().setStatusNull(true); } public void doSetWriteTime(BInteger i){ setWriteDuration(BRelTime.makeSeconds(i.getInt())); } public void doWriteThisValue(BBoolean i){ getOutput().setValue(i.getBoolean()); this.getOutput().setStatusNull(false); updateTimer(); } // public BValue getActionParameterDefault(Action action) { // if (action == BTempWrite.writeThisValue) { // return getInput().asValue(); // } else { // return action.getParameterDefault(); // } // } public static final Action setWriteTime = newAction(0, BInteger.make(1)); public static final Action writeThisValue = newAction(0,BBoolean.make(true)); public static final Action setNull = newAction(0); public static final Property input = newProperty(Flags.SUMMARY, new BStatusBoolean()); public static final Property output = newProperty(Flags.SUMMARY, new BStatusBoolean()); public static final Property writeDuration = newProperty(Flags.SUMMARY, BRelTime.DEFAULT); public BStatusBoolean getInput() { return (BStatusBoolean)get(input); } public BStatusBoolean getOutput() { if (ticket != null){ return (BStatusBoolean)get(output); } else{ return (new BStatusBoolean()); } } public BRelTime getWriteDuration() { return (BRelTime)get(writeDuration); } public void setInput(BStatusBoolean v) { set(input, v); } public void setOutput(BStatusBoolean v) { set(output, v); } public void setWriteDuration(BRelTime v) { set(writeDuration, v); } public void setWriteTime(BInteger x) { invoke(setWriteTime, x, null); } public void writeThisValue( BBoolean now) { invoke(writeThisValue, now, null); } public void setNull(){ invoke(setNull,null,null); } public static final Property trigger = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BStatusBoolean getTrigger() { return (BStatusBoolean)get(trigger); } public void setTrigger(BStatusBoolean v) { set(trigger, v); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BTempWriteBoolean.class); public Type getType() { return TYPE; } } Node-path: niagara/korsMaster/src/com/korsengineering/niagara/timer/BTempWriteString.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 3598 Text-content-md5: aeca14ce2a7a1ba3df224b37216248c0 Text-content-sha1: dc1024f3a62e6085ebc15bcfa5ca0c34e919d5ce Content-length: 3608 PROPS-END package com.korsengineering.niagara.timer; import javax.baja.status.*; import javax.baja.sys.*; import java.util.*; public class BTempWriteString extends BComponent{ boolean fired = false; Clock.Ticket ticket; public void started(){ doSetNull(); } void updateTimer(){ if (ticket != null) ticket.cancel(); ticket = Clock.schedule(this, getWriteDuration(), setNull, null); } public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } if (property == trigger){ //System.out.println(this.asComponent().getNavName() + ':' + getTrigger().getBoolean() + ':' + fired ); if (getTrigger().getValue() && fired == false){ fired = true; getOutput().setValue(getInput().getValue()); getOutput().setStatusNull(false); updateTimer(); } else { fired = false; } } } public void doSetNull(){ this.getOutput().setStatusNull(true); } public void doSetWriteTime(BInteger i){ setWriteDuration(BRelTime.makeSeconds(i.getInt())); } public void doWriteThisValue(BString i){ getOutput().setValue(i.getString()); this.getOutput().setStatusNull(false); updateTimer(); } // public BValue getActionParameterDefault(Action action) { // if (action == BTempWrite.writeThisValue) { // return getInput().asValue(); // } else { // return action.getParameterDefault(); // } // } public static final Action setWriteTime = newAction(0, BInteger.make(1)); public static final Action writeThisValue = newAction(0,BString.make("")); public static final Action setNull = newAction(0); public static final Property input = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property output = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property writeDuration = newProperty(Flags.SUMMARY, BRelTime.DEFAULT); public BStatusString getInput() { return (BStatusString)get(input); } public BStatusString getOutput() { if (ticket != null){ return (BStatusString)get(output); } else{ return (new BStatusString()); } } public BRelTime getWriteDuration() { return (BRelTime)get(writeDuration); } public void setInput(BStatusString v) { set(input, v); } public void setOutput(BStatusString v) { set(output, v); } public void setWriteDuration(BRelTime v) { set(writeDuration, v); } public void setWriteTime(BInteger x) { invoke(setWriteTime, x, null); } public void writeThisValue( BString now) { invoke(writeThisValue, now, null); } public void setNull(){ invoke(setNull,null,null); } public static final Property trigger = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BStatusBoolean getTrigger() { return (BStatusBoolean)get(trigger); } public void setTrigger(BStatusBoolean v) { set(trigger, v); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BTempWriteString.class); public Type getType() { return TYPE; } } Revision-number: 8 Prop-content-length: 130 Content-length: 130 K 7 svn:log V 31 added two new tempwrite objects K 10 svn:author V 4 mike K 8 svn:date V 27 2008-03-06T17:20:13.823781Z PROPS-END Node-path: niagara/korsMaster/module.palette Node-kind: file Node-action: change Text-content-length: 2065 Text-content-md5: 751739ff57a51ad5534e71528788faf8 Text-content-sha1: c5462916570e4f84ffb67060b9737b98d152f757 Content-length: 2065

Revision-number: 9 Prop-content-length: 130 Content-length: 130 K 7 svn:log V 31 added two new tempwrite objects K 10 svn:author V 4 mike K 8 svn:date V 27 2008-03-06T17:21:08.083042Z PROPS-END Node-path: niagara/korsMaster/module-include.xml Node-kind: file Node-action: change Text-content-length: 2308 Text-content-md5: c6929f65bd549f0e2231cdedb2a10652 Text-content-sha1: 5712334ec2a92e054b1e93716934cc1e000459ac Content-length: 2308 Revision-number: 10 Prop-content-length: 99 Content-length: 99 K 7 svn:log V 0 K 10 svn:author V 5 roman K 8 svn:date V 27 2008-03-06T19:03:56.303147Z PROPS-END Node-path: niagara/korsNotification/src/com/korsengineering/niagara/notification/BPathNotifHandler.java Node-kind: file Node-action: change Text-content-length: 3001 Text-content-md5: e611a0932546f84e94a1879c8ad684a5 Text-content-sha1: 7868ab85ee0b3f9ab662b18a354fccfd268580f6 Content-length: 3001 package com.korsengineering.niagara.notification; import javax.baja.gx.BImage; import javax.baja.sys.BString; import javax.baja.sys.BajaRuntimeException; import javax.baja.sys.Context; import javax.baja.sys.Sys; import javax.baja.sys.Type; import javax.baja.ui.BButton; import javax.baja.ui.BDialog; import javax.baja.ui.BLabel; import javax.baja.ui.BWidget; import javax.baja.ui.Command; import javax.baja.ui.CommandArtifact; import javax.baja.ui.enums.BHalign; import javax.baja.ui.enums.BValign; import javax.baja.ui.pane.BBorderPane; import javax.baja.ui.pane.BGridPane; import javax.baja.ui.util.UiLexicon; import javax.baja.util.BNotification; import javax.baja.util.Lexicon; import javax.baja.workbench.BWbShell; import javax.baja.workbench.util.BNotificationHandler; import com.tridium.ui.theme.Theme; public class BPathNotifHandler extends BNotificationHandler{ public void handle(BWbShell shell, BNotification notify, Context cx) { if (!(notify instanceof BPathNotif)) { throw new BajaRuntimeException("Invalid notification type"); } String sourcePath = ((BString) notify.get("path")).getString().replaceFirst(".*:", ""); String currentPath = shell.getActiveOrd().encodeToString().replaceFirst(".*:", ""); if (!(sourcePath.startsWith(currentPath + "/") || sourcePath.equals(currentPath))) { return; } BImage icon = BImage.make("module://icons/x32/warning.png"); BString t = (BString) notify.get("title"); BString m = (BString) notify.get("message"); Lexicon lex = Lexicon.make("workbench", cx); String title = (t != null) ? t.getString() : lex.getText("notify.handler.notification"); String msg = (m != null) ? m.getString() : lex.getText("notify.handler.unknown"); BGridPane grid1 = new BGridPane(1); grid1.add(null, new BLabel(title, Theme.widget().getBoldText())); grid1.add(null, new BLabel(msg + "\n"+"Source path " + sourcePath+"\n"+"Current path " + currentPath, BHalign.left)); BGridPane grid2 = new BGridPane(2); grid2.setColumnGap(10); grid2.setRowAlign(BValign.top); grid2.add(null, new BLabel(icon)); grid2.add(null, grid1); OkCommand ok = new OkCommand(shell); BGridPane grid3; grid3 = new BGridPane(1); grid3.add(null, new BButton(ok)); BGridPane grid4 = new BGridPane(1); grid4.setRowGap(15); grid4.setColumnAlign(BHalign.center); grid4.add(null, grid2); grid4.add(null, grid3); BBorderPane pane = new BBorderPane(grid4); BDialog dlg = new BDialog(shell, title, true, pane); ok.dlg = dlg; dlg.setBoundsCenteredOnOwner(); dlg.open(); } static class OkCommand extends Command { public OkCommand(BWidget owner) { super(owner, UiLexicon.bajaui.getText("action.ok")); } public CommandArtifact doInvoke() { dlg.close(); return null; } BDialog dlg; } public Type getType() { return TYPE; } public static final Type TYPE = Sys.loadType(BPathNotifHandler.class); } Revision-number: 11 Prop-content-length: 99 Content-length: 99 K 7 svn:log V 0 K 10 svn:author V 5 roman K 8 svn:date V 27 2008-03-06T19:10:05.425089Z PROPS-END Node-path: niagara/korsNotification/.classpath Node-action: delete Revision-number: 12 Prop-content-length: 99 Content-length: 99 K 7 svn:log V 0 K 10 svn:author V 5 roman K 8 svn:date V 27 2008-03-06T19:13:39.486052Z PROPS-END Node-path: niagara/korsNotification/.settings/org.eclipse.jdt.core.prefs Node-action: delete Node-path: niagara/korsNotification/.settings/org.eclipse.jdt.ui.prefs Node-action: delete Revision-number: 13 Prop-content-length: 99 Content-length: 99 K 7 svn:log V 0 K 10 svn:author V 5 roman K 8 svn:date V 27 2008-03-06T19:14:33.060092Z PROPS-END Node-path: niagara/korsNotification/.settings Node-action: delete Revision-number: 14 Prop-content-length: 99 Content-length: 99 K 7 svn:log V 0 K 10 svn:author V 5 roman K 8 svn:date V 27 2008-03-07T18:48:47.660114Z PROPS-END Node-path: niagara/korsMaster/.project Node-action: delete Node-path: niagara/korsMaster/.classpath Node-action: delete Revision-number: 15 Prop-content-length: 99 Content-length: 99 K 7 svn:log V 0 K 10 svn:author V 5 roman K 8 svn:date V 27 2008-03-07T18:48:53.601827Z PROPS-END Node-path: niagara/korsNotification/.project Node-action: delete Revision-number: 16 Prop-content-length: 99 Content-length: 99 K 7 svn:log V 0 K 10 svn:author V 5 roman K 8 svn:date V 27 2008-03-07T18:49:00.774158Z PROPS-END Node-path: niagara/korsOrm/module-include.xml.bak Node-action: delete Node-path: niagara/korsOrm/.project Node-action: delete Node-path: niagara/korsOrm/.settings Node-action: delete Node-path: niagara/korsOrm/.classpath Node-action: delete Revision-number: 17 Prop-content-length: 99 Content-length: 99 K 7 svn:log V 0 K 10 svn:author V 5 roman K 8 svn:date V 27 2008-03-07T18:49:05.731253Z PROPS-END Node-path: niagara/korsPlexus/.settings Node-action: delete Node-path: niagara/korsPlexus/.classpath Node-action: delete Node-path: niagara/korsPlexus/.project Node-action: delete Node-path: niagara/korsPlexus/module.lexicon Node-action: delete Node-path: niagara/korsPlexus/POLtoPLC.txt Node-action: delete Node-path: niagara/korsPlexus/responce.txt Node-action: delete Revision-number: 18 Prop-content-length: 125 Content-length: 125 K 7 svn:log V 26 added select string module K 10 svn:author V 4 mike K 8 svn:date V 27 2008-03-17T22:15:52.021184Z PROPS-END Node-path: niagara/korsMaster/src/com/korsengineering/niagara/list/BSelectString.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 2174 Text-content-md5: 2bec3dce99051632c3628bd12200ff2f Text-content-sha1: 2e535f6366ff1ed97945336b7534ce4611166b3f Content-length: 2184 PROPS-END package com.korsengineering.niagara.list; import javax.baja.status.*; import javax.baja.sys.*; /** * BStringSelect uses a Boolean to switch between two strings. * * @author Mike Arnott */ public class BSelectString extends BComponent { public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } if(getBooleanIn().getValue()){ getStringOut().setValue(getStringInTrue().getValue()); } else{ getStringOut().setValue(getStringInFalse().getValue()); } } //Property Declarations, Gets, and Sets //Enum Input public static final Property booleanIn = newProperty(Flags.SUMMARY, new BStatusBoolean()); /**String Output*/ public static final Property stringOut = newProperty(Flags.SUMMARY, new BStatusString()); /**String Inputs*/ public static final Property stringInTrue = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property stringInFalse = newProperty(Flags.SUMMARY, new BStatusString()); //Get methods public BStatusBoolean getBooleanIn() { return (BStatusBoolean)get(booleanIn); } public BStatusString getStringOut() { return (BStatusString)get(stringOut);} public BStatusString getStringInTrue() { return (BStatusString)get(stringInTrue);} public BStatusString getStringInFalse() { return (BStatusString)get(stringInFalse);} //Set Methods public void setBooleanIn(BStatusBoolean v) { set(booleanIn, v); } public void setStringOut(BStatusString v) {set(stringOut,v);} public void setStringInTrue(BStatusString v) {set(stringInTrue,v);} public void setStringInFalse(BStatusString v) {set(stringInFalse,v);} public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BSelectString.class); public Type getType() { return TYPE; } } Revision-number: 19 Prop-content-length: 98 Content-length: 98 K 7 svn:log V 0 K 10 svn:author V 4 mike K 8 svn:date V 27 2008-03-17T22:16:03.414021Z PROPS-END Node-path: niagara/korsMaster/module.palette Node-kind: file Node-action: change Text-content-length: 2134 Text-content-md5: 4a0d1ecc6d8a03d666bdd535d7e176fb Text-content-sha1: 526dc4a98d82e955a6dfcde5d6b04e86a3ec2064 Content-length: 2134

Revision-number: 20 Prop-content-length: 98 Content-length: 98 K 7 svn:log V 0 K 10 svn:author V 4 mike K 8 svn:date V 27 2008-03-17T22:16:13.218092Z PROPS-END Node-path: niagara/korsMaster/module-include.xml Node-kind: file Node-action: change Text-content-length: 2408 Text-content-md5: 16015c7941dd5b6a55366e99996ebfd4 Text-content-sha1: 54de15800cf18f48c9251b35215ad7a19e234ccc Content-length: 2408 Revision-number: 21 Prop-content-length: 98 Content-length: 98 K 7 svn:log V 0 K 10 svn:author V 4 mike K 8 svn:date V 27 2008-03-18T19:54:18.471826Z PROPS-END Node-path: niagara/korsPlexus/src/com/korsengineering/niagara/plexus/BPoster.java Node-kind: file Node-action: change Text-content-length: 13247 Text-content-md5: 5e81b5ee91b1336b8253b2e578b84c2c Text-content-sha1: 89e6394e557e9a1be5559bd7524c2d2085f54d30 Content-length: 13247 package com.korsengineering.niagara.plexus; import com.korsengineering.http.HttpSender; import java.io.*; import java.net.*; import java.text.SimpleDateFormat; import java.util.Date; import javax.baja.naming.SyntaxException; import javax.baja.security.BPassword; import javax.baja.sys.*; import javax.baja.xml.XElem; import javax.baja.xml.XParser; import com.tridium.util.FileLock; import javax.baja.status.*; import javax.baja.xml.XException; /** * This class models and sends requests to Plexus. All slots that are maked as * "USER_DEFINED_1" in subclasses will be used as fields in the body XML. * @author Roman Ivanov */ public abstract class BPoster extends BComponent{ protected File buffer; protected boolean lastTriggerState = false; protected URL destinationUrl; public void started() throws Exception{ buffer = new File(Sys.getStationHome().getAbsolutePath() + "/plex-buffer.xml"); setGoodTransactions(new BStatusNumeric(0)); setBadTransactions(new BStatusNumeric(0)); } /** * Reacts to changes in destination and trigger slots. */ public void changed(Property property, Context context){ super.changed(property, context); if (property == destination) { try { if (getDestination().getValue().equals("") || getDestination().getValue() == null) { destinationUrl = new URL("http:127.0.0.1"); } else { destinationUrl = new URL(getDestination().getValue()); } } catch (MalformedURLException ex) { throw new SyntaxException(ex); } } else if (property == trigger) { if(!Sys.atSteadyState()){ return; } try { if (getTrigger().getValue() && (lastTriggerState == false)) { //set start time of transaction BAbsTime bt = BAbsTime.now(); doSend(); BRelTime at = bt.delta(BAbsTime.now()); setTimeLastTransaction(new BStatusNumeric(at.getMillis())); } } catch (Exception ex) { throw new BajaRuntimeException(ex); } finally { lastTriggerState = getTrigger().getValue(); } } } //Boilerplate code: /** * URL for the future requests. */ public static final Property destination = newProperty(Flags.SUMMARY, new BStatusString()); public BStatusString getDestination() { return (BStatusString) get(destination); } public void setDestination(BStatusString v) { set(destination, v); } /** * Http login. */ public static final Property login = newProperty(Flags.SUMMARY, new BStatusString()); public BStatusString getLogin() { return (BStatusString) get(login); } public void setLogin(BStatusString v) { set(login, v); } /** * Http password. */ public static final Property password = newProperty(Flags.SUMMARY, BPassword.DEFAULT); public BPassword getPassword() { return (BPassword) get(password); } public void setPassword(BPassword v) { set(password, v); } /** * ID of this machine (for Plexus). */ public static final Property machineId = newProperty(Flags.SUMMARY, new BStatusString()); public BStatusString getMachineId() { return (BStatusString) get(machineId); } public void setMachineId(BStatusString v) { set(machineId, v); } /** * When set to true from false state, triggers doSend(). */ public static final Property trigger = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BStatusBoolean getTrigger() { return (BStatusBoolean) get(trigger); } public void setTrigger(BStatusBoolean v) { set(trigger, v); } /** * Whether re last request was successfull. Account for low-level errors, * as well as responce status from Plexus. */ public static final Property result = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BStatusBoolean getResult() { return (BStatusBoolean) get(result); } public void setResult(BStatusBoolean v) { set(result, v); } /** * Set to true if IO exception was thrown while sending data. */ public static final Property internetFailure = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BStatusBoolean getInternetFailure() { return (BStatusBoolean) get(internetFailure); } public void setInternetFailure(BStatusBoolean v) { set(internetFailure, v); } /** * When set to true, transaction that failed due to low-level errors (IO) * will be buffered in plex-biffer.xml. * @see com.korsengineering.niagara.plexus.BRepeater */ public static final Property useBuffer = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BStatusBoolean getUseBuffer() { return (BStatusBoolean) get(useBuffer); } public void setUseBuffer(BStatusBoolean v) { set(useBuffer, v); } public static final Property verbose = newProperty(0, false); public boolean getVerbose() { return getBoolean(verbose); } public void setVerbose(boolean v) { setBoolean(verbose, v); } public static final Property lastRequest = newProperty(0, new BStatusString()); public BStatusString getLastRequest() { return (BStatusString)get(lastRequest); } public void setLastRequest(BStatusString v) { set(lastRequest, v); } public static final Property lastResponse = newProperty(0, new BStatusString()); public BStatusString getLastResponse() { return (BStatusString)get(lastResponse); } public void setLastResponse(BStatusString v) { set(lastResponse, v); } public static final Property lastSummary = newProperty(0, new BStatusString()); public BStatusString getLastSummary() { return (BStatusString)get(lastSummary); } public void setLastSummary(BStatusString v) { set(lastSummary, v); } public static final Property goodTransactions = newProperty(Flags.SUMMARY, new BStatusNumeric(0)); public BStatusNumeric getGoodTransactions() { return (BStatusNumeric) get(goodTransactions); } public void setGoodTransactions(BStatusNumeric v) { set(goodTransactions, v); } public static final Property badTransactions = newProperty(Flags.SUMMARY, new BStatusNumeric(0)); public BStatusNumeric getBadTransactions() { return (BStatusNumeric) get(badTransactions); } public void setBadTransactions(BStatusNumeric v) { set(badTransactions, v); } private static javax.baja.units.BUnit msecs = javax.baja.units.BUnit.getUnit("millisecond"); public static final Property timeLastTransaction = newProperty(Flags.SUMMARY, new BStatusNumeric(0),BFacets.makeNumeric(msecs, 0)); public BStatusNumeric getTimeLastTransaction() { return (BStatusNumeric) get(timeLastTransaction); } public void setTimeLastTransaction(BStatusNumeric v) { set(timeLastTransaction, v); } protected String getAction(){ return this.getClass().getName().substring(1); } public static final Action send = newAction(0); public void send() { invoke(send, null); } //invokes /** * Generates XML request from the fields of the object, and sends it to * http://www.plexus-online.com/PLC via HttpSender. Sets result slot * appropriately. If the request fails due to IO error and buffering is * enabled, this method buffers the request via addToBuffer(). * @see com.korsengineering.niagara.plexus.BPoster#addToBuffer() * @throws Exception */ public void doSend() throws Exception{ Date now = new Date(); SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy"); SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss"); String xData = ""; String xml = "" + "" + "" + getMachineId().getValue() + "" + "" + getAction() + "" + "" + "" + dateFormat.format(now) + "" + ""; SlotCursor properties = getProperties(); int contentLength = 0; while (properties.next()) { Property property = properties.property(); if (!Flags.isUserDefined1(this, property)) { continue; } String valueString = ""; if (get(property) instanceof BStatusString) { valueString = ((BStatusString) get(property)).getValue(); } else { continue; } String name = property.getName().substring(0, 1).toUpperCase() + property.getName().substring(1); xml += "<"+name+">"+valueString+""; if(xData.length()>0){ xData += ", "; } xData += valueString; contentLength += valueString.length(); } xml += "" + "" + ""; if (getVerbose()) { System.out.println("Request: \n" + xml); } boolean sent = false; String summaryString = ""; setLastRequest(new BStatusString(xml)); if (contentLength>0) { try { String response = HttpSender.send(destinationUrl, getLogin().getValue(), getPassword().getString(), xml); setInternetFailure(new BStatusBoolean(false)); setLastResponse(new BStatusString(response)); if (getVerbose()) { System.out.println("Response: \n" + response); } sent = response.indexOf("0") != -1; setLastResponse(new BStatusString(response)); } catch (IOException ex) { setInternetFailure(new BStatusBoolean(true)); setLastResponse(new BStatusString("Error: " + ex)); addToBuffer(xml, "io"); throw ex; } finally { if (sent) { setGoodTransactions(new BStatusNumeric(getGoodTransactions().getValue() + 1)); summaryString += "At " + dateFormat.format(now) + " " + timeFormat.format(now); summaryString += " Machine " + getMachineId().getValue(); summaryString += " Successfully sent " + getAction(); summaryString += " with values(" + xData + ")"; getLastSummary().setStatus(BStatus.ok); } else { setBadTransactions(new BStatusNumeric(getBadTransactions().getValue() + 1)); summaryString += "At " + dateFormat.format(now) + " " + timeFormat.format(now); summaryString += " Machine " + getMachineId().getValue(); summaryString += " FAILED sending " + getAction(); summaryString += " with values(" + xData + ")"; getLastSummary().setStatus(BStatus.fault); } getLastSummary().setValue(summaryString); setResult(new BStatusBoolean(sent)); } } } /** * Buffers failed requests in plex-buffer.xml file, located in station home folder. * @param value Failed request XML. (Not parsed.) * @param reason Reason of failure. Currently, only "io" is used. * @throws Exception */ public void addToBuffer(String value, String reason) throws Exception{ XElem root = new XElem("buffer"); if (!buffer.exists()) { if (!buffer.createNewFile()) { throw new IOException("Could not create the buffer file"); } } FileLock fl = FileLock.lock(buffer); try { if (buffer.length() != 0) { root = XParser.make(buffer).parse(); } XElem error = new XElem("error"); error.addAttr("times", "1"); error.addAttr("reason", reason); error.addContent(XParser.make(value).parse()); root.addContent(error); root.write(buffer); } catch (XException ex) { buffer.delete(); throw ex; } finally { fl.unlock(); } } public static final Type TYPE = Sys.loadType(BPoster.class); public Type getType() { return TYPE; } } Revision-number: 22 Prop-content-length: 98 Content-length: 98 K 7 svn:log V 0 K 10 svn:author V 4 mike K 8 svn:date V 27 2008-03-26T03:30:10.054218Z PROPS-END Node-path: niagara/korsMaster/src/com/korsengineering/niagara/BQL/BBadOPCPointCount.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 2595 Text-content-md5: c628f6bb14261ceade0a55084be6f4f5 Text-content-sha1: d8cd348ca4ecdbf4857d66a113941e5fd5ff33ed Content-length: 2605 PROPS-END package com.korsengineering.niagara.BQL; import javax.baja.sys.BComponent; import javax.baja.sys.BFacets; import javax.baja.sys.BIcon; import javax.baja.sys.Context; import javax.baja.sys.Cursor; import javax.baja.sys.Flags; import javax.baja.sys.Property; import javax.baja.sys.Sys; import javax.baja.sys.Type; import java.util.*; import javax.baja.status.*; import javax.baja.sys.*; import javax.baja.control.*; import javax.baja.bql.*; import javax.baja.naming.*; import javax.baja.collection.*; import javax.baja.util.*; import com.korsengineering.niagara.timer.BTempWrite; /**Queries for bad opc points relative to the parent folder */ public class BBadOPCPointCount extends BComponent{ public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } if (property == trigger){ String ordPath = "station:|" + this.getSlotPath().toString(); int lastSlash = ordPath.lastIndexOf("/"); ordPath = ordPath.substring(0, lastSlash); ordPath += "|bql:select parent.slotPath as 'Slot Path',tuning.lastReadTime as 'Last Read', parent.status as 'Status' from opc:OpcProxyExt where (parent.status.isStale or parent.status.isDown or parent.status.isFault) and parent.isSubscribed"; System.out.println (ordPath); BOrd ord = BOrd.make(ordPath); BICollection result = (BICollection)ord.resolve().get(); Cursor c = result.cursor(); int rowNum = 0; while (c.next()) { rowNum++; } getBadPoints().setValue(rowNum); } } /* */ public final static Property badPoints = newProperty(Flags.SUMMARY,new BStatusNumeric()); public BStatusNumeric getBadPoints() { return (BStatusNumeric)get(badPoints); } public void setBadPoints(BStatusNumeric v) { set(badPoints, v); } public static final Property trigger = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BStatusBoolean getTrigger() { return (BStatusBoolean)get(trigger); } public void setTrigger(BStatusBoolean v) { set(trigger, v); } public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BBadOPCPointCount.class); public Type getType() { return TYPE; } } Node-path: niagara/korsMaster/src/com/korsengineering/niagara/list/BLatestString.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 6954 Text-content-md5: 8e7bdafd89ea7cb7d7d6f3ef44a7e37f Text-content-sha1: 44d5c89822f269a7a537613907bac3bd1ca831f9 Content-length: 6964 PROPS-END package com.korsengineering.niagara.list; import javax.baja.status.*; import javax.baja.sys.*; /** * BStringSelect uses a Boolean to switch between two strings. * * @author Mike Arnott */ public class BLatestString extends BComponent { public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState()){ return; } if(property == stringIn01){ getStringOut().setValue(getStringIn01().getValue()); } if(property == stringIn02){ getStringOut().setValue(getStringIn02().getValue()); } if(property == stringIn03){ getStringOut().setValue(getStringIn03().getValue()); } if(property == stringIn04){ getStringOut().setValue(getStringIn04().getValue()); } if(property == stringIn05){ getStringOut().setValue(getStringIn05().getValue()); } if(property == stringIn06){ getStringOut().setValue(getStringIn06().getValue()); } if(property == stringIn07){ getStringOut().setValue(getStringIn07().getValue()); } if(property == stringIn08){ getStringOut().setValue(getStringIn08().getValue()); } if(property == stringIn09){ getStringOut().setValue(getStringIn09().getValue()); } if(property == stringIn10){ getStringOut().setValue(getStringIn10().getValue()); } if(property == stringIn11){ getStringOut().setValue(getStringIn11().getValue()); } if(property == stringIn12){ getStringOut().setValue(getStringIn12().getValue()); } if(property == stringIn13){ getStringOut().setValue(getStringIn13().getValue()); } if(property == stringIn14){ getStringOut().setValue(getStringIn14().getValue()); } if(property == stringIn15){ getStringOut().setValue(getStringIn15().getValue()); } if(property == stringIn16){ getStringOut().setValue(getStringIn16().getValue()); } } //Property Declarations, Gets, and Sets /**String Output*/ public static final Property stringOut = newProperty(Flags.SUMMARY, new BStatusString()); /**String Inputs*/ public static final Property stringIn01 = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property stringIn02 = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property stringIn03 = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property stringIn04 = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property stringIn05 = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property stringIn06 = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property stringIn07 = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property stringIn08 = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property stringIn09 = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property stringIn10 = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property stringIn11 = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property stringIn12 = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property stringIn13 = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property stringIn14 = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property stringIn15 = newProperty(Flags.SUMMARY, new BStatusString()); public static final Property stringIn16 = newProperty(Flags.SUMMARY, new BStatusString()); //Get methods public BStatusString getStringOut() { return (BStatusString)get(stringOut);} public BStatusString getStringIn01() { return (BStatusString)get(stringIn01);} public BStatusString getStringIn02() { return (BStatusString)get(stringIn02);} public BStatusString getStringIn03() { return (BStatusString)get(stringIn03);} public BStatusString getStringIn04() { return (BStatusString)get(stringIn04);} public BStatusString getStringIn05() { return (BStatusString)get(stringIn05);} public BStatusString getStringIn06() { return (BStatusString)get(stringIn06);} public BStatusString getStringIn07() { return (BStatusString)get(stringIn07);} public BStatusString getStringIn08() { return (BStatusString)get(stringIn08);} public BStatusString getStringIn09() { return (BStatusString)get(stringIn09);} public BStatusString getStringIn10() { return (BStatusString)get(stringIn10);} public BStatusString getStringIn11() { return (BStatusString)get(stringIn11);} public BStatusString getStringIn12() { return (BStatusString)get(stringIn12);} public BStatusString getStringIn13() { return (BStatusString)get(stringIn13);} public BStatusString getStringIn14() { return (BStatusString)get(stringIn14);} public BStatusString getStringIn15() { return (BStatusString)get(stringIn15);} public BStatusString getStringIn16() { return (BStatusString)get(stringIn16);} //Set Methods public void setStringOut(BStatusString v) {set(stringOut,v);} public void setStringIn01(BStatusString v) {set(stringIn01,v);} public void setStringIn02(BStatusString v) {set(stringIn02,v);} public void setStringIn03(BStatusString v) {set(stringIn03,v);} public void setStringIn04(BStatusString v) {set(stringIn04,v);} public void setStringIn05(BStatusString v) {set(stringIn05,v);} public void setStringIn06(BStatusString v) {set(stringIn06,v);} public void setStringIn07(BStatusString v) {set(stringIn07,v);} public void setStringIn08(BStatusString v) {set(stringIn08,v);} public void setStringIn09(BStatusString v) {set(stringIn09,v);} public void setStringIn10(BStatusString v) {set(stringIn10,v);} public void setStringIn11(BStatusString v) {set(stringIn11,v);} public void setStringIn12(BStatusString v) {set(stringIn12,v);} public void setStringIn13(BStatusString v) {set(stringIn13,v);} public void setStringIn14(BStatusString v) {set(stringIn14,v);} public void setStringIn15(BStatusString v) {set(stringIn15,v);} public void setStringIn16(BStatusString v) {set(stringIn16,v);} public BIcon getIcon() { return icon; } private static final BIcon icon = BIcon.make("local:|module://KorsMaster/com/korsengineering/niagara/graphics/korsLogo.png"); public static final Type TYPE = Sys.loadType(BLatestString.class); public Type getType() { return TYPE; } } Revision-number: 23 Prop-content-length: 98 Content-length: 98 K 7 svn:log V 0 K 10 svn:author V 4 mike K 8 svn:date V 27 2008-03-26T03:30:17.977445Z PROPS-END Node-path: niagara/korsMaster/module.palette Node-kind: file Node-action: change Text-content-length: 2266 Text-content-md5: c6e15d38e465ea0febf2c9c30f486a6e Text-content-sha1: 65c31a7128c5d1f175e8e3f75223e39db8711a3a Content-length: 2266

Revision-number: 24 Prop-content-length: 98 Content-length: 98 K 7 svn:log V 0 K 10 svn:author V 4 mike K 8 svn:date V 27 2008-03-26T03:30:26.447116Z PROPS-END Node-path: niagara/korsMaster/module-include.xml Node-kind: file Node-action: change Text-content-length: 2603 Text-content-md5: a6c684d87d46295663d6f69d226d0c0d Text-content-sha1: 65aa750b98c474b57bd105ae53747fb93b24ce07 Content-length: 2603 Revision-number: 25 Prop-content-length: 149 Content-length: 149 K 7 svn:log V 49 Added stub for generic (and dynamic) WS operation K 10 svn:author V 5 roman K 8 svn:date V 27 2008-04-01T18:14:28.038513Z PROPS-END Node-path: niagara/korsPlexusWs/src/com/korsengineering/niagara/plexus/ws/BGenericWsOperation.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 6485 Text-content-md5: a79712b15c8dde8496c09a33ec3ae2ec Text-content-sha1: 47baa14914d2a6233d8708dfd4e66dd76e66c4bb Content-length: 6495 PROPS-END package com.korsengineering.niagara.plexus.ws; import java.net.URL; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.baja.control.BBooleanWritable; import javax.baja.control.BNumericWritable; import javax.baja.control.BStringWritable; import javax.baja.status.BStatusString; import javax.baja.sys.BComponent; import javax.baja.sys.BEnum; import javax.baja.sys.BEnumRange; import javax.baja.sys.BajaRuntimeException; import javax.baja.sys.Context; import javax.baja.sys.Flags; import javax.baja.sys.Property; import javax.baja.sys.Sys; import javax.baja.sys.Type; import javax.baja.util.BFolder; import javax.baja.util.BUnrestrictedFolder; import javax.baja.xml.XElem; import javax.baja.xml.XException; import javax.baja.xml.XNs; import javax.baja.xml.XParser; import com.korsengineering.http.HttpSender; public class BGenericWsOperation extends BComponent{ protected XElem root = null; protected Map tagMap = new HashMap(); //protected XNs wsdlNs = new XNs("wsdl", "http://schemas.xmlsoap.org/wsdl/"); static String prefixChop(String name){ String[] nameParts = new String[2]; nameParts = name.split(":", 2); if (nameParts[1] == null) { return name; } return nameParts[1]; } protected XElem getRoot(){ if (root == null) { try { root = XParser.make(getOutWsdlString()).parse(); } catch (Exception e) { throw new BajaRuntimeException(); } } return root; } public void changed(Property property, Context context){ super.changed(property, context); if (property == inWsdl && Sys.atSteadyState()) { try { String xml = HttpSender.get(new URL(getInWsdl())); setOutWsdlString(xml); } catch (Exception e) { throw new BajaRuntimeException(); } XElemSearcher recRoot = new XElemSearcher(getRoot()); Map nameFilter = new HashMap(); nameFilter.put("name", "WebServiceSoap12"); XElem soap12binding = recRoot.elem("binding", nameFilter); XElem[] operations = soap12binding.elems("operation"); List operationNames = new ArrayList(); operationNames.add("none"); for (XElem opeartion : operations) { operationNames.add(opeartion.get("name")); } try { removeAll(); } catch (Exception e) { //do nothing } BEnumRange operationsEnum = BEnumRange.make(operationNames.toArray(new String[0])); add("operation", operationsEnum.get(0)); } else if (property == getProperty("operation") && Sys.atSteadyState()) { System.out.println("changed!"); String operationName = ((BEnum) get(getProperty("operation"))).getTag(); if (operationName == "none") { return; } XElemSearcher recRoot = new XElemSearcher(getRoot()); Map nameFilter = new HashMap(); nameFilter.put("name", "WebServiceSoap"); XElem portType = recRoot.elem("portType", nameFilter); XElemSearcher recPortType = new XElemSearcher(portType); nameFilter = new HashMap(); String opName = ((BEnum) get(getProperty("operation"))).getTag(); nameFilter.put("name", opName); XElem operation = recPortType.elem("operation", nameFilter); String inputMessageName = operation.elem("input").get("message"); inputMessageName = prefixChop(inputMessageName); nameFilter.put("name", inputMessageName); String inputElementName = recRoot.elem("message", nameFilter).elem("part").get("element"); String outputMessageName = operation.elem("output").get("message"); outputMessageName = prefixChop(outputMessageName); nameFilter.put("name", outputMessageName); String outputElementName = recRoot.elem("message", nameFilter).elem("part").get("element"); BUnrestrictedFolder input = new BUnrestrictedFolder(); add("input", input); addMessages(input, inputElementName); BUnrestrictedFolder output = new BUnrestrictedFolder(); add("output", output); addMessages(output, outputElementName); } } public void addMessages(BComponent base, String name){ name = prefixChop(name); XElemSearcher schema = new XElemSearcher(getRoot().elem("types").elem("schema")); Map nameFilter = new HashMap(); nameFilter.put("name", name); XElem whatever = schema.elem(nameFilter); if (whatever == null) { //no description is schema part return; } XElemSearcher whateverSearcher = new XElemSearcher(whatever); nameFilter.put("name", null); //has some name? nameFilter.put("type", null); //has some type? XElem[] subelems = whateverSearcher.subelems("element", nameFilter); for (XElem subelem : subelems) { String type = ""; String subName = ""; try { type = subelem.get("type"); subName = subelem.get("name"); } catch (XException e) { assert true : "Filtering error"; } if (type.equals("s:string")) { base.add(subName, new BStringWritable()); } else if (type.equals("s:double") || type.equals("s:float") || type.equals("s:decimal") || type.equals("s:integer") || type.equals("s:int") || type.equals("s:long")) { base.add(subName, new BNumericWritable()); } else if (type.equals("s:bool") || type.equals("s:boolean")) { base.add(subName, new BBooleanWritable()); } else { BFolder folder = new BFolder(); base.add(subName, folder); addMessages(folder, type); } } } public static final Property inWsdl = newProperty(Flags.SUMMARY, ""); public String getInWsdl() { return getString(inWsdl); } public void setInWsdl(String v) { setString(inWsdl, v); } public static final Property outWsdlString = newProperty(Flags.SUMMARY, ""); public String getOutWsdlString() { return getString(outWsdlString); } public void setOutWsdlString(String v) { setString(outWsdlString, v); } public static final Type TYPE = Sys.loadType(BGenericWsOperation.class); public Type getType() { return TYPE; } } Node-path: niagara/korsPlexusWs/src/com/korsengineering/niagara/plexus/ws/XElemSearcher.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 6237 Text-content-md5: a15cea876baae73b6559a8fcf4260ce4 Text-content-sha1: fbb7eeabc0302daf381140d5ba802f41106ee67b Content-length: 6247 PROPS-END package com.korsengineering.niagara.plexus.ws; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import javax.baja.xml.XElem; import javax.baja.xml.XException; import javax.baja.xml.XNs; public class XElemSearcher{ // ==Static things== static boolean matches(XElem elem, Map filter){ Set keys = filter.keySet(); for (Iterator iterator = keys.iterator(); iterator.hasNext(); ) { String name = iterator.next(); String value = filter.get(name); if (value != null) { //check for specific value try { if (!elem.get(name).equals(value)) { return false; } } catch (XException e) { return false; } } else { //check whether attribute exists try { elem.get(name); //calling for exceptions only } catch (XException e) { return false; } } } return true; } @SuppressWarnings ("unchecked") public static T[] concat(T[]... arrays) { int count = 0; for (T[] array : arrays) { count += array.length; } // create new array T[] rv = (T[]) Array.newInstance(arrays[0][0].getClass(), count); int start = 0; for (T[] array : arrays) { System.arraycopy(array,0,rv,start,array.length); start += array.length; } return (T[]) rv; } // ==Dynamic things== protected XElem coreElem; public XElemSearcher(XElem elem){ if (elem == null) { throw new NullPointerException(); } coreElem = elem; } public final XElem[] elems(Map filter) { XElem[] elems = coreElem.elems(); List results = new ArrayList(); for (XElem elem : elems) { if (matches(elem, filter)) { results.add(elem); } } return results.toArray(new XElem[0]); } public final XElem elem(Map filter) { XElem[] elems = coreElem.elems(); for (XElem elem : elems) { if (matches(elem, filter)) { return elem; } } return null; } public final XElem elem(String name, Map filter) { XElem[] elems = elems(filter); for (XElem elem : elems) { if (elem.name().equals(name)) { return elem; } } return null; } public final XElem elem(XNs ns, String name, Map filter) { XElem[] elems = elems(filter); for (XElem elem : elems) { if (elem.name().equals(name) && elem.ns().equals(ns)) { return elem; } } return null; } public final XElem[] elems(String name, Map filter) { XElem[] elems = coreElem.elems(); List results = new ArrayList(); for (XElem elem : elems) { if (matches(elem, filter) && elem.name().equals(name)) { results.add(elem); } } return results.toArray(new XElem[0]); } public final XElem[] elems(XNs ns, String name, Map filter) { XElem[] elems = coreElem.elems(); List results = new ArrayList(); for (XElem elem : elems) { if (matches(elem, filter) && elem.name().equals(name) && elem.ns().equals(ns)) { results.add(elem); } } return results.toArray(new XElem[0]); } public final XElem[] elems(XNs ns, Map filter) { XElem[] elems = coreElem.elems(); List results = new ArrayList(); for (XElem elem : elems) { if (matches(elem, filter) && elem.ns().equals(ns)) { results.add(elem); } } return results.toArray(new XElem[0]); } //Methods that operate recursively public final XElem[] subelems() { XElem[] elems = coreElem.elems(); XElem[] subelems = coreElem.elems(); for (XElem elem : elems) { subelems = concat(subelems, new XElemSearcher(elem).subelems()); } return subelems; } public final XElem[] subelems(Map filter) { XElem[] elems = subelems(); List results = new ArrayList(); for (XElem elem : elems) { if (matches(elem, filter)) { results.add(elem); } } return results.toArray(new XElem[0]); } public final XElem subelem(String name) { XElem[] elems = subelems(); for (XElem elem : elems) { if (elem.name().equals(name)) { return elem; } } return null; } public final XElem[] subelems(String name) { XElem[] elems = subelems(); List results = new ArrayList(); for (XElem elem : elems) { if (elem.name().equals(name)) { results.add(elem); } } return results.toArray(new XElem[0]); } public final XElem subelem(String name, Map filter) { XElem[] elems = subelems(filter); for (XElem elem : elems) { if (elem.name().equals(name)) { return elem; } } return null; } public final XElem subelem(XNs ns, String name, Map filter) { XElem[] elems = subelems(filter); for (XElem elem : elems) { if (elem.name().equals(name) && elem.ns().equals(ns)) { return elem; } } return null; } public final XElem[] subelems(String name, Map filter) { XElem[] elems = subelems(); ArrayList results = new ArrayList(); for (XElem elem : elems) { if (matches(elem, filter) && elem.name().equals(name)) { results.add(elem); } } return results.toArray(new XElem[0]); } public final XElem[] subelems(XNs ns, String name, Map filter) { XElem[] elems = subelems(); ArrayList results = new ArrayList(); for (XElem elem : elems) { if (matches(elem, filter) && elem.name().equals(name) && elem.ns().equals(ns)) { results.add(elem); } } return results.toArray(new XElem[0]); } public final XElem[] subelems(XNs ns, Map filter) { XElem[] elems = subelems(); ArrayList results = new ArrayList(); for (XElem elem : elems) { if (matches(elem, filter) && elem.ns().equals(ns)) { results.add(elem); } } return results.toArray(new XElem[0]); } } Revision-number: 26 Prop-content-length: 98 Content-length: 98 K 7 svn:log V 0 K 10 svn:author V 4 mike K 8 svn:date V 27 2008-04-03T20:14:01.640534Z PROPS-END Node-path: niagara/korsPlexus/src/com/korsengineering/niagara/plexus/BPoster.java Node-kind: file Node-action: change Text-content-length: 13244 Text-content-md5: 8684c7a39fbcd2b924a70fb442d1fd95 Text-content-sha1: 6c3ddc5aa1b72740605640bc1f6370bf63ce5408 Content-length: 13244 package com.korsengineering.niagara.plexus; import com.korsengineering.http.HttpSender; import java.io.*; import java.net.*; import java.text.SimpleDateFormat; import java.util.Date; import javax.baja.naming.SyntaxException; import javax.baja.security.BPassword; import javax.baja.sys.*; import javax.baja.xml.XElem; import javax.baja.xml.XParser; import com.tridium.util.FileLock; import javax.baja.status.*; import javax.baja.xml.XException; /** * This class models and sends requests to Plexus. All slots that are maked as * "USER_DEFINED_1" in subclasses will be used as fields in the body XML. * @author Roman Ivanov */ public abstract class BPoster extends BComponent{ protected File buffer; protected boolean lastTriggerState = false; protected URL destinationUrl; public void started() throws Exception{ buffer = new File(Sys.getStationHome().getAbsolutePath() + "/plex-buffer.xml"); setGoodTransactions(new BStatusNumeric(0)); setBadTransactions(new BStatusNumeric(0)); } /** * Reacts to changes in destination and trigger slots. */ public void changed(Property property, Context context){ super.changed(property, context); if (property == destination) { try { if (getDestination().getValue().equals("") || getDestination().getValue() == null) { destinationUrl = new URL("http:127.0.0.1"); } else { destinationUrl = new URL(getDestination().getValue()); } } catch (MalformedURLException ex) { throw new SyntaxException(ex); } } else if (property == trigger) { if(!Sys.atSteadyState()){ return; } try { if (getTrigger().getValue() && (lastTriggerState == false)) { //set start time of transaction BAbsTime bt = BAbsTime.now(); doSend(); BRelTime at = bt.delta(BAbsTime.now()); setTimeLastTransaction(new BStatusNumeric(at.getMillis())); } } catch (Exception ex) { throw new BajaRuntimeException(ex); } finally { lastTriggerState = getTrigger().getValue(); } } } //Boilerplate code: /** * URL for the future requests. */ public static final Property destination = newProperty(Flags.SUMMARY, new BStatusString()); public BStatusString getDestination() { return (BStatusString) get(destination); } public void setDestination(BStatusString v) { set(destination, v); } /** * Http login. */ public static final Property login = newProperty(Flags.SUMMARY, new BStatusString()); public BStatusString getLogin() { return (BStatusString) get(login); } public void setLogin(BStatusString v) { set(login, v); } /** * Http password. */ public static final Property password = newProperty(Flags.SUMMARY, BPassword.DEFAULT); public BPassword getPassword() { return (BPassword) get(password); } public void setPassword(BPassword v) { set(password, v); } /** * ID of this machine (for Plexus). */ public static final Property machineId = newProperty(Flags.SUMMARY, new BStatusString()); public BStatusString getMachineId() { return (BStatusString) get(machineId); } public void setMachineId(BStatusString v) { set(machineId, v); } /** * When set to true from false state, triggers doSend(). */ public static final Property trigger = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BStatusBoolean getTrigger() { return (BStatusBoolean) get(trigger); } public void setTrigger(BStatusBoolean v) { set(trigger, v); } /** * Whether re last request was successfull. Account for low-level errors, * as well as responce status from Plexus. */ public static final Property result = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BStatusBoolean getResult() { return (BStatusBoolean) get(result); } public void setResult(BStatusBoolean v) { set(result, v); } /** * Set to true if IO exception was thrown while sending data. */ public static final Property internetFailure = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BStatusBoolean getInternetFailure() { return (BStatusBoolean) get(internetFailure); } public void setInternetFailure(BStatusBoolean v) { set(internetFailure, v); } /** * When set to true, transaction that failed due to low-level errors (IO) * will be buffered in plex-biffer.xml. * @see com.korsengineering.niagara.plexus.BRepeater */ public static final Property useBuffer = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BStatusBoolean getUseBuffer() { return (BStatusBoolean) get(useBuffer); } public void setUseBuffer(BStatusBoolean v) { set(useBuffer, v); } public static final Property verbose = newProperty(0, false); public boolean getVerbose() { return getBoolean(verbose); } public void setVerbose(boolean v) { setBoolean(verbose, v); } public static final Property lastRequest = newProperty(0, new BStatusString()); public BStatusString getLastRequest() { return (BStatusString)get(lastRequest); } public void setLastRequest(BStatusString v) { set(lastRequest, v); } public static final Property lastResponse = newProperty(0, new BStatusString()); public BStatusString getLastResponse() { return (BStatusString)get(lastResponse); } public void setLastResponse(BStatusString v) { set(lastResponse, v); } public static final Property lastSummary = newProperty(0, new BStatusString()); public BStatusString getLastSummary() { return (BStatusString)get(lastSummary); } public void setLastSummary(BStatusString v) { set(lastSummary, v); } public static final Property goodTransactions = newProperty(Flags.SUMMARY, new BStatusNumeric(0)); public BStatusNumeric getGoodTransactions() { return (BStatusNumeric) get(goodTransactions); } public void setGoodTransactions(BStatusNumeric v) { set(goodTransactions, v); } public static final Property badTransactions = newProperty(Flags.SUMMARY, new BStatusNumeric(0)); public BStatusNumeric getBadTransactions() { return (BStatusNumeric) get(badTransactions); } public void setBadTransactions(BStatusNumeric v) { set(badTransactions, v); } private static javax.baja.units.BUnit msecs = javax.baja.units.BUnit.getUnit("millisecond"); public static final Property timeLastTransaction = newProperty(Flags.SUMMARY, new BStatusNumeric(0),BFacets.makeNumeric(msecs, 0)); public BStatusNumeric getTimeLastTransaction() { return (BStatusNumeric) get(timeLastTransaction); } public void setTimeLastTransaction(BStatusNumeric v) { set(timeLastTransaction, v); } protected String getAction(){ return this.getClass().getName().substring(1); } public static final Action send = newAction(0); public void send() { invoke(send, null); } //invokes /** * Generates XML request from the fields of the object, and sends it to * http://www.plexus-online.com/PLC via HttpSender. Sets result slot * appropriately. If the request fails due to IO error and buffering is * enabled, this method buffers the request via addToBuffer(). * @see com.korsengineering.niagara.plexus.BPoster#addToBuffer() * @throws Exception */ public void doSend() throws Exception{ Date now = new Date(); SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy"); SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss"); String xData = ""; String xml = "" + "" + "" + getMachineId().getValue() + "" + "" + getAction() + "" + "" + "" + dateFormat.format(now) + "" + ""; SlotCursor properties = getProperties(); int contentLength = 0; while (properties.next()) { Property property = properties.property(); if (!Flags.isUserDefined1(this, property)) { continue; } String valueString = ""; if (get(property) instanceof BStatusString) { valueString = ((BStatusString) get(property)).getValue(); } else { continue; } String name = property.getName().substring(0, 1).toUpperCase() + property.getName().substring(1); xml += "<"+name+">"+valueString+""; if(xData.length()>0){ xData += ", "; } xData += valueString; contentLength += valueString.length(); } xml += "" + "" + ""; if (getVerbose()) { System.out.println("Request: \n" + xml); } boolean sent = false; String summaryString = ""; setLastRequest(new BStatusString(xml)); if (contentLength>0) { try { String response = HttpSender.send(destinationUrl, getLogin().getValue(), getPassword().getString(), xml); setInternetFailure(new BStatusBoolean(false)); setLastResponse(new BStatusString(response)); if (getVerbose()) { System.out.println("Response: \n" + response); } sent = response.indexOf("0") != -1; setLastResponse(new BStatusString(response)); } catch (IOException ex) { setInternetFailure(new BStatusBoolean(true)); setLastResponse(new BStatusString("Error: " + ex)); addToBuffer(xml, "io"); throw ex; } finally { if (sent) { setGoodTransactions(new BStatusNumeric(getGoodTransactions().getValue() + 1)); summaryString += "At " + dateFormat.format(now) + " " + timeFormat.format(now); summaryString += " Machine " + getMachineId().getValue(); summaryString += " Successfully sent " + getAction(); summaryString += " with values(" + xData + ")"; getLastSummary().setStatus(BStatus.ok); } else { setBadTransactions(new BStatusNumeric(getBadTransactions().getValue() + 1)); summaryString += "At " + dateFormat.format(now) + " " + timeFormat.format(now); summaryString += " Machine " + getMachineId().getValue(); summaryString += " FAILED sending " + getAction(); summaryString += " with values(" + xData + ")"; getLastSummary().setStatus(BStatus.ok); } getLastSummary().setValue(summaryString); setResult(new BStatusBoolean(sent)); } } } /** * Buffers failed requests in plex-buffer.xml file, located in station home folder. * @param value Failed request XML. (Not parsed.) * @param reason Reason of failure. Currently, only "io" is used. * @throws Exception */ public void addToBuffer(String value, String reason) throws Exception{ XElem root = new XElem("buffer"); if (!buffer.exists()) { if (!buffer.createNewFile()) { throw new IOException("Could not create the buffer file"); } } FileLock fl = FileLock.lock(buffer); try { if (buffer.length() != 0) { root = XParser.make(buffer).parse(); } XElem error = new XElem("error"); error.addAttr("times", "1"); error.addAttr("reason", reason); error.addContent(XParser.make(value).parse()); root.addContent(error); root.write(buffer); } catch (XException ex) { buffer.delete(); throw ex; } finally { fl.unlock(); } } public static final Type TYPE = Sys.loadType(BPoster.class); public Type getType() { return TYPE; } } Revision-number: 27 Prop-content-length: 99 Content-length: 99 K 7 svn:log V 0 K 10 svn:author V 5 roman K 8 svn:date V 27 2008-04-08T16:22:19.686709Z PROPS-END Node-path: niagara/korsPlexus/src/com/korsengineering/http/HttpSender.java Node-kind: file Node-action: change Text-content-length: 2543 Text-content-md5: 059ae276fa38edc6ffad441260844ae8 Text-content-sha1: 5b1bf44e8d3092e9b6e78395ba5ba3375b526b15 Content-length: 2543 package com.korsengineering.http; import java.io.*; import java.net.*; import javax.baja.io.Base64; /** * @author Roman Ivanov * Generic HTTP sender, which can deal with simple authentication. */ public class HttpSender{ /** * This class is simply a container for static methods. */ private HttpSender(){} /** * @param destination * @param login * @param password * @param xml Body of the request that will be made. * @return String with the response body. * @throws IOException */ public static String send(URL destination, String login, String password, String xml) throws IOException { HttpURLConnection connection = (HttpURLConnection) destination.openConnection(); connection.setRequestMethod("POST"); connection.setRequestProperty("Host", destination.getHost()); String authCode = Base64.encode((login + ":" + password).getBytes()); connection.setRequestProperty("Authorization", "Basic " + authCode); connection.setDoOutput(true); connection.connect(); OutputStream out = connection.getOutputStream(); byte[] xmlBytes = xml.getBytes(); out.write(xmlBytes, 0, xmlBytes.length); String inString = ""; try { BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); String inBuffer = ""; while ((inBuffer = in.readLine()) != null) { inString += inBuffer + "\n"; } } catch (IOException ex) { ex.printStackTrace(); } connection.disconnect(); return inString; } public static String get(URL destination) throws IOException { HttpURLConnection connection = (HttpURLConnection) destination.openConnection(); connection.setRequestMethod("GET"); connection.setRequestProperty("Host", destination.getHost()); connection.setDoOutput(true); connection.connect(); String inString = ""; try { BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); String inBuffer = ""; while ((inBuffer = in.readLine()) != null) { inString += inBuffer + "\n"; } } catch (IOException ex) { ex.printStackTrace(); } connection.disconnect(); return inString; } } Node-path: niagara/korsPlexus/src/com/korsengineering/niagara/plexus/BPoster.java Node-kind: file Node-action: change Text-content-length: 13306 Text-content-md5: ea5cf2b24fc2622c85cac004c454c1a3 Text-content-sha1: 73bacde2e05ebafd6dea77a9150de473ae237103 Content-length: 13306 package com.korsengineering.niagara.plexus; import com.korsengineering.http.HttpSender; import java.io.*; import java.net.*; import java.text.SimpleDateFormat; import java.util.Date; import javax.baja.naming.SyntaxException; import javax.baja.security.BPassword; import javax.baja.sys.*; import javax.baja.xml.XElem; import javax.baja.xml.XParser; import com.tridium.util.FileLock; import javax.baja.status.*; import javax.baja.xml.XException; /** * This class models and sends requests to Plexus. All slots that are flagged as * "USER_DEFINED_1" in subclasses will be used as fields in the body XML. * @author Roman Ivanov */ public abstract class BPoster extends BComponent{ protected File buffer; protected boolean lastTriggerState = false; protected URL destinationUrl; public void started() throws Exception{ buffer = new File(Sys.getStationHome().getAbsolutePath() + "/plex-buffer.xml"); setGoodTransactions(new BStatusNumeric(0)); setBadTransactions(new BStatusNumeric(0)); } /** * Reacts to changes in destination and trigger slots. */ public void changed(Property property, Context context){ super.changed(property, context); if(!Sys.atSteadyState() || !isRunning()){ return; } if (property == destination) { try { if (getDestination().getValue().equals("") || getDestination().getValue() == null) { destinationUrl = new URL("http:127.0.0.1"); } else { destinationUrl = new URL(getDestination().getValue()); } } catch (MalformedURLException ex) { throw new SyntaxException(ex); } } else if (property == trigger) { try { if (getTrigger().getValue() && (lastTriggerState == false)) { //set start time of transaction BAbsTime bt = BAbsTime.now(); doSend(); BRelTime at = bt.delta(BAbsTime.now()); setTimeLastTransaction(new BStatusNumeric(at.getMillis())); } } catch (Exception ex) { throw new BajaRuntimeException(ex); } finally { lastTriggerState = getTrigger().getValue(); } } } //Boilerplate code: /** * URL for the future requests. */ public static final Property destination = newProperty(Flags.SUMMARY, new BStatusString()); public BStatusString getDestination() { return (BStatusString) get(destination); } public void setDestination(BStatusString v) { set(destination, v); } /** * Http login. */ public static final Property login = newProperty(Flags.SUMMARY, new BStatusString()); public BStatusString getLogin() { return (BStatusString) get(login); } public void setLogin(BStatusString v) { set(login, v); } /** * Http password. */ public static final Property password = newProperty(Flags.SUMMARY, BPassword.DEFAULT); public BPassword getPassword() { return (BPassword) get(password); } public void setPassword(BPassword v) { set(password, v); } /** * ID of this machine (for Plexus). */ public static final Property machineId = newProperty(Flags.SUMMARY, new BStatusString()); public BStatusString getMachineId() { return (BStatusString) get(machineId); } public void setMachineId(BStatusString v) { set(machineId, v); } /** * When set to true from false state, triggers doSend(). */ public static final Property trigger = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BStatusBoolean getTrigger() { return (BStatusBoolean) get(trigger); } public void setTrigger(BStatusBoolean v) { set(trigger, v); } /** * Whether re last request was successfull. Account for low-level errors, * as well as responce status from Plexus. */ public static final Property result = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BStatusBoolean getResult() { return (BStatusBoolean) get(result); } public void setResult(BStatusBoolean v) { set(result, v); } /** * Set to true if IO exception was thrown while sending data. */ public static final Property internetFailure = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BStatusBoolean getInternetFailure() { return (BStatusBoolean) get(internetFailure); } public void setInternetFailure(BStatusBoolean v) { set(internetFailure, v); } /** * When set to true, transaction that failed due to low-level errors (IO) * will be buffered in plex-biffer.xml. * @see com.korsengineering.niagara.plexus.BRepeater */ public static final Property useBuffer = newProperty(Flags.SUMMARY, new BStatusBoolean(false)); public BStatusBoolean getUseBuffer() { return (BStatusBoolean) get(useBuffer); } public void setUseBuffer(BStatusBoolean v) { set(useBuffer, v); } public static final Property verbose = newProperty(0, false); public boolean getVerbose() { return getBoolean(verbose); } public void setVerbose(boolean v) { setBoolean(verbose, v); } public static final Property lastRequest = newProperty(0, new BStatusString()); public BStatusString getLastRequest() { return (BStatusString)get(lastRequest); } public void setLastRequest(BStatusString v) { set(lastRequest, v); } public static final Property lastResponse = newProperty(0, new BStatusString()); public BStatusString getLastResponse() { return (BStatusString)get(lastResponse); } public void setLastResponse(BStatusString v) { set(lastResponse, v); } public static final Property lastSummary = newProperty(0, new BStatusString()); public BStatusString getLastSummary() { return (BStatusString)get(lastSummary); } public void setLastSummary(BStatusString v) { set(lastSummary, v); } public static final Property goodTransactions = newProperty(Flags.SUMMARY, new BStatusNumeric(0)); public BStatusNumeric getGoodTransactions() { return (BStatusNumeric) get(goodTransactions); } public void setGoodTransactions(BStatusNumeric v) { set(goodTransactions, v); } public static final Property badTransactions = newProperty(Flags.SUMMARY, new BStatusNumeric(0)); public BStatusNumeric getBadTransactions() { return (BStatusNumeric) get(badTransactions); } public void setBadTransactions(BStatusNumeric v) { set(badTransactions, v); } private static javax.baja.units.BUnit msecs = javax.baja.units.BUnit.getUnit("millisecond"); public static final Property timeLastTransaction = newProperty(Flags.SUMMARY, new BStatusNumeric(0),BFacets.makeNumeric(msecs, 0)); public BStatusNumeric getTimeLastTransaction() { return (BStatusNumeric) get(timeLastTransaction); } public void setTimeLastTransaction(BStatusNumeric v) { set(timeLastTransaction, v); } protected String getAction(){ return this.getClass().getName().substring(1); } public static final Action send = newAction(0); public void send() { invoke(send, null); } //invokes /** * Generates XML request from the fields of the object, and sends it to * http://www.plexus-online.com/PLC via HttpSender. Sets result slot * appropriately. If the request fails due to IO error and buffering is * enabled, this method buffers the request via addToBuffer(). * @see com.korsengineering.niagara.plexus.BPoster#addToBuffer() * @throws Exception */ public void doSend() throws Exception{ Date now = new Date(); SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy"); SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss"); String xData = ""; String xml = "" + "" + "" + getMachineId().getValue() + "" + "" + getAction() + "" + "" + "" + dateFormat.format(now) + "" + ""; SlotCursor properties = getProperties(); int contentLength = 0; while (properties.next()) { Property property = properties.property(); if (!Flags.isUserDefined1(this, property)) { continue; } String valueString = ""; if (get(property) instanceof BStatusString) { valueString = ((BStatusString) get(property)).getValue(); } else { continue; } String name = property.getName().substring(0, 1).toUpperCase() + property.getName().substring(1); xml += "<"+name+">"+valueString+""; if(xData.length()>0){ xData += ", "; } xData += valueString; contentLength += valueString.length(); } xml += "" + "" + ""; if (getVerbose()) { System.out.println("Request: \n" + xml); } boolean sent = false; String summaryString = ""; setLastRequest(new BStatusString(xml)); if (contentLength>0) { try { String response = HttpSender.send(destinationUrl, getLogin().getValue(), getPassword().getString(), xml); setInternetFailure(new BStatusBoolean(false)); setLastResponse(new BStatusString(response)); if (getVerbose()) { System.out.println("Response: \n" + response); } sent = response.indexOf("0") != -1; setLastResponse(new BStatusString(response)); } catch (IOException ex) { setInternetFailure(new BStatusBoolean(true)); setLastResponse(new BStatusString("Error: " + ex)); addToBuffer(xml, "io"); if (getVerbose()) { throw ex; } } finally { if (sent) { setGoodTransactions(new BStatusNumeric(getGoodTransactions().getValue() + 1)); summaryString += "At " + dateFormat.format(now) + " " + timeFormat.format(now); summaryString += " Machine " + getMachineId().getValue(); summaryString += " Successfully sent " + getAction(); summaryString += " with values(" + xData + ")"; getLastSummary().setStatus(BStatus.ok); } else { setBadTransactions(new BStatusNumeric(getBadTransactions().getValue() + 1)); summaryString += "At " + dateFormat.format(now) + " " + timeFormat.format(now); summaryString += " Machine " + getMachineId().getValue(); summaryString += " FAILED sending " + getAction(); summaryString += " with values(" + xData + ")"; getLastSummary().setStatus(BStatus.ok); } getLastSummary().setValue(summaryString); setResult(new BStatusBoolean(sent)); } } } /** * Buffers failed requests in plex-buffer.xml file, located in station home folder. * @param value Failed request XML. (Not parsed.) * @param reason Reason of failure. Currently, only "io" is used. * @throws Exception */ public void addToBuffer(String value, String reason) throws Exception{ XElem root = new XElem("buffer"); if (!buffer.exists()) { if (!buffer.createNewFile()) { throw new IOException("Could not create the buffer file"); } } FileLock fl = FileLock.lock(buffer); try { if (buffer.length() != 0) { root = XParser.make(buffer).parse(); } XElem error = new XElem("error"); error.addAttr("times", "1"); error.addAttr("reason", reason); error.addContent(XParser.make(value).parse()); root.addContent(error); root.write(buffer); } catch (XException ex) { buffer.delete(); throw ex; } finally { fl.unlock(); } } public static final Type TYPE = Sys.loadType(BPoster.class); public Type getType() { return TYPE; } } Node-path: niagara/korsPlexus/src/com/korsengineering/niagara/printing/BPrinter.java Node-kind: file Node-action: change Text-content-length: 3368 Text-content-md5: d68adafa03dae750c5873409c8a48b22 Text-content-sha1: 3cb88c923a152fc58a1c7fa53e5b7299726edbf1 Content-length: 3368 package com.korsengineering.niagara.printing; import javax.baja.status.BStatusString; import javax.baja.sys.Action; import javax.baja.sys.BComponent; import javax.baja.sys.Flags; import javax.baja.sys.Property; import javax.baja.sys.Sys; import javax.baja.sys.Type; import javax.print.Doc; import javax.print.DocFlavor; import javax.print.DocPrintJob; import javax.print.PrintException; import javax.print.PrintService; import javax.print.PrintServiceLookup; import javax.print.SimpleDoc; import javax.print.attribute.PrintServiceAttribute; import javax.print.attribute.standard.PrinterName; public class BPrinter extends BComponent{ public static boolean printSomething (String pName, byte[] pArray){ boolean bResult = false; String sPrinterName = null; PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null); for (int i = 0; i < services.length; i++) { PrintServiceAttribute attr = services[i].getAttribute(PrinterName.class); sPrinterName = ((PrinterName)attr).getValue(); if (sPrinterName.indexOf(pName)>=0){ System.out.println("Found printer: " + sPrinterName ); //found printer, now send byte array to it try { DocPrintJob job = services[i].createPrintJob(); DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE; Doc doc = new SimpleDoc(pArray, flavor, null); job.print(doc, null); bResult = true; } catch (PrintException e) { e.printStackTrace(); } } else { System.out.println("not printer: " + sPrinterName ); } } System.out.println("Finshed\n"); return bResult; } public String getAction(){ return "PrintString"; } public void doPrintString() { //attempt to send input string to partial printer name BStatusString inp = getPrintString(); BStatusString prt = getPrinterName(); if(prt.toString().length()>0) { //have a printer name, now check string if (inp.getValue().length()>0) { boolean pf = printSomething(prt.getValue(),inp.getValue().getBytes()); } } } public static final Action PrintString = newAction(0); public void PrintString() { invoke(PrintString, null); } public static final Property printString = newProperty (Flags.SUMMARY , new BStatusString()); public BStatusString getPrintString() { return (BStatusString) get(printString); } public void setPrintString(BStatusString v) { set(printString, v); } public static final Property printerName = newProperty (Flags.SUMMARY , new BStatusString()); public BStatusString getPrinterName() { return (BStatusString) get(printerName); } public void setPrinterName(BStatusString v) { set(printerName, v); } public static final Type TYPE = Sys.loadType(BPrinter.class); public Type getType() { return TYPE; } } Revision-number: 28 Prop-content-length: 99 Content-length: 99 K 7 svn:log V 0 K 10 svn:author V 5 roman K 8 svn:date V 27 2008-04-08T16:28:41.992857Z PROPS-END Node-path: niagara/korsPlexusWs/src/com/korsengineering/niagara/plexus/ws/BGenericWsOperation.java Node-kind: file Node-action: change Text-content-length: 13861 Text-content-md5: 1c817d42d9d1386cd9a06ab3abc2345a Text-content-sha1: 6b4c47eebb02011e58979db537cbfbea183504dd Content-length: 13861 package com.korsengineering.niagara.plexus.ws; import java.net.URL; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.baja.control.BBooleanWritable; import javax.baja.control.BNumericWritable; import javax.baja.control.BStringWritable; import javax.baja.io.Base64; import javax.baja.security.BPassword; import javax.baja.status.BStatusBoolean; import javax.baja.status.BStatusNumeric; import javax.baja.status.BStatusString; import javax.baja.sys.Action; import javax.baja.sys.BComponent; import javax.baja.sys.BEnum; import javax.baja.sys.BEnumRange; import javax.baja.sys.BajaRuntimeException; import javax.baja.sys.Context; import javax.baja.sys.Flags; import javax.baja.sys.Property; import javax.baja.sys.Sys; import javax.baja.sys.Type; import javax.baja.util.BFolder; import javax.baja.xml.XElem; import javax.baja.xml.XException; import javax.baja.xml.XParser; import javax.xml.namespace.QName; import javax.xml.soap.MessageFactory; import javax.xml.soap.MimeHeaders; import javax.xml.soap.SOAPBody; import javax.xml.soap.SOAPConstants; import javax.xml.soap.SOAPElement; import javax.xml.soap.SOAPEnvelope; import javax.xml.soap.SOAPException; import javax.xml.soap.SOAPHeader; import javax.xml.soap.SOAPMessage; import javax.xml.soap.SOAPPart; import javax.xml.ws.Dispatch; import javax.xml.ws.Service; import javax.xml.ws.soap.SOAPBinding; import com.korsengineering.http.HttpSender; public class BGenericWsOperation extends BComponent{ protected XElem root = null; protected Map tagMap = new HashMap(); //protected XNs wsdlNs = new XNs("wsdl", "http://schemas.xmlsoap.org/wsdl/"); static String prefixChop(String name){ String[] nameParts = new String[2]; nameParts = name.split(":", 2); if (nameParts[1] == null) { return name; } return nameParts[1]; } protected XElem getRoot(){ if (root == null) { try { root = XParser.make(getWsdlString()).parse(); } catch (Exception e) { throw new BajaRuntimeException(); } } return root; } public void changed(Property property, Context context){ if (!isRunning()) return; super.changed(property, context); if (property == inWsdl && Sys.atSteadyState()) { onWsdlChange(); /* String[] x = {"one", "two", "three"}; BEnumRange operationsEnum = BEnumRange.make(x); if (get("operation") != null) { remove("operation"); } add("operation", operationsEnum.get(0)); */ } else if (property == getProperty("operation") && Sys.atSteadyState()) { onOperationChange(); } } protected void onWsdlChange(){ try { String xml = HttpSender.get(new URL(getInWsdl())); setWsdlString(xml); } catch (Exception e) { throw new BajaRuntimeException(); } XElemSearcher recRoot = new XElemSearcher(getRoot()); Map nameFilter = new HashMap(); nameFilter.put("name", "WebServiceSoap12"); XElem soap12binding = recRoot.elem("binding", nameFilter); XElem[] operations = soap12binding.elems("operation"); List operationNames = new ArrayList(); operationNames.add("none"); for (XElem opeartion : operations) { operationNames.add(opeartion.get("name")); } if (get("input") != null) { remove("input"); } if (get("output") != null) { remove("output"); } BEnumRange operationsEnum = BEnumRange.make(operationNames.toArray(new String[0])); if (get("operation") != null) { remove("operation"); } add("operation", operationsEnum.get(0)); } protected void onOperationChange(){ String operationName = ((BEnum) get(getProperty("operation"))).getTag(); if (operationName == "none") { return; } Map nameFilter = new HashMap(); XElemSearcher recRoot = new XElemSearcher(getRoot()); nameFilter.put("name", "WebServiceSoap"); XElem portType = recRoot.elem("portType", nameFilter); XElemSearcher recPortType = new XElemSearcher(portType); String opName = ((BEnum) get(getProperty("operation"))).getTag(); nameFilter.put("name", opName); XElem operation = recPortType.elem("operation", nameFilter); String inputMessageName = operation.elem("input").get("message"); inputMessageName = prefixChop(inputMessageName); nameFilter.put("name", inputMessageName); String inputElementName = recRoot.elem("message", nameFilter).elem("part").get("element"); String outputMessageName = operation.elem("output").get("message"); outputMessageName = prefixChop(outputMessageName); nameFilter.put("name", outputMessageName); String outputElementName = recRoot.elem("message", nameFilter).elem("part").get("element"); if (getProperty("input") != null) { remove("input"); } BFolder input = new BXmlContainer(); add("input", input); addMessages(input, inputElementName); if (getProperty("output") != null) { remove("output"); } BFolder output = new BXmlContainer(); add("output", output); addMessages(output, outputElementName); } public void addMessages(BComponent base, String name){ name = prefixChop(name); XElemSearcher schema = new XElemSearcher(getRoot().elem("types").elem("schema")); Map nameFilter = new HashMap(); nameFilter.put("name", name); XElem whatever = schema.elem(nameFilter); if (whatever == null) { //no description is schema part return; } XElemSearcher whateverSearcher = new XElemSearcher(whatever); nameFilter.put("name", null); //has some name? nameFilter.put("type", null); //has some type? XElem[] subelems = whateverSearcher.subelems("element", nameFilter); for (XElem subelem : subelems) { String type = ""; String subName = ""; try { type = subelem.get("type"); subName = subelem.get("name"); } catch (XException e) { assert true : "Filtering error"; } if (type.equals("s:string")) { base.add(subName, new BXmlString()); } else if (type.equals("s:double") || type.equals("s:float") || type.equals("s:decimal") || type.equals("s:integer") || type.equals("s:int") || type.equals("s:long")) { base.add(subName, new BXmlNumber()); } else if (type.equals("s:bool") || type.equals("s:boolean")) { base.add(subName, new BXmlBoolean()); } else { BXmlContainer folder = new BXmlContainer(); addMessages(folder, type); XElemSearcher subSearcher = new XElemSearcher(subelem); XElem extension = subSearcher.subelem("extension"); if (extension != null) { String messageBase = prefixChop(extension.get("base")); addMessages(folder, messageBase); } } } } protected String getTargetNs(){ return getRoot().get("targetNamespace"); } protected QName getServiceName(){ String serviceName = getRoot().elem("service").get("name"); return new QName(getTargetNs(), serviceName); } protected QName getPortName(){ String operationName = ((BEnum) get(getProperty("operation"))).getTag(); //Map nameFilter = new HashMap(); //nameFilter.put("name", "WebServiceSoap12"); //XElemSearcher rootSearcher = new XElemSearcher(getRoot()); //XElem soap12binding = rootSearcher.elem("binding", nameFilter); //XElemSearcher bindingSearcher = new XElemSearcher(soap12binding); //nameFilter.put("name", operationName); //XElem op = bindingSearcher.elem("operation ", nameFilter); //String url = op.elem("operation").get("soapAction"); return new QName(getTargetNs(), operationName); } protected String getEndpointUrl(){ XElemSearcher serviceSearcher = new XElemSearcher(getRoot().elem("service")); Map nameFilter = new HashMap(); nameFilter.put("name", "WebServiceSoap12"); XElem soap12binding = serviceSearcher.elem("binding", nameFilter); return soap12binding.elem("address").get("location"); } public static final Action send = newAction(0); public void send(){ invoke(send, null); } //invokes public void doSend() throws Exception{ Service service = Service.create(getServiceName()); service.addPort(getServiceName(), SOAPBinding.SOAP12HTTP_BINDING, getEndpointUrl()); Dispatch dispatch = service.createDispatch(getPortName(), SOAPMessage.class, Service.Mode.MESSAGE); MessageFactory mf = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL); // Create a message. This example works with the SOAPPART. SOAPMessage request = mf.createMessage(); MimeHeaders headers = request.getMimeHeaders(); System.out.println(headers.getAllHeaders()); String authCode = Base64.encode(("BatesvilleWS@plex.com" + ":" + "pass").getBytes()); headers.addHeader("Authorization", "Basic " + authCode); SOAPPart part = request.getSOAPPart(); // Obtain the SOAPEnvelope and header and body elements. SOAPEnvelope env = part.getEnvelope(); //SOAPHeader header = env.getHeader(); SOAPBody body = env.getBody(); // Construct the message payload. composeSoap(body, (BComponent) getChildren(XmlTag.class)[0]); request.saveChanges(); SOAPMessage response = dispatch.invoke(request); response.writeTo(System.out); //TODO remove in production /* SOAPElement rpr = (SOAPElement) response.getSOAPBody().getChildElements(new QName("http://www.plexus-online.com/Production", "RecordProductionResponse")).next(); SOAPElement rpres = (SOAPElement) rpr.getChildElements(new QName("http://www.plexus-online.com/Production","RecordProductionResult")).next(); try { String error = ((SOAPElement) rpres.getChildElements(new QName("http://www.plexus-online.com/Production", "Error")).next()).getTextContent(); String errorNo = ((SOAPElement) rpres.getChildElements(new QName("http://www.plexus-online.com/Production", "ErrorNo")).next()).getTextContent(); String message = ((SOAPElement) rpres.getChildElements(new QName("http://www.plexus-online.com/Production", "Message")).next()).getTextContent(); setOutError(new BStatusBoolean(true)); setOutErrorNo(new BStatusNumeric(Integer.valueOf(errorNo))); setOutErrorMessage(new BStatusString(message)); return; } catch (NoSuchElementException e) { //do nothing } setOutError(new BStatusBoolean(false)); setOutErrorNo(new BStatusNumeric(0)); setOutErrorMessage(new BStatusString("")); SOAPElement label = (SOAPElement) rpres.getChildElements(new QName("http://www.plexus-online.com/Production","Label")).next(); */ } public void composeSoap(SOAPElement element, BComponent component){ BComponent[] children = (BComponent[]) component.getChildren(XmlTag.class); for (BComponent child : children) { if (child instanceof BXmlContainer) { SOAPElement newElement; try { newElement = element.addChildElement(child.getName()); } catch (SOAPException e) { throw new BajaRuntimeException(e); } composeSoap(newElement, child); } else { String value = ""; if (child instanceof BBooleanWritable) { value = ((BBooleanWritable) child).getBoolean() ? "true" : "false"; } else if (child instanceof BNumericWritable) { value = Double.toString(((BNumericWritable) child).getOut().getValue()); } else if (child instanceof BStringWritable) { value = ((BStringWritable) child).getOut().getValue(); } else { value = "null"; } try { element.addChildElement(child.getName()).addTextNode(value); } catch (SOAPException e) { throw new BajaRuntimeException(e); } } } } public static final Property inWsdl = newProperty(Flags.SUMMARY, ""); public String getInWsdl() { return getString(inWsdl); } public void setInWsdl(String v) { setString(inWsdl, v); } public static final Property wsdlString = newProperty(0, ""); public String getWsdlString() { return getString(wsdlString); } public void setWsdlString(String v) { setString(wsdlString, v); } public static final Property outResponse = newProperty(Flags.SUMMARY, new BStatusString()); public BStatusString getOutResponse() { return (BStatusString) get(outResponse); } public void setOutResponse(BStatusString v) { set(outResponse, v); } public static final Property httpLogin = newProperty(0, ""); public String getHttpLogin() { return getString(httpLogin); } public void setHttpLogin(String v) { setString(httpLogin, v); } public static final Property httpPassword = newProperty(0, BPassword.DEFAULT); public BPassword getHttpPassword() { return (BPassword) get(httpPassword); } public void setHttpPassword(BPassword v) { set(httpPassword, v); } public static final Type TYPE = Sys.loadType(BGenericWsOperation.class); public Type getType() { return TYPE; } } Node-path: niagara/korsPlexusWs/src/com/korsengineering/niagara/plexus/ws/BXmlBoolean.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 342 Text-content-md5: 9e3a89d3c0fb829d3582050c395b87b5 Text-content-sha1: 31bf6633cbddcbd64930abb0bb78e9eaf40a1b62 Content-length: 352 PROPS-END package com.korsengineering.niagara.plexus.ws; import javax.baja.control.BBooleanWritable; import javax.baja.sys.Sys; import javax.baja.sys.Type; public class BXmlBoolean extends BBooleanWritable implements XmlTag { public static final Type TYPE = Sys.loadType(BXmlBoolean.class); public Type getType() { return TYPE; } } Node-path: niagara/korsPlexusWs/src/com/korsengineering/niagara/plexus/ws/BXmlContainer.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 325 Text-content-md5: 6f7fd6321b7ce4de7f12b77e84ce959e Text-content-sha1: 57a8276db588bc1f854dc186211d520ec63eee1a Content-length: 335 PROPS-END package com.korsengineering.niagara.plexus.ws; import javax.baja.sys.Sys; import javax.baja.sys.Type; import javax.baja.util.BFolder; public class BXmlContainer extends BFolder implements XmlTag { public static final Type TYPE = Sys.loadType(BXmlContainer.class); public Type getType() { return TYPE; } } Node-path: niagara/korsPlexusWs/src/com/korsengineering/niagara/plexus/ws/BXmlNumber.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 340 Text-content-md5: e5524a8a9b9414499df56f22f0b30915 Text-content-sha1: f688584af17f90e4338e98309e923ce3c7552dcf Content-length: 350 PROPS-END package com.korsengineering.niagara.plexus.ws; import javax.baja.control.BNumericWritable; import javax.baja.sys.Sys; import javax.baja.sys.Type; public class BXmlNumber extends BNumericWritable implements XmlTag { public static final Type TYPE = Sys.loadType(BXmlNumber.class); public Type getType() { return TYPE; } } Node-path: niagara/korsPlexusWs/src/com/korsengineering/niagara/plexus/ws/BXmlString.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 338 Text-content-md5: 35bf97447d9571abd82eb5eff00dc81f Text-content-sha1: 6d87a30ee0fb0b233f04b9fb839883f359bf78bd Content-length: 348 PROPS-END package com.korsengineering.niagara.plexus.ws; import javax.baja.control.BStringWritable; import javax.baja.sys.Sys; import javax.baja.sys.Type; public class BXmlString extends BStringWritable implements XmlTag { public static final Type TYPE = Sys.loadType(BXmlString.class); public Type getType() { return TYPE; } } Node-path: niagara/korsPlexusWs/src/com/korsengineering/niagara/plexus/ws/XElemSearcher.java Node-kind: file Node-action: replace Prop-content-length: 10 Text-content-length: 6573 Text-content-md5: 58352367a7f0a104d7b83dacc74f683b Text-content-sha1: 0fad7eaa9507fa645e1625de072716134156bb02 Content-length: 6583 PROPS-END package com.korsengineering.niagara.plexus.ws; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import javax.baja.xml.XElem; import javax.baja.xml.XException; import javax.baja.xml.XNs; public class XElemSearcher{ // ==Static things== static boolean matches(XElem elem, Map filter){ Set keys = filter.keySet(); for (Iterator iterator = keys.iterator(); iterator.hasNext(); ) { String name = iterator.next(); String value = filter.get(name); if (value != null) { //check for specific value try { if (!elem.get(name).equals(value)) { return false; } } catch (XException e) { return false; } } else { //check whether attribute exists try { elem.get(name); //calling for exceptions only } catch (XException e) { return false; } } } return true; } @SuppressWarnings ("unchecked") public static T[] concat(T[]... arrays) { int count = 0; for (T[] array : arrays) { count += array.length; } // create new array T[] rv = (T[]) Array.newInstance(arrays[0][0].getClass(), count); int start = 0; for (T[] array : arrays) { System.arraycopy(array,0,rv,start,array.length); start += array.length; } return (T[]) rv; } public static Map makeFilter(String[]... pairs){ Map filter = new HashMap(); for (String[] pair : pairs) { if (pair.length != 2) { throw new Error("Invalid pair length"); } filter.put(pair[0], pair[1]); } return filter; } // ==Dynamic things== protected XElem coreElem; public XElemSearcher(XElem elem){ if (elem == null) { throw new NullPointerException(); } coreElem = elem; } public final XElem[] elems(Map filter) { XElem[] elems = coreElem.elems(); List results = new ArrayList(); for (XElem elem : elems) { if (matches(elem, filter)) { results.add(elem); } } return results.toArray(new XElem[0]); } public final XElem elem(Map filter) { XElem[] elems = coreElem.elems(); for (XElem elem : elems) { if (matches(elem, filter)) { return elem; } } return null; } public final XElem elem(String name, Map filter) { XElem[] elems = elems(filter); for (XElem elem : elems) { if (elem.name().equals(name)) { return elem; } } return null; } public final XElem elem(XNs ns, String name, Map filter) { XElem[] elems = elems(filter); for (XElem elem : elems) { if (elem.name().equals(name) && elem.ns().equals(ns)) { return elem; } } return null; } public final XElem[] elems(String name, Map filter) { XElem[] elems = coreElem.elems(); List results = new ArrayList(); for (XElem elem : elems) { if (matches(elem, filter) && elem.name().equals(name)) { results.add(elem); } } return results.toArray(new XElem[0]); } public final XElem[] elems(XNs ns, String name, Map filter) { XElem[] elems = coreElem.elems(); List results = new ArrayList(); for (XElem elem : elems) { if (matches(elem, filter) && elem.name().equals(name) && elem.ns().equals(ns)) { results.add(elem); } } return results.toArray(new XElem[0]); } public final XElem[] elems(XNs ns, Map filter) { XElem[] elems = coreElem.elems(); List results = new ArrayList(); for (XElem elem : elems) { if (matches(elem, filter) && elem.ns().equals(ns)) { results.add(elem); } } return results.toArray(new XElem[0]); } //Methods that operate recursively public final XElem[] subelems() { XElem[] elems = coreElem.elems(); XElem[] subelems = coreElem.elems(); for (XElem elem : elems) { subelems = concat(subelems, new XElemSearcher(elem).subelems()); } return subelems; } public final XElem[] subelems(Map filter) { XElem[] elems = subelems(); List results = new ArrayList(); for (XElem elem : elems) { if (matches(elem, filter)) { results.add(elem); } } return results.toArray(new XElem[0]); } public final XElem subelem(String name) { XElem[] elems = subelems(); for (XElem elem : elems) { if (elem.name().equals(name)) { return elem; } } return null; } public final XElem[] subelems(String name) { XElem[] elems = subelems(); List results = new ArrayList(); for (XElem elem : elems) { if (elem.name().equals(name)) { results.add(elem); } } return results.toArray(new XElem[0]); } public final XElem subelem(String name, Map filter) { XElem[] elems = subelems(filter); for (XElem elem : elems) { if (elem.name().equals(name)) { return elem; } } return null; } public final XElem subelem(XNs ns, String name, Map filter) { XElem[] elems = subelems(filter); for (XElem elem : elems) { if (elem.name().equals(name) && elem.ns().equals(ns)) { return elem; } } return null; } public final XElem[] subelems(String name, Map filter) { XElem[] elems = subelems(); ArrayList results = new ArrayList(); for (XElem elem : elems) { if (matches(elem, filter) && elem.name().equals(name)) { results.add(elem); } } return results.toArray(new XElem[0]); } public final XElem[] subelems(XNs ns, String name, Map filter) { XElem[] elems = subelems(); ArrayList results = new ArrayList(); for (XElem elem : elems) { if (matches(elem, filter) && elem.name().equals(name) && elem.ns().equals(ns)) { results.add(elem); } } return results.toArray(new XElem[0]); } public final XElem[] subelems(XNs ns, Map filter) { XElem[] elems = subelems(); ArrayList results = new ArrayList(); for (XElem elem : elems) { if (matches(elem, filter) && elem.ns().equals(ns)) { results.add(elem); } } return results.toArray(new XElem[0]); } } Node-path: niagara/korsPlexusWs/src/com/korsengineering/niagara/plexus/ws/XmlTag.java Node-kind: file Node-action: add Prop-content-length: 10 Text-content-length: 82 Text-content-md5: ccd218824554d0da406343141fceb309 Text-content-sha1: 68c63370aeb0f09754f95e113ac1a899072da3bb Content-length: 92 PROPS-END package com.korsengineering.niagara.plexus.ws; public interface XmlTag { } Revision-number: 29 Prop-content-length: 99 Content-length: 99 K 7 svn:log V 0 K 10 svn:author V 5 roman K 8 svn:date V 27 2008-04-08T16:29:10.060541Z PROPS-END Node-path: niagara/korsPlexusWs/build.xml Node-kind: file Node-action: change Text-content-length: 411 Text-content-md5: ba2159e2cd79578f8a15f7e088245b33 Text-content-sha1: 311b1229b3d6677bf9e4b4df4c200e15c47fb825 Content-length: 411 Node-path: niagara/korsPlexusWs/module-include.xml Node-kind: file Node-action: change Text-content-length: 576 Text-content-md5: aa8d46174e1154a3bde8e95866dfad51 Text-content-sha1: cde2f007f11c7312ab4d91bed370c102f526554e Content-length: 576 Node-path: niagara/korsPlexusWs/module.palette Node-kind: file Node-action: change Text-content-length: 265 Text-content-md5: 9cceaddbc48844453ba9be89122e85b7 Text-content-sha1: 66cd58f2f10730d924543f68da49371907321b9f Content-length: 265

Revision-number: 30 Prop-content-length: 98 Content-length: 98 K 7 svn:log V 0 K 10 svn:author V 4 mike K 8 svn:date V 27 2008-04-08T16:43:46.893655Z PROPS-END Node-path: niagara/korsPlexus/src/com/korsengineering/niagara/plexus/BReceiver.java Node-kind: file Node-action: change Text-content-length: 15808 Text-content-md5: 419e19c3bdc44d4f8df2fc2e41d8a2b8 Text-content-sha1: 8a835fbd85cd022df469ef5ae9f262ced8cc016c Content-length: 15808 package com.korsengineering.niagara.plexus; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.text.SimpleDateFormat; import java.util.Date; import javax.baja.collection.BICollection; import javax.baja.control.*; import javax.baja.naming.BOrd; import javax.baja.status.*; import javax.baja.sys.*; import javax.baja.web.*; import javax.baja.xml.*; import javax.servlet.http.*; /** * Servlet that responds to Plexus xml requests. * @author Roman Ivanov */ public class BReceiver extends BWebServlet{ public void doPost(WebOp op) throws Exception{ if (getVerbose()) { System.out.println("Started servicing request"); } String response = ""; HttpServletRequest request = op.getRequest(); BufferedReader br = request.getReader(); String buffer = ""; String subBuffer = ""; while ((subBuffer = br.readLine()) != null) { buffer += subBuffer; } if (getVerbose()) { System.out.println("Request: " + buffer); } setLastRequest(new BStatusString(buffer)); XElem result = handleXml(buffer); ByteArrayOutputStream baos = new ByteArrayOutputStream(); XWriter xw = new XWriter(baos); result.write(xw); xw.flush(); baos.flush(); response = baos.toString(); if (getVerbose()) { System.out.println("Response: " + response); } setLastResponse(new BStatusString(response)); op.getHtmlWriter().println(response); if (getVerbose()) { System.out.println("Finished servicing request"); } } /** * Parses the request XML, deduces the points that need to be set, sets them, and sends back a reply. * @param xml * @return * @throws Exception */ public XElem handleXml(String xml) throws Exception{ XElem response = new XElem("", "http://www.plexus-online.com/PLC", "RespondCommand"); XElem root = XParser.make(xml).parse(); XElem[] events = root.elems("Event"); if (events.length == 0) { throw new BajaException("No events supplied in XML"); } for (int i = 0; i < events.length; i++) { XElem event = events[i]; String plc = event.elem("PLC").text().string(); String action = event.elem("Action").text().string(); event.removeContent(event.elem("PLC")); event.removeContent(event.elem("Action")); XElem[] data = event.elem("Data").elems(); XElem responseEvent = new XElem("Event"); responseEvent.addContent(new XElem("Plc").addText(plc)); responseEvent.addContent(new XElem("Action").addText(action)); boolean problems = false; String errors = ""; //check to see if transaction enabled String enabled = getEnabled(plc, action); if(enabled == ""){ if (action.equals("RequestUpdate")) { try { return handleRequestUpdate(plc); } catch (Exception e) { problems = true; errors = e.getMessage(); } } else { for (int j = 0; j < data.length; j++) { try { setPoints(plc, action, data[j].name(), data[j]); } catch (BajaException ex) { problems = true; errors += ex.getMessage() + "\r\n"; } } } } else{ //not enabled, return error code problems = true; errors = enabled; setLastRejection(plc,action); } XElem responseData = new XElem("Data"); if (!problems) { responseData.addContent(new XElem("Status").addText("1")); responseData.addContent(new XElem("StatusMsg").addText("Download Completed Successfuly")); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); Cursor cursor = getPointsByBql("select from control:StringWritable where slotPath like '%/"+plc+"/"+action+"/LastSuccessfulUpdate'"); if (cursor.next()) { ((BStringWritable) cursor.get()).setIn10(new BStatusString(format.format(new Date()))); } else { if (getVerbose()) { System.out.println("No '%/"+plc+"/"+action+"/LastSuccessfulUpdate' slot"); } } //((BStringWritable) BOrd.make("station:|slot:/"+plc+"/LastSuccessfulUpdate").resolve().get()).setIn10(new BStatusString(format.format(new Date()))); } else { responseData.addContent(new XElem("Status").addText("0")); responseData.addContent(new XElem("StatusMsg").addText("Errors: \n\r" + errors)); } responseEvent.addContent(responseData); response.addContent(responseEvent); } return response; } public void setLastSuccessful(String plc,String action){ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); Cursor cursor = getPointsByBql("select from control:StringWritable where slotPath like '%/"+plc+"/"+action+"/LastSuccessfulUpdate'"); if (cursor.next()) { ((BStringWritable) cursor.get()).setIn10(new BStatusString(format.format(new Date()))); } else { if (getVerbose()) { System.out.println("No '%/"+plc+"/"+action+"/LastSuccessfulUpdate' slot"); } } } public void setLastRejection(String plc,String action){ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); Cursor cursor = getPointsByBql("select from control:StringWritable where slotPath like '%/"+plc+"/"+action+"/LastRejectedUpdate'"); if (cursor.next()) { ((BStringWritable) cursor.get()).setIn10(new BStatusString(format.format(new Date()))); } else { if (getVerbose()) { System.out.println("No '%/"+plc+"/"+action+"/LastRejectedUpdate' slot"); } } } /** * Handles RequestUpdate requests, which is a special case as far as requests go. * @param plc * @return */ public XElem handleRequestUpdate(String plc){ Date now = new Date(); SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy"); SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss"); XElem response = new XElem("", "http://www.plexus-online.com/PLC", "RespondCommand"); XElem responseEvent = new XElem("Event"); responseEvent.addContent(new XElem("Plc").addText(plc)); responseEvent.addContent(new XElem("Action").addText("RequestUpdate")); Cursor cursor; XElem responseData = new XElem("Data"); cursor = getPointsByBql("select from control:NumericWritable where slotPath like '%/"+plc+"/RequestUpdate/PartsProduced'"); cursor.next(); BStatusNumeric partsProduced = ((BNumericWritable) cursor.get()).getOut(); if (partsProduced.getStatus().isOk()) { responseData.addContent(new XElem("DataQuality").addText("Good")); responseData.addContent(new XElem("Date").addText(dateFormat.format(now))); responseData.addContent(new XElem("Time").addText(timeFormat.format(now))); cursor = getPointsByBql("select from control:StringWritable where slotPath like '%/"+plc+"/RequestUpdate/PartNumber'"); if (!cursor.next()) { throw new BajaRuntimeException("No such slot"); } BStatusString partNumber = ((BStringWritable) cursor.get()).getOut(); cursor = getPointsByBql("select from control:NumericWritable where slotPath like '%/"+plc+"/RequestUpdate/PartsInBin'"); if (!cursor.next()) { throw new BajaRuntimeException("No such slot"); } BStatusNumeric partsInBin = ((BNumericWritable) cursor.get()).getOut(); cursor = getPointsByBql("select from control:NumericWritable where slotPath like '%/"+plc+"/RequestUpdate/HitsOnTool'"); if (!cursor.next()) { throw new BajaRuntimeException("No such slot"); } BStatusNumeric hitsOnTool = ((BNumericWritable) cursor.get()).getOut(); /* BStatusString partNumber = ((BStringWritable) BOrd.make("station:|slot:/"+plc+"/RequestUpdate/PartNumber").resolve().get()).getOut(); BStatusNumeric partsInBin = ((BNumericWritable) BOrd.make("station:|slot:/"+plc+"/RequestUpdate/PartsInBin").resolve().get()).getOut(); BStatusNumeric hitsOnTool = ((BNumericWritable) BOrd.make("station:|slot:/"+plc+"/RequestUpdate/HitsOnTool").resolve().get()).getOut(); */ responseData.addContent(new XElem("PartsProduced").addText(Double.toString(partsProduced.getValue()))); responseData.addContent(new XElem("PartNumber").addText(partNumber.getValue())); responseData.addContent(new XElem("PartsInBin").addText(Double.toString(partsInBin.getValue()))); responseData.addContent(new XElem("HitsOnTool").addText(Double.toString(hitsOnTool.getValue()))); responseData.addContent(new XElem("Status").addText("1")); responseData.addContent(new XElem("StatusMsg").addText("Download Completed Successfully")); setLastSuccessful(plc,"RequestUpdate"); } else { responseData.addContent(new XElem("DataQuality").addText("Bad")); responseData.addContent(new XElem("Date").addText(dateFormat.format(now))); responseData.addContent(new XElem("Time").addText(timeFormat.format(now))); responseData.addContent(new XElem("Status").addText("0")); responseData.addContent(new XElem("StatusMsg").addText("PLC Data Point Status BAD")); } responseEvent.addContent(responseData); response.addContent(responseEvent); return response; } /** * @param plc * @param action * @param name * @param point * @throws BajaException */ public void setPoints(String plc, String action, String name, XElem point) throws BajaException { XElem[] subpoints = point.elems(); String errors = ""; boolean problems = false; if (subpoints.length != 0) { for (int i = 0; i < subpoints.length; i++) { try { setPoints(plc, action, name + "/" + subpoints[i].name(), subpoints[i]); } catch (BajaException ex) { problems = true; errors += ex.getMessage() + "\r\n"; } } } else { if (getVerbose()) { System.out.println(plc); System.out.println(action); System.out.println(name); } if(point.text()!=null) { if (getVerbose()) {System.out.println(point.text().length());} setPoint(plc, action, name, point.text().string()); } else { setPoint(plc, action, name, ""); } } if (problems) { throw new BajaException(errors); } } /** * @param plc * @param action * @param point * @param value * @throws BajaException */ public void setPoint(String plc, String action, String point, String value) throws BajaException{ if (getVerbose()) {System.out.println("Trying to set a point: /" +plc+"/"+action+"/"+point);} if (value == null) { value = ""; } /*BOrd ord = BOrd.make("station:|slot:|bql:select from control:StringWritable where slotPath like '%/"+plc+"/"+action+"/"+point+"'"); BICollection result = (BICollection) ord.resolve().get(); Cursor cursor = result.cursor();*/ boolean changedSomething = false; Cursor cursor = getPointsByBql("select from control:StringWritable where slotPath like '%/"+plc+"/"+action+"/"+point+"'"); while (cursor.next()) { ((BStringWritable) cursor.get()).setIn10(new BStatusString(value)); changedSomething = true; } if (!changedSomething) { throw new BajaException("Tag not found: /"+plc+"/"+action+"/"+point); } } public String getEnabled(String plc, String action){ //this method checks for a "Enabled" bit in the action folder //if it exists and is false, checks for a "ResposeString" to return String resp = ""; try{ Cursor cursor = getPointsByBql("select from control:BooleanWritable where slotPath like '%/"+plc+"/"+action+"/Enabled'"); if(cursor!=null){ cursor.next(); BBooleanWritable b = ((BBooleanWritable) cursor.get()); //b.setValue(((BStatusBoolean) cursor.get()).getBoolean()); if(!b.getBoolean()){ //action is disabled, get the reason code to return to POL Cursor cursorS = getPointsByBql("select from control:StringWritable where slotPath like '%/"+plc+"/"+action+"/ResponseString'"); if(cursorS!=null){ cursorS.next(); resp = ((BStringWritable) cursorS.get()).getOut().getValue(); } } } } catch (Exception e){ //if error, just return "" System.out.println(e.toString()); resp = ""; } return resp; } /** * Utility method. * @param bql * @return Cursor with the points found by the given BQL statement. */ public Cursor getPointsByBql(String bql){ BOrd ord = BOrd.make("station:|slot:|bql:"+bql); BICollection result = (BICollection) ord.resolve().get(); return result.cursor(); } /** * When set to true, allows the obejct to output various debugging information (mostly errors) into the console. */ public static final Property verbose = newProperty(0, false); public boolean getVerbose() { return getBoolean(verbose); } public void setVerbose(boolean v) { setBoolean(verbose, v); } /** * Contents of the last request (i.e. request sent by Plexus side). */ public static final Property lastRequest = newProperty(0, new BStatusString()); public BStatusString getLastRequest() { return (BStatusString)get(lastRequest); } public void setLastRequest(BStatusString v) { set(lastRequest, v); } /** * Contents of the last response (i.e. reply send by this class). */ public static final Property lastResponse = newProperty(0, new BStatusString()); public BStatusString getLastResponse() { return (BStatusString)get(lastResponse); } public void setLastResponse(BStatusString v) { set(lastResponse, v); } public static final Type TYPE = Sys.loadType(BReceiver.class); public Type getType() { return TYPE; } } Revision-number: 31 Prop-content-length: 99 Content-length: 99 K 7 svn:log V 0 K 10 svn:author V 5 roman K 8 svn:date V 27 2008-04-09T17:29:35.006156Z PROPS-END Node-path: niagara/korsPlexusWs/src/com/korsengineering/niagara/plexus/ws/BGenericWsOperation.java Node-kind: file Node-action: change Text-content-length: 13027 Text-content-md5: 62ad158e91c089d07fde2ef36278ca26 Text-content-sha1: ad75a50523983fec01afbec039688ea618d077b7 Content-length: 13027 package com.korsengineering.niagara.plexus.ws; import java.net.URL; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.baja.control.BBooleanWritable; import javax.baja.control.BNumericWritable; import javax.baja.control.BStringWritable; import javax.baja.io.Base64; import javax.baja.security.BPassword; import javax.baja.status.BStatusBoolean; import javax.baja.status.BStatusNumeric; import javax.baja.status.BStatusString; import javax.baja.sys.Action; import javax.baja.sys.BComponent; import javax.baja.sys.BEnum; import javax.baja.sys.BEnumRange; import javax.baja.sys.BajaRuntimeException; import javax.baja.sys.Context; import javax.baja.sys.Flags; import javax.baja.sys.Property; import javax.baja.sys.Sys; import javax.baja.sys.Type; import javax.baja.util.BFolder; import javax.baja.xml.XElem; import javax.baja.xml.XException; import javax.baja.xml.XNs; import javax.baja.xml.XParser; import javax.xml.namespace.QName; import javax.xml.soap.MessageFactory; import javax.xml.soap.MimeHeaders; import javax.xml.soap.SOAPBody; import javax.xml.soap.SOAPConstants; import javax.xml.soap.SOAPElement; import javax.xml.soap.SOAPEnvelope; import javax.xml.soap.SOAPException; import javax.xml.soap.SOAPHeader; import javax.xml.soap.SOAPMessage; import javax.xml.soap.SOAPPart; import javax.xml.ws.Dispatch; import javax.xml.ws.Service; import javax.xml.ws.soap.SOAPBinding; import com.korsengineering.http.HttpSender; public class BGenericWsOperation extends BComponent{ protected XElem root = null; protected Map tagMap = new HashMap(); //protected XNs wsdlNs = new XNs("wsdl", "http://schemas.xmlsoap.org/wsdl/"); static String prefixChop(String name){ String[] nameParts = new String[2]; nameParts = name.split(":", 2); if (nameParts[1] == null) { return name; } return nameParts[1]; } protected XElem getRoot(){ if (root == null) { try { root = XParser.make(getWsdlString()).parse(); } catch (Exception e) { throw new BajaRuntimeException(); } } return root; } public void changed(Property property, Context context){ super.changed(property, context); if (!(Sys.atSteadyState() && isRunning())) { return; } if (property == inWsdl) { onWsdlChange(); /* String[] x = {"one", "two", "three"}; BEnumRange operationsEnum = BEnumRange.make(x); if (get("operation") != null) { remove("operation"); } add("operation", operationsEnum.get(0)); */ } else if (property == getProperty("operation")) { onOperationChange(); } } protected XElem getSoap12Binding(){ XElem[] bindings = getRoot().elems("binding"); for (XElem binding : bindings) { XElem operation = binding.elem(new XNs("soap12", "http://schemas.xmlsoap.org/wsdl/soap12/"), "binding"); if (operation == null) { continue; } return binding; } throw new BajaRuntimeException("Couldn't find SOAP 1.2 binding."); } protected void onWsdlChange(){ try { String xml = HttpSender.get(new URL(getInWsdl()), getHttpLogin(), getHttpPassword().getString()); System.out.println(xml); //TODO delete in production setWsdlString(xml); } catch (Exception e) { throw new BajaRuntimeException(); } XElemSearcher recRoot = new XElemSearcher(getRoot()); XElem soap12binding = getSoap12Binding(); XElem[] operations = soap12binding.elems("operation"); List operationNames = new ArrayList(); operationNames.add("none"); for (XElem opeartion : operations) { operationNames.add(opeartion.get("name")); } if (get("input") != null) { remove("input"); } if (get("output") != null) { remove("output"); } BEnumRange operationsEnum = BEnumRange.make(operationNames.toArray(new String[0])); if (get("operation") != null) { remove("operation"); } add("operation", operationsEnum.get(0)); } protected void onOperationChange(){ String operationName = ((BEnum) get(getProperty("operation"))).getTag(); if (operationName == "none") { return; } Map nameFilter = new HashMap(); //nameFilter.put("name", "WebServiceSoap"); //XElem portType = recRoot.elem("portType", nameFilter); XElem portType = getRoot().elem("portType"); XElemSearcher recRoot = new XElemSearcher(getRoot()); XElemSearcher recPortType = new XElemSearcher(portType); String opName = ((BEnum) get(getProperty("operation"))).getTag(); nameFilter.put("name", opName); XElem operation = recPortType.elem("operation", nameFilter); String inputMessageName = operation.elem("input").get("message"); inputMessageName = prefixChop(inputMessageName); nameFilter.put("name", inputMessageName); String inputElementName = recRoot.elem("message", nameFilter).elem("part").get("element"); String outputMessageName = operation.elem("output").get("message"); outputMessageName = prefixChop(outputMessageName); nameFilter.put("name", outputMessageName); String outputElementName = recRoot.elem("message", nameFilter).elem("part").get("element"); if (getProperty("input") != null) { remove("input"); } BFolder input = new BXmlContainer(); add("input", input); addMessages(input, inputElementName); if (getProperty("output") != null) { remove("output"); } BFolder output = new BXmlContainer(); add("output", output); addMessages(output, outputElementName); } public void addMessages(BComponent base, String name){ name = prefixChop(name); XElemSearcher schema = new XElemSearcher(getRoot().elem("types").elem("schema")); Map nameFilter = new HashMap(); nameFilter.put("name", name); XElem whatever = schema.elem(nameFilter); if (whatever == null) { //no description is schema part return; } XElemSearcher whateverSearcher = new XElemSearcher(whatever); nameFilter.put("name", null); //has some name? nameFilter.put("type", null); //has some type? XElem[] subelems = whateverSearcher.subelems("element", nameFilter); for (XElem subelem : subelems) { String type = ""; String subName = ""; try { type = subelem.get("type"); subName = subelem.get("name"); } catch (XException e) { assert true : "Filtering error"; } if (type.equals("s:string")) { base.add(subName, new BXmlString()); } else if (type.equals("s:double") || type.equals("s:float") || type.equals("s:decimal") || type.equals("s:integer") || type.equals("s:int") || type.equals("s:long")) { base.add(subName, new BXmlNumber()); } else if (type.equals("s:bool") || type.equals("s:boolean")) { base.add(subName, new BXmlBoolean()); } else { BXmlContainer folder = new BXmlContainer(); addMessages(folder, type); XElemSearcher subSearcher = new XElemSearcher(subelem); XElem extension = subSearcher.subelem("extension"); if (extension != null) { String messageBase = prefixChop(extension.get("base")); addMessages(folder, messageBase); } } } } protected String getTargetNs(){ return getRoot().get("targetNamespace"); } protected QName getServiceName(){ String serviceName = getRoot().elem("service").get("name"); return new QName(getTargetNs(), serviceName); } protected QName getPortName(){ String operationName = ((BEnum) get(getProperty("operation"))).getTag(); return new QName(getTargetNs(), operationName); } protected String getSoapAction(){ String operationName = ((BEnum) get(getProperty("operation"))).getTag(); XElem soap12binding = getSoap12Binding(); XElemSearcher bindingSearcher = new XElemSearcher(soap12binding); Map nameFilter = new HashMap(); nameFilter.put("name", operationName); XElem op = bindingSearcher.elem("operation", nameFilter); String url = op.elem("operation").get("soapAction"); return url; } /*protected String getEndpointUrl(){ XElemSearcher serviceSearcher = new XElemSearcher(getRoot().elem("service")); Map nameFilter = new HashMap(); nameFilter.put("name", "WebServiceSoap12"); XElem soap12binding = serviceSearcher.elem("port", nameFilter); return soap12binding.elem("address").get("location"); }*/ public static final Action send = newAction(0); public void send(){ invoke(send, null); } //invokes public void doSend() throws Exception{ Service service = Service.create(getServiceName()); QName portName = getPortName(); service.addPort(portName, SOAPBinding.SOAP12HTTP_BINDING, getSoapAction()); Dispatch dispatch = service.createDispatch(portName, SOAPMessage.class, Service.Mode.MESSAGE); MessageFactory mf = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL); // Create a message. This example works with the SOAPPART. SOAPMessage request = mf.createMessage(); MimeHeaders headers = request.getMimeHeaders(); System.out.println(headers.getAllHeaders()); String authCode = Base64.encode((getHttpLogin() + ":" + getHttpPassword().getString()).getBytes()); headers.addHeader("Authorization", "Basic " + authCode); SOAPPart part = request.getSOAPPart(); // Obtain the SOAPEnvelope and header and body elements. SOAPEnvelope env = part.getEnvelope(); //SOAPHeader header = env.getHeader(); SOAPBody body = env.getBody(); // Construct the message payload. composeSoap(body, (BComponent) getChildren(XmlTag.class)[0]); request.saveChanges(); SOAPMessage response = dispatch.invoke(request); response.writeTo(System.out); //TODO remove in production } public void composeSoap(SOAPElement element, BComponent component){ BComponent[] children = component.getChildComponents(); for (BComponent child : children) { if (!(child instanceof XmlTag)) { continue; } if (child instanceof BXmlContainer) { SOAPElement newElement; try { newElement = element.addChildElement(child.getName()); } catch (SOAPException e) { throw new BajaRuntimeException(e); } composeSoap(newElement, child); } else { String value = ""; if (child instanceof BBooleanWritable) { value = ((BBooleanWritable) child).getBoolean() ? "true" : "false"; } else if (child instanceof BNumericWritable) { value = Double.toString(((BNumericWritable) child).getOut().getValue()); } else if (child instanceof BStringWritable) { value = ((BStringWritable) child).getOut().getValue(); } else { value = "null"; } try { element.addChildElement(child.getName()).addTextNode(value); } catch (SOAPException e) { throw new BajaRuntimeException(e); } } } } public static final Property inWsdl = newProperty(Flags.SUMMARY, ""); public String getInWsdl() { return getString(inWsdl); } public void setInWsdl(String v) { setString(inWsdl, v); } public static final Property wsdlString = newProperty(0, ""); public String getWsdlString() { return getString(wsdlString); } public void setWsdlString(String v) { setString(wsdlString, v); } public static final Property outResponse = newProperty(Flags.SUMMARY, new BStatusString()); public BStatusString getOutResponse() { return (BStatusString) get(outResponse); } public void setOutResponse(BStatusString v) { set(outResponse, v); } public static final Property httpLogin = newProperty(0, ""); public String getHttpLogin() { return getString(httpLogin); } public void setHttpLogin(String v) { setString(httpLogin, v); } public static final Property httpPassword = newProperty(0, BPassword.DEFAULT); public BPassword getHttpPassword() { return (BPassword) get(httpPassword); } public void setHttpPassword(BPassword v) { set(httpPassword, v); } public static final Type TYPE = Sys.loadType(BGenericWsOperation.class); public Type getType() { return TYPE; } } Revision-number: 32 Prop-content-length: 99 Content-length: 99 K 7 svn:log V 0 K 10 svn:author V 5 roman K 8 svn:date V 27 2008-04-09T18:21:53.011212Z PROPS-END Node-path: niagara/korsPlexusWs/src/com/korsengineering/niagara/plexus/ws/BGenericWsOperation.java Node-kind: file Node-action: change Text-content-length: 13181 Text-content-md5: d4ca8ab6a95c62c116987bae3c27e0f0 Text-content-sha1: 779aa8e5fc4aa7f12e4179fff724bd73a8f96ee7 Content-length: 13181 package com.korsengineering.niagara.plexus.ws; import java.net.URL; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.baja.control.BBooleanWritable; import javax.baja.control.BNumericWritable; import javax.baja.control.BStringWritable; import javax.baja.io.Base64; import javax.baja.security.BPassword; import javax.baja.status.BStatusBoolean; import javax.baja.status.BStatusNumeric; import javax.baja.status.BStatusString; import javax.baja.sys.Action; import javax.baja.sys.BComponent; import javax.baja.sys.BEnum; import javax.baja.sys.BEnumRange; import javax.baja.sys.BajaRuntimeException; import javax.baja.sys.Context; import javax.baja.sys.Flags; import javax.baja.sys.Property; import javax.baja.sys.Sys; import javax.baja.sys.Type; import javax.baja.util.BFolder; import javax.baja.xml.XElem; import javax.baja.xml.XException; import javax.baja.xml.XNs; import javax.baja.xml.XParser; import javax.xml.namespace.QName; import javax.xml.soap.MessageFactory; import javax.xml.soap.MimeHeaders; import javax.xml.soap.SOAPBody; import javax.xml.soap.SOAPConstants; import javax.xml.soap.SOAPElement; import javax.xml.soap.SOAPEnvelope; import javax.xml.soap.SOAPException; import javax.xml.soap.SOAPHeader; import javax.xml.soap.SOAPMessage; import javax.xml.soap.SOAPPart; import javax.xml.ws.Dispatch; import javax.xml.ws.Service; import javax.xml.ws.soap.SOAPBinding; import com.korsengineering.http.HttpSender; public class BGenericWsOperation extends BComponent{ protected XElem root = null; protected Map tagMap = new HashMap(); //protected XNs wsdlNs = new XNs("wsdl", "http://schemas.xmlsoap.org/wsdl/"); static String prefixChop(String name){ String[] nameParts = new String[2]; nameParts = name.split(":", 2); if (nameParts[1] == null) { return name; } return nameParts[1]; } protected XElem getRoot(){ if (root == null) { try { root = XParser.make(getWsdlString()).parse(); } catch (Exception e) { throw new BajaRuntimeException(); } } return root; } public void changed(Property property, Context context){ super.changed(property, context); if (!(Sys.atSteadyState() && isRunning())) { return; } if (property == inWsdl) { onWsdlChange(); /* String[] x = {"one", "two", "three"}; BEnumRange operationsEnum = BEnumRange.make(x); if (get("operation") != null) { remove("operation"); } add("operation", operationsEnum.get(0)); */ } else if (property == getProperty("operation")) { onOperationChange(); } } protected XElem getSoap12Binding(){ XElem[] bindings = getRoot().elems("binding"); for (XElem binding : bindings) { XElem operation = binding.elem(new XNs("soap12", "http://schemas.xmlsoap.org/wsdl/soap12/"), "binding"); if (operation == null) { continue; } return binding; } throw new BajaRuntimeException("Couldn't find SOAP 1.2 binding."); } protected void onWsdlChange(){ try { String xml = HttpSender.get(new URL(getInWsdl()), getHttpLogin(), getHttpPassword().getString()); System.out.println(xml); //TODO delete in production setWsdlString(xml); } catch (Exception e) { throw new BajaRuntimeException(); } XElemSearcher recRoot = new XElemSearcher(getRoot()); XElem soap12binding = getSoap12Binding(); XElem[] operations = soap12binding.elems("operation"); List operationNames = new ArrayList(); operationNames.add("none"); for (XElem opeartion : operations) { operationNames.add(opeartion.get("name")); } if (get("input") != null) { remove("input"); } if (get("output") != null) { remove("output"); } BEnumRange operationsEnum = BEnumRange.make(operationNames.toArray(new String[0])); if (get("operation") != null) { remove("operation"); } add("operation", operationsEnum.get(0)); } protected void onOperationChange(){ String operationName = ((BEnum) get(getProperty("operation"))).getTag(); if (operationName == "none") { return; } Map nameFilter = new HashMap(); //nameFilter.put("name", "WebServiceSoap"); //XElem portType = recRoot.elem("portType", nameFilter); XElem portType = getRoot().elem("portType"); XElemSearcher recRoot = new XElemSearcher(getRoot()); XElemSearcher recPortType = new XElemSearcher(portType); String opName = ((BEnum) get(getProperty("operation"))).getTag(); nameFilter.put("name", opName); XElem operation = recPortType.elem("operation", nameFilter); String inputMessageName = operation.elem("input").get("message"); inputMessageName = prefixChop(inputMessageName); nameFilter.put("name", inputMessageName); String inputElementName = recRoot.elem("message", nameFilter).elem("part").get("element"); String outputMessageName = operation.elem("output").get("message"); outputMessageName = prefixChop(outputMessageName); nameFilter.put("name", outputMessageName); String outputElementName = recRoot.elem("message", nameFilter).elem("part").get("element"); if (getProperty("input") != null) { remove("input"); } BFolder input = new BXmlContainer(); add("input", input); addMessages(input, inputElementName); if (getProperty("output") != null) { remove("output"); } BFolder output = new BXmlContainer(); add("output", output); addMessages(output, outputElementName); } public void addMessages(BComponent base, String name){ name = prefixChop(name); XElemSearcher schema = new XElemSearcher(getRoot().elem("types").elem("schema")); Map nameFilter = new HashMap(); nameFilter.put("name", name); XElem whatever = schema.elem(nameFilter); if (whatever == null) { //no description is schema part return; } XElemSearcher whateverSearcher = new XElemSearcher(whatever); nameFilter.put("name", null); //has some name? nameFilter.put("type", null); //has some type? XElem[] subelems = whateverSearcher.subelems("element", nameFilter); for (XElem subelem : subelems) { String type = ""; String subName = ""; try { type = subelem.get("type"); subName = subelem.get("name"); } catch (XException e) { assert true : "Filtering error"; } if (type.equals("s:string")) { base.add(subName, new BXmlString()); } else if (type.equals("s:double") || type.equals("s:float") || type.equals("s:decimal") || type.equals("s:integer") || type.equals("s:int") || type.equals("s:long")) { base.add(subName, new BXmlNumber()); } else if (type.equals("s:bool") || type.equals("s:boolean")) { base.add(subName, new BXmlBoolean()); } else { BXmlContainer folder = new BXmlContainer(); addMessages(folder, type); XElemSearcher subSearcher = new XElemSearcher(subelem); XElem extension = subSearcher.subelem("extension"); if (extension != null) { String messageBase = prefixChop(extension.get("base")); addMessages(folder, messageBase); } } } } protected String getTargetNs(){ return getRoot().get("targetNamespace"); } protected QName getServiceName(){ String serviceName = getRoot().elem("service").get("name"); return new QName(getTargetNs(), serviceName); } protected QName getPortName(){ String operationName = ((BEnum) get(getProperty("operation"))).getTag(); return new QName(getTargetNs(), operationName); } protected String getSoapAction(){ String operationName = ((BEnum) get(getProperty("operation"))).getTag(); XElem soap12binding = getSoap12Binding(); XElemSearcher bindingSearcher = new XElemSearcher(soap12binding); Map nameFilter = new HashMap(); nameFilter.put("name", operationName); XElem op = bindingSearcher.elem("operation", nameFilter); String url = op.elem("operation").get("soapAction"); return url; } /*protected String getEndpointUrl(){ XElemSearcher serviceSearcher = new XElemSearcher(getRoot().elem("service")); Map nameFilter = new HashMap(); nameFilter.put("name", "WebServiceSoap12"); XElem soap12binding = serviceSearcher.elem("port", nameFilter); return soap12binding.elem("address").get("location"); }*/ public static final Action send = newAction(0); public void send(){ invoke(send, null); } //invokes public void doSend() throws Exception{ Service service = Service.create(getServiceName()); QName portName = getPortName(); service.addPort(portName, SOAPBinding.SOAP12HTTP_BINDING, getSoapAction()); System.out.println("Sending request to " + getSoapAction()); Dispatch dispatch = service.createDispatch(portName, SOAPMessage.class, Service.Mode.MESSAGE); MessageFactory mf = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL); // Create a message. This example works with the SOAPPART. SOAPMessage request = mf.createMessage(); MimeHeaders headers = request.getMimeHeaders(); String authCode = Base64.encode((getHttpLogin() + ":" + getHttpPassword().getString()).getBytes()); headers.addHeader("Authorization", "Basic " + authCode); SOAPPart part = request.getSOAPPart(); // Obtain the SOAPEnvelope and header and body elements. SOAPEnvelope env = part.getEnvelope(); //SOAPHeader header = env.getHeader(); SOAPBody body = env.getBody(); // Construct the message payload. BComponent[] children = getChildComponents(); for (BComponent child : children) { if (child.getName() == "input") { composeSoap(body, child); } } request.saveChanges(); SOAPMessage response = dispatch.invoke(request); response.writeTo(System.out); //TODO remove in production } public void composeSoap(SOAPElement element, BComponent component){ BComponent[] children = component.getChildComponents(); for (BComponent child : children) { if (!(child instanceof XmlTag)) { continue; } if (child instanceof BXmlContainer) { SOAPElement newElement; try { newElement = element.addChildElement(child.getName()); } catch (SOAPException e) { throw new BajaRuntimeException(e); } composeSoap(newElement, child); } else { String value = ""; if (child instanceof BBooleanWritable) { value = ((BBooleanWritable) child).getBoolean() ? "true" : "false"; } else if (child instanceof BNumericWritable) { value = Double.toString(((BNumericWritable) child).getOut().getValue()); } else if (child instanceof BStringWritable) { value = ((BStringWritable) child).getOut().getValue(); } else { value = "null"; } try { element.addChildElement(child.getName()).addTextNode(value); } catch (SOAPException e) { throw new BajaRuntimeException(e); } } } } public static final Property inWsdl = newProperty(Flags.SUMMARY, ""); public String getInWsdl() { return getString(inWsdl); } public void setInWsdl(String v) { setString(inWsdl, v); } public static final Property wsdlString = newProperty(0, ""); public String getWsdlString() { return getString(wsdlString); } public void setWsdlString(String v) { setString(wsdlString, v); } public static final Property outResponse = newProperty(Flags.SUMMARY, new BStatusString()); public BStatusString getOutResponse() { return (BStatusString) get(outResponse); } public void setOutResponse(BStatusString v) { set(outResponse, v); } public static final Property httpLogin = newProperty(0, ""); public String getHttpLogin() { return getString(httpLogin); } public void setHttpLogin(String v) { setString(httpLogin, v); } public static final Property httpPassword = newProperty(0, BPassword.DEFAULT); public BPassword getHttpPassword() { return (BPassword) get(httpPassword); } public void setHttpPassword(BPassword v) { set(httpPassword, v); } public static final Type TYPE = Sys.loadType(BGenericWsOperation.class); public Type getType() { return TYPE; } } Revision-number: 33 Prop-content-length: 99 Content-length: 99 K 7 svn:log V 0 K 10 svn:author V 5 roman K 8 svn:date V 27 2008-04-10T18:59:48.471338Z PROPS-END Node-path: niagara/korsPlexusWs/src/com/korsengineering/niagara/plexus/ws/BGenericWsOperation.java Node-kind: file Node-action: change Text-content-length: 14988 Text-content-md5: b502291850344285dd0474273ab1fccc Text-content-sha1: 1359df646a20076a4db01743c98865c6f83537b9 Content-length: 14988 package com.korsengineering.niagara.plexus.ws; import java.net.URL; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.baja.control.BBooleanWritable; import javax.baja.control.BNumericWritable; import javax.baja.control.BStringWritable; import javax.baja.io.Base64; import javax.baja.security.BPassword; import javax.baja.status.BStatusBoolean; import javax.baja.status.BStatusNumeric; import javax.baja.status.BStatusString; import javax.baja.sys.Action; import javax.baja.sys.BComponent; import javax.baja.sys.BEnum; import javax.baja.sys.BEnumRange; import javax.baja.sys.BajaRuntimeException; import javax.baja.sys.Context; import javax.baja.sys.Flags; import javax.baja.sys.Property; import javax.baja.sys.Sys; import javax.baja.sys.Type; import javax.baja.util.BFolder; import javax.baja.util.LongHashMap.Iterator; import javax.baja.xml.XElem; import javax.baja.xml.XException; import javax.baja.xml.XNs; import javax.baja.xml.XParser; import javax.xml.namespac