public String toString() { if (empty) return "Empty TFN"; if (m.isEmpty() && p.isEmpty()) return pfn.toString(); if ((!m.isEmpty()) && p.isEmpty()) return m.toString() + pfn.toString(); return m + ":" + p + pfn; }
/** Returns the time in which the last crate will be unloaded. */ public double getUnloadTime(int floor, double time) { direction = NEUTRAL; int i; Port p = (Port) (outPorts.front()); Crate c; double lastUnloadTime = time; if (floor == WarehouseFloor.MIDDLE) // unload type B and C { lastUnloadTime = time + numA * Crate.A_UNLOAD_TIME; for (i = 0; i < CRATE_CAPACITY; i++) { if ((c = crate[i]) != null && c.type().equals("B")) { lastUnloadTime += Crate.B_UNLOAD_TIME; p.enter(c, lastUnloadTime); } else if ((c = crate[i]) != null && c.type().equals("C")) { lastUnloadTime += Crate.C_UNLOAD_TIME; p.enter(c, lastUnloadTime); } } } else if (floor == WarehouseFloor.TOP) // unload type A { for (i = 0; i < CRATE_CAPACITY; i++) { if ((c = crate[i]) != null && c.type().equals("A")) { lastUnloadTime += Crate.A_UNLOAD_TIME; p.enter(c, lastUnloadTime); } } } return lastUnloadTime; }
public static CatInfo fromPort(Port port) { CatInfo info = new CatInfo(); info.name = port.name; info.value = port.getValue(); info.type = port.getType(); info.readOnly = false; info.leaf = true; return info; }
public static ArrayList<Message> allOutgoingMessages(Thing thing) { ArrayList<Message> result = new ArrayList<Message>(); for (Port p : allPorts(thing)) { for (Message m : p.getSends()) { if (!result.contains(m)) result.add(m); } } return result; }
/** * Test the creation of port. * * @throws Exception */ @Test public void testPort() throws Exception { Port port = new Port("name", "networkId", "tenantId", "deviceOwner", "portId"); Port port2 = new Port("name2", "networkId", "tenantId", "deviceOwner", "2"); assertEquals(port.getName(), "name"); assertEquals(port.getNetworkId(), "networkId"); assertEquals(port.equals(port2), false); }
private void port_set_device(int portnumber, Device device) { Port p = port[portnumber]; p.device = device; p.counter0 = 0; p.counter1 = 0; // set iobit to true if device is capable of latching PPU counters // iobit = port[1].device == Device.SuperScope // || port[1].device == Device.Justifier // || port[1].device == Device.Justifiers; // latchx = -1; // latchy = -1; // // if (device == Device.SuperScope) // { // p.superscope.x = 256 / 2; // p.superscope.y = 240 / 2; // // p.superscope.trigger = false; // p.superscope.cursor = false; // p.superscope.turbo = false; // p.superscope.pause = false; // p.superscope.offscreen = false; // // p.superscope.turbolock = false; // p.superscope.triggerlock = false; // p.superscope.pauselock = false; // } // else if (device == Device.Justifier) // { // p.justifier.active = false; // p.justifier.x1 = 256 / 2; // p.justifier.y1 = 240 / 2; // p.justifier.x2 = -1; // p.justifier.y2 = -1; // // p.justifier.trigger1 = false; // p.justifier.trigger2 = false; // p.justifier.start1 = false; // p.justifier.start2 = false; // } // else if (device == Device.Justifiers) // { // p.justifier.active = false; // p.justifier.x1 = 256 / 2 - 16; // p.justifier.y1 = 240 / 2; // p.justifier.x2 = 256 / 2 + 16; // p.justifier.y2 = 240 / 2; // // p.justifier.trigger1 = false; // p.justifier.trigger2 = false; // p.justifier.start1 = false; // p.justifier.start2 = false; // } }
@Override public double getMin(int dim, Port port) { switch (dim) { case 0: return port.getSrcLowerCorner().getBlockX(); case 1: return port.getSrcLowerCorner().getBlockZ(); } return 0; }
public static ArrayList<Port> findPort(Thing thing, String name, boolean fuzzy) { ArrayList<Port> result = new ArrayList<Port>(); for (Port t : allPorts(thing)) { if (t.getName().startsWith(name)) { if (fuzzy) result.add(t); else if (t.getName().equals(name)) result.add(t); } } return result; }
/** * Returns a printable representation of this header. * * @param filter FormatProperties object for filtering this header. * @return Returns a string representation of this header. */ public String toString(FormatProperties filter) { // Check for Port filtering if (filter != null) { // If filter is enabled boolean print = false; String port = filter.getPort(); if (port == null) { print = true; // The filtering doesn't apply to this header } else if (port.equals(sourceport.toString()) || port.equals(destport.toString())) { print = true; } if (!print) { // Don't print the packet if (Trace.isTraceOn() && Trace.isTraceInformationOn()) { Trace.log(Trace.INFORMATION, CLASS + ".toString() " + "Not printing record"); } return ""; // Return empty record because it didn't pass the filter } } String portname = (String) Port.get(this.sourceport.toString()); String portname2 = (String) Port.get(this.destport.toString()); // Make sure we have enough data to parse a full header if (rawheader.getBitSize() < getHeaderLen()) { return (new Data(rawheader)).toString(); } if (portname == null) { portname = UNASSIGNED; } if (portname2 == null) { portname2 = UNASSIGNED; } String sourceport = this.sourceport.toString() + ", " + portname; String destport = this.destport.toString() + ", " + portname2; Object[] args = {sourceport, destport, length, checksum}; return Formatter.jsprintf( "\t " + UDPSTR + " . . . . : " + SRC + ": {0,18,L} " + DST + ": {1,18,L}\n" + "\t\t\t " + LEN + ": {2,5,L} " + CHKSUM + ": {3}\n", args) + printHexHeader() + printnext(filter) + (new Data(rawpayload)).toString(); }
public void shutDown() { for (Port port : m_OpenPorts.values()) { try { log = log && log(1, "shutDown() closing port %d\n", port.m_FD); port.close(); } catch (Exception e) { // should never happen e.printStackTrace(); } } }
public static int getPort(Class<?> klass) { Port portAnnotation = klass.getAnnotation(Port.class); if (null == portAnnotation) { return 0; } int lport = portAnnotation.value(); if (!"".equals(portAnnotation.systemProperty())) { lport = Integer.getInteger(portAnnotation.systemProperty(), lport); } return lport; }
public int tcdrain(int fd) { Port port = getPort(fd); if (port == null) return -1; try { synchronized (port.m_WrBuffer) { if (!FlushFileBuffers(port.m_Comm)) port.fail(); return 0; } } catch (Fail f) { return -1; } }
public int fcntl(int fd, int cmd, int arg) { Port port = getPort(fd); if (port == null) return -1; if (F_SETFL == cmd) port.m_OpenFlags = arg; else if (F_GETFL == cmd) return port.m_OpenFlags; else { m_ErrNo = ENOTSUP; return -1; } return 0; }
public int tcsendbreak(int fd, int duration) { Port port = getPort(fd); if (port == null) return -1; try { if (!SetCommBreak(port.m_Comm)) port.fail(); nanoSleep(duration * 250000000); if (!ClearCommBreak(port.m_Comm)) port.fail(); return 0; } catch (Fail f) { return -1; } }
public void execute(ApplicationData MyApplicationData) { int port = MyApplicationData.getPort(); String note = (String) (MyApplicationData.getParameters()); Iterator PortIterator = super.getComputer().getPorts().entrySet().iterator(); while (PortIterator.hasNext()) { Port TempPort = (Port) (((Map.Entry) PortIterator.next()).getValue()); if (TempPort.getNumber() == port) { TempPort.setNote(note); } } }
@Override public boolean equals(Object other) { if (!(other instanceof Port)) { return false; } Port p = (Port) other; if (protocol != null) { return port == p.getPort() && protocol.equalsIgnoreCase(p.getProtocol()); } return false; }
private void build(Port port) { if (wsdlModeler.isProvider(port)) return; Binding binding = port.resolveBinding(wsdlDocument); SOAPBinding soapBinding = (SOAPBinding) getExtensionOfType(binding, SOAPBinding.class); // lets try and see if its SOAP 1.2. dont worry about extension flag, its // handled much earlier if (soapBinding == null) { soapBinding = (SOAPBinding) getExtensionOfType(binding, SOAP12Binding.class); } if (soapBinding == null) return; PortType portType = binding.resolvePortType(wsdlDocument); QName bindingName = WSDLModelerBase.getQNameOf(binding); // we dont want to process the port bound to the binding processed earlier if (bindingNameToPortMap.containsKey(bindingName)) return; bindingNameToPortMap.put(bindingName, port); for (Iterator itr = binding.operations(); itr.hasNext(); ) { BindingOperation bindingOperation = (BindingOperation) itr.next(); // get only the bounded operations Set boundedOps = portType.getOperationsNamed(bindingOperation.getName()); if (boundedOps.size() != 1) continue; Operation operation = (Operation) boundedOps.iterator().next(); // No pseudo schema required for doc/lit if (wsdlModeler.isAsync(portType, operation)) { buildAsync(portType, operation, bindingOperation); } } }
@Override public int hashCode() { int result = id; result = 31 * result + (port != null ? port.hashCode() : 0); result = 31 * result + (date != null ? date.hashCode() : 0); return result; }
/** * Generic transaction. * * <p>This is a lower-level interface to the I2C hardware giving you more control over each * transaction. * * @param dataToSend Buffer of data to send as part of the transaction. * @param sendSize Number of bytes to send as part of the transaction. [0..6] * @param dataReceived Buffer to read data into. * @param receiveSize Number of bytes to read from the device. [0..7] * @return Transfer Aborted... false for success, true for aborted. */ public synchronized boolean transaction( byte[] dataToSend, int sendSize, byte[] dataReceived, int receiveSize) { boolean aborted = true; ByteBuffer dataToSendBuffer = ByteBuffer.allocateDirect(sendSize); dataToSendBuffer.put(dataToSend); ByteBuffer dataReceivedBuffer = ByteBuffer.allocateDirect(receiveSize); aborted = I2CJNI.i2CTransaction( (byte) m_port.getValue(), (byte) m_deviceAddress, dataToSendBuffer, (byte) sendSize, dataReceivedBuffer, (byte) receiveSize) != 0; /*if (status.get() == HALUtil.PARAMETER_OUT_OF_RANGE) { if (sendSize > 6) { throw new BoundaryException(BoundaryException.getMessage( sendSize, 0, 6)); } else if (receiveSize > 7) { throw new BoundaryException(BoundaryException.getMessage( receiveSize, 0, 7)); } else { throw new RuntimeException( HALLibrary.PARAMETER_OUT_OF_RANGE_MESSAGE); } } HALUtil.checkStatus(status);*/ if (receiveSize > 0 && dataReceived != null) { dataReceivedBuffer.get(dataReceived); } return aborted; }
@Override public void send(Event e, Port p) { if (p.getName().equals("IOStream")) { IOStreamPort_out.send(e); } else { // Internal channel managed by ThingML super.send(e, p); } }
protected static boolean test() { Port port = new Port(0x12345678); port.byte1 = 42; if (port.byte1 == 42) { if (port.byte2 != 42) { port.short1 = (short) 0xfefe; if (port.short1 == (short) 0xfefe) { port.int1 = 0xabbaabba; if (port.int1 == 0xabbaabba) { return false; } } } } return true; }
/** * Execute a write transaction with the device. * * <p>Write multiple bytes to a register on a device and wait until the transaction is complete. * * @param data The data to write to the device. */ public synchronized boolean writeBulk(byte[] data) { ByteBuffer dataToSendBuffer = ByteBuffer.allocateDirect(data.length); dataToSendBuffer.put(data); return I2CJNI.i2CWrite( (byte) m_port.getValue(), (byte) m_deviceAddress, dataToSendBuffer, (byte) data.length) < 0; }
/** * Unlink the specified Relation. If the Relation is not linked to this port, do nothing. If the * relation is linked more than once, then unlink all occurrences. If there is a container, notify * it by calling connectionsChanged(). This overrides the base class to check to see whether the * link is an inside link, based on the container of the relation, and to call unlinkInside() if * it is. This method is write-synchronized on the workspace and increments its version number. * * @param relation The relation to unlink. */ public void unlink(Relation relation) { if ((relation != null) && _isInsideLinkable(relation.getContainer())) { // An inside link unlinkInside(relation); } else { super.unlink(relation); } }
/** * Test the behaviour of {@link Node#stampDirty()}. * * @throws ExpressionError if the expression causes an error. This indicates a regression. */ public void testMarkStampedDirty() throws ExpressionError { // Setup a graph where a <- b <- c. Node a = Node.ROOT_NODE.newInstance(testLibrary, "a", Integer.class); Node b = Node.ROOT_NODE.newInstance(testLibrary, "b", Integer.class); Node c = Node.ROOT_NODE.newInstance(testLibrary, "c", Integer.class); a.addParameter("a", Parameter.Type.INT); b.addParameter("b", Parameter.Type.INT); Port bIn = b.addPort("in"); Port cIn = c.addPort("in"); bIn.connect(a); cIn.connect(b); // Update the graph. This will make a, b and c clean. c.update(); assertFalse(a.isDirty()); assertFalse(b.isDirty()); assertFalse(c.isDirty()); // Set b to a stamped expression. This will make node b, and all of its dependencies, dirty. b.setExpression("b", "stamp(\"my_b\", 55)"); assertTrue(b.hasStampExpression()); assertFalse(a.isDirty()); assertTrue(b.isDirty()); assertTrue(c.isDirty()); // Update the graph, cleaning all of the nodes. c.update(); assertFalse(a.isDirty()); assertFalse(b.isDirty()); assertFalse(c.isDirty()); // Mark only stamped upstream nodes as dirty. This will make b dirty, and all of its // dependencies. c.stampDirty(); assertFalse(a.isDirty()); assertTrue(b.isDirty()); assertTrue(c.isDirty()); // Remove the expression and update. This will make all nodes clean again. b.clearExpression("b"); c.update(); // Node b will not be dirty, since everything was updated. assertFalse(b.isDirty()); // Since there are no nodes with stamp expressions, marking the stamped upstream nodes will have // no effect. c.stampDirty(); assertFalse(a.isDirty()); assertFalse(b.isDirty()); assertFalse(c.isDirty()); }
public int hashCode() { if (empty) return 0; int hash = 17; hash = 37 * hash + m.hashCode(); hash = 37 * hash + p.hashCode(); hash = 37 * hash + pfn.hashCode(); return hash; }
/** Test if the attributes on ports are set correctly. */ public void testPortAttributes() { Node nodeA = Node.ROOT_NODE.newInstance(testLibrary, "A", String.class); assertEquals(String.class, nodeA.getDataClass()); Port outputPort = nodeA.getOutputPort(); assertEquals("output", outputPort.getName()); assertEquals(Port.Direction.OUT, outputPort.getDirection()); assertEquals(null, outputPort.getValue()); Port stringPort = nodeA.addPort("stringPort"); assertEquals("stringPort", stringPort.getName()); assertEquals(Port.Direction.IN, stringPort.getDirection()); assertEquals(null, stringPort.getValue()); }
public static ArrayList<Message> findOutgoingMessage(Port port, String name, boolean fuzzy) { ArrayList<Message> result = new ArrayList<Message>(); for (Message t : port.getSends()) { if (t.getName().startsWith(name)) { if (fuzzy) result.add(t); else if (t.getName().equals(name)) result.add(t); } } return result; }
public int open(String filename, int flags) { Port port = new Port(); port.m_OpenFlags = flags; try { if (!filename.startsWith("\\\\")) filename = "\\\\.\\" + filename; port.m_Comm = CreateFileW( new WString(filename), GENERIC_READ | GENERIC_WRITE, 0, null, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, null); if (INVALID_HANDLE_VALUE == port.m_Comm) { if (GetLastError() == ERROR_FILE_NOT_FOUND) m_ErrNo = ENOENT; else m_ErrNo = EBUSY; port.fail(); } if (!SetupComm(port.m_Comm, (int) port.m_RdBuffer.size(), (int) port.m_WrBuffer.size())) port.fail(); // FIXME what would be appropriate error code here cfmakeraw(port.m_Termios); cfsetispeed(port.m_Termios, B9600); cfsetospeed(port.m_Termios, B9600); port.m_Termios.c_cc[VTIME] = 0; port.m_Termios.c_cc[VMIN] = 0; updateFromTermios(port); port.m_RdOVL.writeField("hEvent", CreateEventA(null, true, false, null)); if (port.m_RdOVL.hEvent == INVALID_HANDLE_VALUE) port.fail(); port.m_WrOVL.writeField("hEvent", CreateEventA(null, true, false, null)); if (port.m_WrOVL.hEvent == INVALID_HANDLE_VALUE) port.fail(); port.m_SelOVL.writeField("hEvent", CreateEventA(null, true, false, null)); if (port.m_SelOVL.hEvent == INVALID_HANDLE_VALUE) port.fail(); return port.m_FD; } catch (Exception f) { if (port != null) port.close(); return -1; } }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; PortHistory that = (PortHistory) o; return id == that.id && !(port != null ? !port.equals(that.port) : that.port != null) && !(date != null ? !date.equals(that.date) : that.date != null); }
/** * Constructor. * * @param port The I2C port the device is connected to. * @param deviceAddress The address of the device on the I2C bus. */ public I2C(Port port, int deviceAddress) { ByteBuffer status = ByteBuffer.allocateDirect(4); status.order(ByteOrder.LITTLE_ENDIAN); m_port = port; m_deviceAddress = deviceAddress; I2CJNI.i2CInitialize((byte) m_port.getValue(), status.asIntBuffer()); HALUtil.checkStatus(status.asIntBuffer()); UsageReporting.report(tResourceType.kResourceType_I2C, deviceAddress); }