Changeset 282:e3f97af423f0 in finroc_tools_finstruct-java


Ignore:
Timestamp:
25.02.2020 08:00:17 (2 days ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
default
Parents:
280:5b0510561a72 (diff), 281:6996e87e4c6e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Phase:
public
Tags:
tip
Message:

Merge with 17.03

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • FinstructConnectionPanel.java

    r280 r282  
    900900            if (node.getClass().equals(RemotePort.class)) { 
    901901                RemotePort port = (RemotePort)element; 
    902                 result.textColor = tree.getBackground(); 
     902                boolean portBasedInterface = port.getFlag(FrameworkElementFlags.INTERFACE); 
     903                result.textColor = portBasedInterface ? result.textColor : tree.getBackground(); 
    903904                boolean rpc = port.getDataType().getTypeClassification() == DataTypeBase.CLASSIFICATION_RPC_TYPE; 
    904905                boolean mouseOverFlag = (mouseOver instanceof RemotePort) && ((port.getPort() == ((RemotePort)mouseOver).getPort()) || RemoteRuntime.arePortsConnected(port, (RemotePort)mouseOver)); 
    905                 result.nodeColor = selected ? selectedColor : (result.nodeColor != errorColor ? defaultColor : errorColor); 
     906                result.nodeColor = selected ? selectedColor : (result.nodeColor != errorColor ? (portBasedInterface ? interfaceColor : defaultColor) : errorColor); 
    906907                if (otherTreeSelection) { 
    907908                    Definitions.TypeConversionRating rating = highlightedElementRatings.get(node); 
  • FinstructConnectionPanel.java

    r281 r282  
    5252import org.finroc.core.remote.HasURI; 
    5353import org.finroc.core.remote.ModelNode; 
     54import org.finroc.core.remote.Path; 
    5455import org.finroc.core.remote.PortWrapper; 
    5556import org.finroc.core.remote.RemoteConnectOptions; 
     
    652653                                        String errorString = ""; 
    653654                                        if (errorElement != element) { 
    654                                             errorString = "in '" + Util.escapeForHtml(errorElement.getQualifiedName('/').substring(element.getQualifiedName('/').length() + 1)) + "': "; 
     655                                            errorString = "in <i>" + Util.escapeForHtml(errorElement.getQualifiedName('/').substring(element.getQualifiedName('/').length() + 1)) + "</i>: "; 
    655656                                        } 
    656657                                        if (uriConnector.getStatus() == RemoteUriConnector.Status.ERROR) { 
    657658                                            errorString += "Error connecting to URI '" + uriConnector.getUri() + "'"; 
    658659                                        } else if (uriConnector.getStatus() == RemoteUriConnector.Status.DISCONNECTED) { 
    659                                             errorString += "Partner with URI unavailable '" + uriConnector.getUri() + "'"; 
     660                                            if (uriConnector.getAuthority() == null || uriConnector.getAuthority().length() == 0) { 
     661                                                Path resolvablePath = uriConnector.getPath(); 
     662                                                while (runtime.getChildByPath(resolvablePath) == null && resolvablePath.size() > 0) { 
     663                                                    resolvablePath = resolvablePath.getParent(); 
     664                                                } 
     665                                                String resolvablePathString = resolvablePath.toString(); 
     666                                                String unresolvablePathString = uriConnector.getPath().toString().substring(resolvablePathString.length()); 
     667                                                errorString += "Partner with Path unavailable <i>" + resolvablePathString + "<b>" + unresolvablePathString + "</b></i>"; 
     668                                            } else { 
     669                                                errorString += "Partner with URI unavailable <i>" + uriConnector.getUri() + "</i>"; 
     670                                            } 
    660671                                        } 
    661672                                        toolTip += errorString; 
  • SmartConnecting.java

    r279 r282  
    250250 
    251251        // Inner-group connection to group's interface port 
    252         if (port1.getParent() != null && port1.getParent().isInterface() && port1.getParent().getParent() == commonParent && (port1.getFlags() & FrameworkElementFlags.PROXY) == FrameworkElementFlags.PROXY) { 
     252        ModelNode port1ComponentInterface = getComponentInterface(port1); 
     253        ModelNode port2ComponentInterface = getComponentInterface(port1); 
     254        if (port1ComponentInterface != null && port1ComponentInterface.isInterface() && port1ComponentInterface.getParent() == commonParent && (port1.getFlags() & FrameworkElementFlags.PROXY) == FrameworkElementFlags.PROXY) { 
    253255            return port1.getFlag(FrameworkElementFlags.IS_OUTPUT_PORT) ? AbstractPort.ConnectDirection.TO_SOURCE : AbstractPort.ConnectDirection.TO_TARGET; 
    254256        } 
    255         if (port2.getParent() != null && port2.getParent().isInterface() && port2.getParent().getParent() == commonParent && (port2.getFlags() & FrameworkElementFlags.PROXY) == FrameworkElementFlags.PROXY) { 
     257        if (port2ComponentInterface != null && port2ComponentInterface.isInterface() && port2ComponentInterface.getParent() == commonParent && (port2.getFlags() & FrameworkElementFlags.PROXY) == FrameworkElementFlags.PROXY) { 
    256258            return port2.getFlag(FrameworkElementFlags.IS_OUTPUT_PORT) ? AbstractPort.ConnectDirection.TO_TARGET : AbstractPort.ConnectDirection.TO_SOURCE; 
    257259        } 
     
    368370        RemoteType portDataType; 
    369371        PortCreationList.Entry createEntry; 
    370         RemoteFrameworkElement interface_; 
     372        RemoteFrameworkElement parentInterface;  // Parent interface of port (only needs to be set if different from component interface) 
     373        RemoteFrameworkElement componentInterface; 
    371374        RemoteFrameworkElement component; 
    372375 
    373376        public String getPortLink() { 
    374             return component.getQualifiedName(FinstructAction.LINK_SEPARATOR) + FinstructAction.LINK_SEPARATOR + interface_.getName() + FinstructAction.LINK_SEPARATOR + portName; 
     377            if (parentInterface != null && parentInterface != componentInterface) { 
     378                return parentInterface.getQualifiedName(FinstructAction.LINK_SEPARATOR) + FinstructAction.LINK_SEPARATOR + portName; 
     379            } 
     380            return component.getQualifiedName(FinstructAction.LINK_SEPARATOR) + FinstructAction.LINK_SEPARATOR + componentInterface.getName() + FinstructAction.LINK_SEPARATOR + portName; 
    375381        } 
    376382    } 
     
    478484                element1.portName = element1.port.getName(); 
    479485                element1.portDataType = element1.port.getDataType(); 
    480                 if ((!(element1.port.getParent() instanceof RemoteFrameworkElement)) || (!(element1.port.getParent().getParent() instanceof RemoteFrameworkElement))) { 
    481                     throw new Exception("Port must be below two framework elements"); 
    482                 } 
    483                 element1.interface_ = (RemoteFrameworkElement)element1.port.getParent(); 
    484                 element1.component = (RemoteFrameworkElement)element1.interface_.getParent(); 
     486                element1.componentInterface = (RemoteFrameworkElement)getComponentInterface(element1.port); 
     487                if ((!(element1.componentInterface instanceof RemoteFrameworkElement)) || (!(element1.componentInterface.getParent() instanceof RemoteFrameworkElement))) { 
     488                    throw new Exception("Port must be below component"); 
     489                } 
     490                element1.parentInterface = (RemoteFrameworkElement)element1.port.getParent(); 
     491                element1.component = (RemoteFrameworkElement)element1.componentInterface.getParent(); 
    485492 
    486493                // Element 2 
     
    490497                    element2.portName = element2.port.getName(); 
    491498                    element2.portDataType = element2.port.getDataType(); 
    492                     if ((!(element2.port.getParent() instanceof RemoteFrameworkElement)) || (!(element2.port.getParent().getParent() instanceof RemoteFrameworkElement))) { 
    493                         throw new Exception("Port must be below two framework elements"); 
    494                     } 
    495                     element2.interface_ = (RemoteFrameworkElement)element2.port.getParent(); 
    496                     element2.component = (RemoteFrameworkElement)element2.interface_.getParent(); 
     499                    element2.componentInterface = (RemoteFrameworkElement)getComponentInterface(element2.port); 
     500                    if ((!(element2.componentInterface instanceof RemoteFrameworkElement)) || (!(element2.componentInterface.getParent() instanceof RemoteFrameworkElement))) { 
     501                        throw new Exception("Port must be below component"); 
     502                    } 
     503                    element2.parentInterface = (RemoteFrameworkElement)element2.port.getParent(); 
     504                    element2.component = (RemoteFrameworkElement)element2.componentInterface.getParent(); 
    497505                } else if ((nodes2.get(i) instanceof RemoteFrameworkElement) && nodes2.get(i).isInterface()) { 
    498                     element2.interface_ = (RemoteFrameworkElement)nodes2.get(i); 
    499                     if (!(element2.interface_.getParent() instanceof RemoteFrameworkElement)) { 
     506                    element2.componentInterface = (RemoteFrameworkElement)nodes2.get(i); 
     507                    if (!(element2.componentInterface.getParent() instanceof RemoteFrameworkElement)) { 
    500508                        throw new Exception("Interface must be below framework element"); 
    501509                    } 
    502                     element2.component = (RemoteFrameworkElement)element2.interface_.getParent(); 
     510                    element2.component = (RemoteFrameworkElement)element2.componentInterface.getParent(); 
    503511                } else if (nodes2.get(i) instanceof RemoteFrameworkElement) { 
    504512                    element2.component = (RemoteFrameworkElement)nodes2.get(i); 
     
    518526                    port2IsOutputDesired = !port2IsOutputDesired; 
    519527                } 
    520                 if (element2.port != null || (element2.interface_ != null && (element2.interface_.isInputOnlyInterface() || element2.interface_.isOutputOnlyInterface()))) { 
    521                     boolean port2IsOutput = (element2.port != null && element2.port.getFlag(FrameworkElementFlags.IS_OUTPUT_PORT)) || (element2.port == null && element2.interface_.isOutputOnlyInterface()); 
     528                if (element2.port != null || (element2.componentInterface != null && (element2.componentInterface.isInputOnlyInterface() || element2.componentInterface.isOutputOnlyInterface()))) { 
     529                    boolean port2IsOutput = (element2.port != null && element2.port.getFlag(FrameworkElementFlags.IS_OUTPUT_PORT)) || (element2.port == null && element2.componentInterface.isOutputOnlyInterface()); 
    522530                    if (port2IsOutput != port2IsOutputDesired) { 
    523531                        throw new Exception("Unsuitable data flow directions"); 
     
    538546 
    539547                // Decide on whether to use sensor or controller interfaces 
    540                 boolean sensorData = element1.interface_.isSensorInterface() || (element2.interface_ != null && element2.interface_.isSensorInterface()); 
    541                 boolean controllerData = element1.interface_.isControllerInterface() || (element2.interface_ != null && element2.interface_.isControllerInterface()); 
     548                boolean sensorData = element1.componentInterface.isSensorInterface() || (element2.componentInterface != null && element2.componentInterface.isSensorInterface()); 
     549                boolean controllerData = element1.componentInterface.isControllerInterface() || (element2.componentInterface != null && element2.componentInterface.isControllerInterface()); 
    542550//              int index = 1; 
    543551//              ArrayList<RemotePort> portSet1 = new ArrayList<RemotePort>(); 
     
    585593 
    586594                        // Select an interface 
    587                         if (currentElement.interface_ == null) { 
    588                             ModelNode sameNameInterface = currentElement.component.getChildByName(lastElement.interface_.getName()); 
     595                        if (currentElement.componentInterface == null) { 
     596                            ModelNode sameNameInterface = currentElement.component.getChildByName(lastElement.componentInterface.getName()); 
    589597                            if (k > 0 && sameNameInterface instanceof RemoteFrameworkElement && ((RemoteFrameworkElement)sameNameInterface).isInterface() && 
    590598                                    (((RemoteFrameworkElement)sameNameInterface).isEditableInterface() || sameNameInterface.getChildByName(lastElement.portName) instanceof RemotePort)) { 
    591                                 currentElement.interface_ = (RemoteFrameworkElement)sameNameInterface; 
     599                                currentElement.componentInterface = (RemoteFrameworkElement)sameNameInterface; 
    592600                            } else if (currentElement.component.getEditableInterfaces() != null) { 
    593601                                interfaceCandidates.clear(); 
     
    596604                                    int score = 0; 
    597605                                    boolean rpcType = element1.portDataType.getTypeClassification() == DataTypeBase.CLASSIFICATION_RPC_TYPE; 
    598                                     boolean rpcPortInDataInterface = rpcType && (!element1.interface_.getFlag(FrameworkElementFlags.INTERFACE_FOR_RPC_PORTS)); 
     606                                    boolean rpcPortInDataInterface = rpcType && (!element1.componentInterface.getFlag(FrameworkElementFlags.INTERFACE_FOR_RPC_PORTS)); 
    599607                                    boolean checkForRpcType = rpcType && (!rpcPortInDataInterface); 
    600608 
     
    602610                                    if (!rpcType) { 
    603611                                        score += (outputPorts && candidate.isOutputOnlyInterface()) || ((!outputPorts) && candidate.isInputOnlyInterface()) ? 1 : 0; 
    604                                         score += (candidate.isParameterInterface() == lastElement.interface_.isParameterInterface()) ? 2 : 0; 
     612                                        score += (candidate.isParameterInterface() == lastElement.componentInterface.isParameterInterface()) ? 2 : 0; 
    605613                                    } else if (rpcPortInDataInterface) { 
    606                                         score += lastElement.interface_.getName().contains("Output") && candidate.getName().contains("Output") || lastElement.interface_.getName().contains("Input") && candidate.getName().contains("Input") ? 1 : 0; 
     614                                        score += lastElement.componentInterface.getName().contains("Output") && candidate.getName().contains("Output") || lastElement.componentInterface.getName().contains("Input") && candidate.getName().contains("Input") ? 1 : 0; 
    607615                                    } 
    608616                                    boolean typeCheck1 = (sensorData == controllerData) || candidate.getFlag(FrameworkElementFlags.SENSOR_DATA) == candidate.getFlag(FrameworkElementFlags.CONTROLLER_DATA) || (candidate.isControllerInterface() && controllerData) || (candidate.isSensorInterface() && sensorData); 
     
    623631                                    throw new Exception("No suitable interface in " + currentElement.component.getQualifiedName('/')); 
    624632                                } else if (interfaceCandidates.size() == 1) { 
    625                                     currentElement.interface_ = interfaceCandidates.get(0); 
     633                                    currentElement.componentInterface = interfaceCandidates.get(0); 
    626634                                } else if (interfaceCandidates.size() == 2 && sensorData == controllerData && interfaceCandidates.get(0).isControllerInterface() != interfaceCandidates.get(0).isSensorInterface() && 
    627635                                           interfaceCandidates.get(1).isControllerInterface() != interfaceCandidates.get(1).isSensorInterface() && interfaceCandidates.get(0).isSensorInterface() != interfaceCandidates.get(1).isSensorInterface()) { 
    628636                                    // sensor/controller-data ambiguity: two runs (select sensor in first) 
    629                                     currentElement.interface_ = interfaceCandidates.get(0).isControllerInterface() == controllerRun ? interfaceCandidates.get(0) : interfaceCandidates.get(1); 
     637                                    currentElement.componentInterface = interfaceCandidates.get(0).isControllerInterface() == controllerRun ? interfaceCandidates.get(0) : interfaceCandidates.get(1); 
    630638                                    addControllerRun = !controllerRun; 
    631639                                } else { 
     
    639647                        // Component interfaces crossed 
    640648                        if (k > 0) { 
    641                             crossedComponentInterfaces.add(currentElement.interface_); 
     649                            crossedComponentInterfaces.add(currentElement.componentInterface); 
    642650                        } 
    643651 
    644652                        // Check or create port 
    645                         ModelNode childElement = currentElement.interface_.getChildByName(lastElement.portName); 
     653                        ModelNode childElement = currentElement.componentInterface.getChildByName(lastElement.portName); 
    646654                        Definitions.TypeConversionRating conversionRating = Definitions.TypeConversionRating.NO_CONVERSION; 
    647655                        if (childElement != null) { 
     
    679687                                addPortActions.put(currentElement.component, addPortAction); 
    680688                            } 
    681                             List<PortCreationList.Entry> addList = addPortAction.getPortsToAdd(currentElement.interface_.getName()); 
     689                            List<PortCreationList.Entry> addList = addPortAction.getPortsToAdd(currentElement.componentInterface.getName()); 
    682690 
    683691                            // Check whether entry is already in list 
     
    825833        return result; 
    826834    } 
     835 
     836    /** 
     837     * @param port Rempote port 
     838     * @return Component interface that remote port belongs to 
     839     */ 
     840    public static ModelNode getComponentInterface(RemotePort port) { 
     841        ModelNode candidate = port.getParent(); 
     842        while (((RemoteFrameworkElement)candidate).getFlag(FrameworkElementFlags.PORT)) { // Composite port 
     843            candidate = candidate.getParent(); 
     844        }; 
     845        return candidate; 
     846    } 
    827847} 
  • SmartConnecting.java

    r281 r282  
    4747import org.finroc.tools.finstruct.actions.ConnectAction; 
    4848import org.finroc.tools.finstruct.actions.FinstructAction; 
     49import org.rrlib.finroc_core_utils.jc.container.SafeConcurrentlyIterableList; 
    4950import org.rrlib.serialization.Register; 
    5051import org.rrlib.serialization.rtti.DataTypeBase; 
     
    814815 
    815816    /** 
     817     * @param runtime Runtime whose URI alternatives to obtain 
     818     * @param sourceRuntime Runtime from which to obtain URI alternatives 
     819     * @return List with alternatives for URI authorities to use 
     820     */ 
     821    public static SafeConcurrentlyIterableList<String> getUriAuthorityAlternatives(RemoteRuntime runtime, RemoteRuntime sourceRuntime) { 
     822        org.finroc.core.net.generic_protocol.RemoteRuntime runtimeElement = runtime.getRuntimeElement(); 
     823        org.finroc.core.net.generic_protocol.RemoteRuntime sourceRuntimeElement = sourceRuntime.getRuntimeElement(); 
     824 
     825        if (runtimeElement != null) { 
     826            boolean sameHost = sourceRuntimeElement != null && runtimeElement.hasSameHost(sourceRuntimeElement); 
     827            //System.out.println("Same Host " + sameHost + " " + runtimeElement.getName() + " " + sourceRuntimeElement.getName()); 
     828            return runtimeElement.getUriAuthorityAlternatives(sameHost); 
     829        } 
     830 
     831        SafeConcurrentlyIterableList<String> result = new SafeConcurrentlyIterableList<String>(1, 1); 
     832        result.add(runtime.uuid, true); 
     833        return result; 
     834    } 
     835 
     836    /** 
    816837     * @param port Rempote port 
    817838     * @return Component interface that remote port belongs to 
  • propertyeditor/FinrocComponentFactory.java

    r275 r282  
    3737import org.finroc.core.remote.RemoteRuntime; 
    3838import org.finroc.core.remote.RemoteType; 
     39import org.finroc.plugins.data_types.PaintablePortData; 
     40import org.finroc.plugins.data_types.TaskProfile; 
    3941import org.finroc.tools.gui.util.propertyeditor.BooleanEditor; 
    4042import org.finroc.tools.gui.util.propertyeditor.ComponentFactory; 
     
    4850import org.finroc.tools.gui.util.propertyeditor.StandardComponentFactory; 
    4951import org.finroc.tools.gui.util.propertyeditor.gui.DataTypeEditor; 
    50 import org.finroc.plugins.data_types.PaintablePortData; 
    5152import org.finroc.plugins.data_types.TaskProfile; 
    5253import org.rrlib.serialization.BinarySerializable; 
     
    7879 
    7980    /** 
    80      * @param type Type to check 
     81     * @param remoteType Remote type 
     82     * @param localType Local type that is used in port (does not necessarily need to be remote type's default) 
    8183     * @return True if type is supported by Finroc component factory 
    8284     * (e.g. a component for displaying and possibly editing is available) 
    8385     */ 
    84     public static boolean isTypeSupported(DataTypeBase dt) { 
    85         if (dt.getTypeClassification() != DataTypeBase.CLASSIFICATION_RPC_TYPE) { 
    86             Class<?> type = dt.getJavaClass(); 
     86    public static boolean isTypeSupported(RemoteType remoteType, DataTypeBase localType) { 
     87        if (remoteType.getTypeClassification() != DataTypeBase.CLASSIFICATION_RPC_TYPE && remoteType.getTypeClassification() != DataTypeBase.CLASSIFICATION_PORT_COMPOSITE_INTERFACE) { 
     88            Class<?> type = localType.getJavaClass(); 
    8789            if (type != null) { 
    8890                return (type.equals(PortCreationList.class) || DataTypeReference.class.equals(type) 
  • propertyeditor/FinrocComponentFactory.java

    r281 r282  
    5050import org.finroc.tools.gui.util.propertyeditor.StandardComponentFactory; 
    5151import org.finroc.tools.gui.util.propertyeditor.gui.DataTypeEditor; 
     52import org.finroc.plugins.data_types.TaskProfile; 
    5253import org.rrlib.serialization.BinarySerializable; 
    5354import org.rrlib.serialization.EnumValue; 
     
    8889            if (type != null) { 
    8990                return (type.equals(PortCreationList.class) || DataTypeReference.class.equals(type) 
    90                         || PaintablePortData.class.isAssignableFrom(type) || XML.class.isAssignableFrom(type) || type.isEnum() 
     91                        || PaintablePortData.class.isAssignableFrom(type) || XML.class.isAssignableFrom(type) || type.isEnum() || type.equals(TaskProfile.List.class) 
    9192                        || type.equals(EnumValue.class) || CoreBoolean.class.isAssignableFrom(type) || type.equals(PortDataListImpl.class) 
    9293                        || (BinarySerializable.class.isAssignableFrom(type) && (Serialization.isStringSerializable(type) || Serialization.isXmlSerializable(type)))); 
     
    142143            wpec = new BooleanEditor(); 
    143144            acc = new CoreBooleanAdapter((PropertyAccessor<CoreBoolean>)acc); 
     145        } else if (type.equals(TaskProfile.List.class)) { 
     146            wpec = new TaskProfileViewer(RemoteRuntime.find(commonParent)); 
    144147        } else if (type.equals(PortDataListImpl.class)) { 
    145148            wpec = new CoreSerializableDefaultEditor(type); 
Note: See TracChangeset for help on using the changeset viewer.