Пример #1
0
 /// <summary>
 /// Set all Channels visible which have the givent dataType
 /// </summary>
 /// <param name="dataType"></param>
 private void ShowChannels(Asterics.ACS2.dataType dataType)
 {
     // set visibility to "hidden" in the deploymentmodel
     foreach (componentType mc in deploymentModel.components) {
         if (mc != null && mc.ports != null) {
             foreach (object o in mc.ports) {
                 if (o is outputPortType && ((outputPortType)o).PortDataType == dataType) {
                     ((outputPortType)o).PortRectangle.Visibility = Visibility.Visible;
                     ((outputPortType)o).PortLabel.Visibility = Visibility.Visible;
                 }
                 else if (o is inputPortType && ((inputPortType)o).PortDataType == dataType) {
                     ((inputPortType)o).PortRectangle.Visibility = Visibility.Visible;
                     ((inputPortType)o).PortLabel.Visibility = Visibility.Visible;
                 }
             }
         }
     }
 }
Пример #2
0
 /// <summary>
 /// Set all channels with a different datatype as dataTypeto visible or unvisible according to the given arguments
 /// </summary>
 /// <param name="dataType">Specifies the datatype which should not be affected by the operation.</param>
 /// <param name="inputports">If set to true inputports with a datatype different to dataType will get hidden/visible. If set to false inputports will not get changed.</param>
 /// <param name="outputports">If set to true outputports with a datatype different to dataType will get hidden/visible. If set to false outputports will not get changed.</param>
 /// <param name="hide">If true all selected channels get invisible. If set to false all selected channels get visible.</param>
 private void ChangeChannelVisibility(Asterics.ACS2.dataType dataType, bool inputports, bool outputports, bool hide)
 {
     if (hide == true)
         hiddenChannels = true;
     if (!CheckInteroperabilityOfPorts(dataType, ACS2.dataType.boolean))
         ChangeVisibleChannels(ACS2.dataType.boolean, outputports, inputports, hide);
     if (!CheckInteroperabilityOfPorts(dataType, ACS2.dataType.integer))
         ChangeVisibleChannels(ACS2.dataType.integer, outputports, inputports, hide);
     if (!CheckInteroperabilityOfPorts(dataType, ACS2.dataType.@byte))
         ChangeVisibleChannels(ACS2.dataType.@byte, outputports, inputports, hide);
     if (!CheckInteroperabilityOfPorts(dataType, ACS2.dataType.@char))
         ChangeVisibleChannels(ACS2.dataType.@char, outputports, inputports, hide);
     if (!CheckInteroperabilityOfPorts(dataType, ACS2.dataType.@double))
         ChangeVisibleChannels(ACS2.dataType.@double, outputports, inputports, hide);
     if (!CheckInteroperabilityOfPorts(dataType, ACS2.dataType.@string))
         ChangeVisibleChannels(ACS2.dataType.@string, outputports, inputports, hide);
 }
Пример #3
0
 /// <summary>
 /// This method changes the visibility of all channels with the specified datatype according to the given arguments.
 /// </summary>
 /// <param name="dataType">Datatype of the channels which should get changed</param>
 /// <param name="outputports">True if outputports should be affected, false otherwise.</param>
 /// <param name="inputports">True if inputports should be affected, false otherwise</param>
 /// <param name="hidden">True if the channels should become invisible, true if they should become visible</param>
 private void ChangeVisibleChannels(Asterics.ACS2.dataType dataType, bool outputports, bool inputports, bool hidden)
 {
     // set visibility to "hidden" in the deploymentmodel
     foreach (componentType mc in deploymentModel.components) {
         if (mc != null && mc.ports != null && mc.ports != null) {
             foreach (object o in mc.ports) {
                 if (outputports && o is outputPortType && ((outputPortType)o).PortDataType == dataType && ((outputPortType)o).ChannelIds.Count == 0) {
                     if (hidden) {
                         ((outputPortType)o).PortRectangle.Visibility = Visibility.Hidden;
                         ((outputPortType)o).PortLabel.Visibility = Visibility.Hidden;
                     }
                     else {
                         ((outputPortType)o).PortRectangle.Visibility = Visibility.Visible;
                         ((outputPortType)o).PortLabel.Visibility = Visibility.Visible;
                     }
                 }
                 else if (inputports && o is inputPortType && ((inputPortType)o).PortDataType == dataType && ((inputPortType)o).ChannelId.Equals("")) {
                     if (hidden) {
                         ((inputPortType)o).PortRectangle.Visibility = Visibility.Hidden;
                         ((inputPortType)o).PortLabel.Visibility = Visibility.Hidden;
                     }
                     else {
                         ((inputPortType)o).PortRectangle.Visibility = Visibility.Visible;
                         ((inputPortType)o).PortLabel.Visibility = Visibility.Visible;
                     }
                 }
             }
         }
     }
 }
        // copy all relevant properties of an eventport
        //private void CopyEventPort(Canvas source, Canvas target) {
        //    target.Width = source.Width;
        //    target.Height = source.Height;
        //    PointCollection eventPortPointCollection = new PointCollection();
        //    Polygon eventPortPolygon = new Polygon();
        //    foreach (Polygon pg in source.Children) {
        //        foreach (Point p in pg.Points) {
        //            eventPortPointCollection.Add(new Point(p.X, p.Y));
        //        }
        //        eventPortPolygon.Points = eventPortPointCollection;
        //        eventPortPolygon.Fill = pg.Fill;
        //        eventPortPolygon.Stroke = pg.Stroke;
        //    }
        //    target.Children.Add(eventPortPolygon);
        //}
        /// <summary>
        /// Generate a new deployment component form a bundle component, deep copy
        /// </summary>
        /// <param name="component">The bundle component, which should be copied</param>
        /// <param name="id">The id of the new component</param>
        /// <returns>A new model component based on the bundle component</returns>
        public static componentType CopyFromBundleModel(Asterics.ACS2.componentTypesComponentType component, String id)
        {
            componentType mComponent = new componentType();
            //int portIndex = 0;

            mComponent.id = id;
            mComponent.componentTypeDataType = component.type.Value;
            //mComponent.componentId = component.id;
            mComponent.type_id = component.id;
            mComponent.description = component.description;

            // copy the graphical elements
            mComponent.ComponentCanvas.Height = component.ComponentCanvas.Height;
            mComponent.ComponentCanvas.Width = component.ComponentCanvas.Width;
            mComponent.ComponentCanvas.FocusVisualStyle = null;
            mComponent.CopyRectangel(component.MainRectangle, mComponent.MainRectangle);
            mComponent.ComponentCanvas.Children.Add(mComponent.MainRectangle);
            Canvas.SetLeft(mComponent.MainRectangle, Canvas.GetLeft(component.MainRectangle));
            Canvas.SetTop(mComponent.MainRectangle, Canvas.GetTop(component.MainRectangle));
            mComponent.Label.Text = id;

            mComponent.InitLabeling();

            // copy the properties
            if (component.properties != null) {
                foreach (Asterics.ACS2.propertyType compProperty in component.properties) {
                    propertyType property = new propertyType();
                    property.name = compProperty.name;
                    property.DataType = compProperty.type;
                    property.Description = compProperty.description;
                    property.value = compProperty.value;
                    if (compProperty.combobox != null) {
                        property.ComboBoxStrings = compProperty.combobox.Split(new String[] { "//" }, StringSplitOptions.None);
                    }
                    if (compProperty.getStringList) {
                        property.GetStringList = true;
                    } else {
                        property.GetStringList = false;
                    }
                    mComponent.PropertyArrayList.Add(property);
                }
            }
            mComponent.propertiesField = new propertyType[mComponent.PropertyArrayList.Count];
            mComponent.PropertyArrayList.CopyTo(mComponent.propertiesField);

            // copy the ports

            if (component.ports != null) {
                foreach (object o in component.ports) {
                    // copy the inports
                    if (o is Asterics.ACS2.inputPortType) {
                        Asterics.ACS2.inputPortType compInPort = (Asterics.ACS2.inputPortType)o;
                        inputPortType inPort = new inputPortType();
                        inPort.portTypeID = compInPort.id;
                        inPort.ComponentId = id;
                        inPort.Description = compInPort.description;
                        inPort.MustBeConnected = compInPort.mustBeConnected;
                        inPort.PortDataType = compInPort.dataType;
                        inPort.ComponentTypeId = component.id;

                        inPort.PortLabel.Text = compInPort.id;
                        mComponent.componentCanvas.Children.Add(inPort.PortLabel);
                        Canvas.SetLeft(inPort.PortLabel, Canvas.GetLeft(compInPort.PortRectangle) + ACS.LayoutConstants.INPORTRECTANGLEWIDTH + 2);
                        Canvas.SetTop(inPort.PortLabel, Canvas.GetTop(compInPort.PortRectangle) - 2 );

                        mComponent.CopyRectangel(compInPort.PortRectangle, inPort.PortRectangle);
                        mComponent.ComponentCanvas.Children.Add(inPort.PortRectangle);
                        Canvas.SetLeft(inPort.PortRectangle, Canvas.GetLeft(compInPort.PortRectangle));
                        Canvas.SetTop(inPort.PortRectangle, Canvas.GetTop(compInPort.PortRectangle));

                        // copy the properties of the inports
                        if (compInPort.properties != null) {
                            foreach (Asterics.ACS2.propertyType portProperty in compInPort.properties) {
                                propertyType property = new propertyType();
                                property.name = portProperty.name;
                                property.DataType = portProperty.type;
                                property.Description = portProperty.description;
                                property.value = portProperty.value;
                                if (portProperty.combobox != null) {
                                    property.ComboBoxStrings = portProperty.combobox.Split(new String[] { "//" }, StringSplitOptions.None);
                                }
                                inPort.PropertyArrayList.Add(property);
                            }
                            inPort.properties = new propertyType[inPort.PropertyArrayList.Count];
                            inPort.PropertyArrayList.CopyTo(inPort.properties);
                        }

                        // copy the reference to another port (only available, if it is a group element)
                        if (compInPort.RefPort != null) {
                            inPort.refs = compInPort.RefPort;
                        }

                        mComponent.PortsList.Add(inPort.portTypeID,inPort);

                    // copy the outports
                    } else if (o is Asterics.ACS2.outputPortType) {
                        Asterics.ACS2.outputPortType compOutPort = (Asterics.ACS2.outputPortType)o;
                        outputPortType outPort = new outputPortType();
                        outPort.portTypeID = compOutPort.id;
                        outPort.ComponentId = id;
                        outPort.Description = compOutPort.description;
                        outPort.PortDataType = compOutPort.dataType;
                        outPort.ComponentTypeId = component.id;

                        outPort.PortLabel.Text = compOutPort.id;
                        mComponent.componentCanvas.Children.Add(outPort.PortLabel);
                        Canvas.SetLeft(outPort.PortLabel, Canvas.GetLeft(compOutPort.PortRectangle) - ACS.LayoutConstants.OUTPORTLABELWIDTH - 2);
                        Canvas.SetTop(outPort.PortLabel, Canvas.GetTop(compOutPort.PortRectangle) - 2);

                        mComponent.CopyRectangel(compOutPort.PortRectangle, outPort.PortRectangle);
                        mComponent.ComponentCanvas.Children.Add(outPort.PortRectangle);
                        Canvas.SetLeft(outPort.PortRectangle, Canvas.GetLeft(compOutPort.PortRectangle));
                        Canvas.SetTop(outPort.PortRectangle, Canvas.GetTop(compOutPort.PortRectangle));

                        // copy the properties of the outports
                        if (compOutPort.properties != null) {
                            foreach (Asterics.ACS2.propertyType portProperty in compOutPort.properties) {
                                propertyType property = new propertyType();
                                property.name = portProperty.name;
                                property.DataType = portProperty.type;
                                property.Description = portProperty.description;
                                property.value = portProperty.value;
                                if (portProperty.combobox != null) {
                                    property.ComboBoxStrings = portProperty.combobox.Split(new String[] { "//" }, StringSplitOptions.None);
                                }
                                outPort.PropertyArrayList.Add(property);
                            }
                            outPort.properties = new propertyType[outPort.PropertyArrayList.Count];
                            outPort.PropertyArrayList.CopyTo(outPort.properties);
                        }

                        // copy the reference to another port (only available, if it is a group element)
                        if (compOutPort.RefPort != null) {
                            outPort.refs = compOutPort.RefPort;
                        }

                        mComponent.PortsList.Add(outPort.portTypeID,outPort);
                    }

                }
                mComponent.ports = new object[mComponent.PortsList.Count];
                mComponent.PortsList.Values.CopyTo(mComponent.ports, 0);
            }

            // Searching for event listeners and event triggers and saving them in arrays
            if ((component.events != null)&&(component.events != null)) {
                foreach (object eventO in component.events) {
                    if (eventO is ACS2.eventsTypeEventListenerPortType) {
                        ACS2.eventsTypeEventListenerPortType compEl = (ACS2.eventsTypeEventListenerPortType)eventO;
                        EventListenerPort el = new EventListenerPort();
                        el.EventListenerId = compEl.id;
                        el.EventDescription = compEl.description;
                        el.ComponentId = id;
                        mComponent.EventListenerList.Add(el);
                    } else if (eventO is ACS2.eventsTypeEventTriggererPortType) {
                        ACS2.eventsTypeEventTriggererPortType compEl = (ACS2.eventsTypeEventTriggererPortType)eventO;
                        EventTriggerPort et = new EventTriggerPort();
                        et.EventTriggerId = compEl.id;
                        et.EventDescription = compEl.description;
                        et.ComponentId = id;
                        mComponent.EventTriggerList.Add(et);
                    }
                }
            }

            // Adapt the size of MainRectangle, if more then MAINRECTANGLENUMBEROFPORTS are in a component
            int numInPorts = 0;
            int numOutPorts = 0;
            foreach (object o in mComponent.PortsList.Values) {
                if (o is inputPortType) {
                    numInPorts++;
                } else {
                    numOutPorts++;
                }
            }
            if (numOutPorts > ACS.LayoutConstants.MAINRECTANGLENUMBEROFPORTS) {
                mComponent.MainRectangle.Height += (numOutPorts - ACS.LayoutConstants.MAINRECTANGLENUMBEROFPORTS) * (ACS.LayoutConstants.OUTPORTDISTANCE );
                mComponent.ComponentCanvas.Height += (numOutPorts - ACS.LayoutConstants.MAINRECTANGLENUMBEROFPORTS) * (ACS.LayoutConstants.OUTPORTDISTANCE);
            } else if (numInPorts > ACS.LayoutConstants.MAINRECTANGLENUMBEROFPORTS) {
                mComponent.MainRectangle.Height += (numInPorts - ACS.LayoutConstants.MAINRECTANGLENUMBEROFPORTS) * (ACS.LayoutConstants.INPORTDISTANCE);
                mComponent.ComponentCanvas.Height += (numInPorts - ACS.LayoutConstants.MAINRECTANGLENUMBEROFPORTS) * (ACS.LayoutConstants.INPORTDISTANCE);
            }

            // Drawing the event listener and event trigger port, if events are available
            if (mComponent.EventListenerList.Count > 0) {
                EventListenerPolygon inputEventPolygon = new EventListenerPolygon();
                mComponent.EventListenerPolygon = inputEventPolygon;
                mComponent.componentCanvas.Children.Add(inputEventPolygon.InputEventPortCanvas);
                Canvas.SetLeft(inputEventPolygon.InputEventPortCanvas, ACS.LayoutConstants.EVENTINPORTCANVASOFFSETX);
                //Canvas.SetTop(inputEventPolygon.InputEventPortCanvas, ACS.LayoutConstants.EVENTINPORTCANVASOFFSETY);
                Canvas.SetTop(inputEventPolygon.InputEventPortCanvas, mComponent.MainRectangle.Height + ACS.LayoutConstants.MAINRECTANGLEOFFSETY - 10);
            }
            if (mComponent.EventTriggerList.Count > 0) {
                EventTriggerPolygon outputEventPolygon = new EventTriggerPolygon();
                mComponent.EventTriggerPolygon = outputEventPolygon;
                mComponent.componentCanvas.Children.Add(outputEventPolygon.OutputEventPortCanvas);
                Canvas.SetLeft(outputEventPolygon.OutputEventPortCanvas, ACS.LayoutConstants.EVENTOUTPORTCANVASOFFSETX);
                //Canvas.SetTop(outputEventPolygon.OutputEventPortCanvas, ACS.LayoutConstants.EVENTOUTPORTCANVASOFFSETY);
                Canvas.SetTop(outputEventPolygon.OutputEventPortCanvas, mComponent.MainRectangle.Height + ACS.LayoutConstants.MAINRECTANGLEOFFSETY - 10);
            }

            return mComponent;
        }