public void Port_DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            int index = portsGrid.SelectedIndex;

            if ((index < portsGrid.Items.Count) && (index >= 0))
            {
                PortDefenition portDef = portsGrid.Items[index] as PortDefenition;
                bool           delete  = MessageUtilities.AskToDelete("Do you want to delete " + portDef.Name + "?");
                if (delete == true)
                {
                    AutosarApplication.GetInstance().DeletePort(composition.GetInternalPortPainter(portDef));
                    AutosarApplication.GetInstance().DeletePort(composition.GetExternalPortPainter(portDef));

                    PortPainter internalPort = composition.GetInternalPortPainter(portDef);
                    if (internalPort != null)
                    {
                        composition.InternalPortsInstances.Remove(internalPort);
                    }

                    PortPainter externalPort = composition.GetExternalPortPainter(portDef);
                    if (externalPort != null)
                    {
                        composition.Ports.Remove(externalPort);
                    }

                    composition.PortsDefenitions.Remove(portDef);
                    tree.UpdateAutosarTreeView(tree.SelectedItem);
                    UpdatePortsGrid();
                }
            }
        }
        public PortPainter CreatePortPainter(PortDefenition portDef, double X, double Y)
        {
            String      portName    = NameUtils.GetInterfaceName(portDef);
            PortPainter portPainter = new PortPainter(portDef.GUID, X, Y, portName);

            return(portPainter);
        }
        public PortDefenition CreatePortDefenition(string Name, PortType portType)
        {
            PortDefenition portDef = new PortDefenition();

            portDef.Name     = Name;
            portDef.PortType = portType;
            portDef.GUID     = Guid.NewGuid();
            return(portDef);
        }
Beispiel #4
0
        public static String GetInterfaceName(PortDefenition portDef)
        {
            String interfaceName = portDef.InterfaceName;

            if ((interfaceName.IndexOf("sr") == 0) || (interfaceName.IndexOf("cs") == 0))
            {
                return(interfaceName.Substring(2));
            }
            return(interfaceName);
        }
Beispiel #5
0
 public PortPainter GetInternalPortPainter(PortDefenition portDef)
 {
     foreach (PortPainter portPainter in InternalPortsInstances)
     {
         if (portPainter.PortDefenition.Equals(portDef))
         {
             return(portPainter);
         }
     }
     return(null);
 }
 public PortPainter GetPort(PortDefenition portDef)
 {
     foreach (PortPainter portPainter in Ports)
     {
         if (portPainter.PortDefenition.Equals(portDef))
         {
             return(portPainter);
         }
     }
     return(null);
 }
Beispiel #7
0
 public PortPainter FindPortByItsDefenition(PortDefenition portDef)
 {
     foreach (PortPainter portPainter in this)
     {
         if (portPainter.PortDefenitionGuid.Equals(portDef.GUID))
         {
             return(portPainter);
         }
     }
     return(null);
 }
Beispiel #8
0
        public bool CouldPortsBeAssigned(PortPainter port1, PortPainter port2)
        {
            /* Ports shall be different */
            if (port1 == port2)
            {
                return(false);
            }

            /* ports shall have different parent */
            IElementWithPorts component1 = AutosarApplication.GetInstance().FindComponentInstanceByPort(port1);
            IElementWithPorts component2 = AutosarApplication.GetInstance().FindComponentInstanceByPort(port2);

            if ((component1 == component2) || (component1 == null) || (component2 == null))
            {
                return(false);
            }


            /* Ports shall have the same interfaces */
            PortDefenition portDef1 = AutosarApplication.GetInstance().GetPortDefenition(port1.PortDefenitionGuid);
            PortDefenition portDef2 = AutosarApplication.GetInstance().GetPortDefenition(port2.PortDefenitionGuid);

            if (!portDef1.InterfaceGUID.Equals(portDef2.InterfaceGUID))
            {
                return(false);
            }

            if (!port1.IsDelegatePort && !port2.IsDelegatePort)
            {
                /* Another port shall be the correspondent type */
                bool check = (portDef1.PortType == PortType.Client) && (portDef2.PortType == PortType.Server);
                check |= (portDef1.PortType == PortType.Server) && (portDef2.PortType == PortType.Client);
                check |= (portDef1.PortType == PortType.Receiver) && (portDef2.PortType == PortType.Sender);
                check |= (portDef1.PortType == PortType.Sender) && (portDef2.PortType == PortType.Receiver);

                if (!check)
                {
                    return(false);
                }
            }
            else /* One of the ports is delegate */
            {
                /* Port shall have the same type */
                bool check = (portDef1.PortType == portDef2.PortType);

                if (!check)
                {
                    return(false);
                }
            }

            return(true);
        }
        public void UpdatePortsInComponentInstances()
        {
            /* Remove unexists port in defenition */
            foreach (CompositionInstance composition in Compositions)
            {
                foreach (ComponentInstance compInstance in composition.ComponentInstances)
                {
                    ComponentDefenition compDefenition = compInstance.ComponentDefenition;
                    for (int i = compInstance.Ports.Count - 1; i >= 0; i--)
                    {
                        PortPainter    portPainter    = compInstance.Ports[i];
                        PortDefenition portDefenition = compDefenition.Ports.FindObject(portPainter.PortDefenitionGuid);
                        if (portDefenition == null)
                        {
                            DeletePort(portPainter);
                        }
                    }
                }
            }

            /* Add new or missing ports */
            foreach (CompositionInstance composition in Compositions)
            {
                foreach (ComponentInstance compInstance in composition.ComponentInstances)
                {
                    ComponentDefenition compDefenition = compInstance.ComponentDefenition;
                    foreach (PortDefenition portDef in compDefenition.Ports)
                    {
                        bool find = false;
                        foreach (PortPainter portPainter in compInstance.Ports)
                        {
                            if (portPainter.PortDefenition.Equals(portDef))
                            {
                                find = true;
                                break;
                            }
                        }
                        if (!find)
                        {
                            double x = compInstance.Painter.Left - PortPainter.DefaultWidth / 2.0;
                            double y = (compInstance.Painter.Top + compInstance.Painter.Bottom) / 2;

                            PortPainter portPainter = ComponentFabric.GetInstance().CreatePortPainter(portDef, x, y);
                            compInstance.Ports.Add(portPainter);
                        }
                    }
                }
            }
        }
Beispiel #10
0
        void WriteZeroDefaultValueForSenderPort(StreamWriter writer, PortDefenition portDef, SenderReceiverInterface srInterface)
        {
            for (int j = 0; j < srInterface.Fields.Count; j++)
            {
                SenderReceiverInterfaceField field = srInterface.Fields[j];

                writer.Write("    ." + RteFunctionsGenerator.GenerateRteWriteFieldInComponentDefenitionStruct(portDef, field) + " = ");

                WriteZeroDefaultValue(writer, field.DataType);

                if (j < srInterface.Fields.Count - 1)
                {
                    writer.WriteLine(",");
                }
            }
        }
Beispiel #11
0
        public static String GenerateReadWriteFunctionName(PortDefenition port, SenderReceiverInterfaceField field)
        {
            String res = "Rte_";

            if (port.PortType == PortType.Sender)
            {
                res += "Write_";
            }
            else
            {
                res += "Read_";
            }

            res += port.Name + "_" + field.Name;
            return(res);
        }
Beispiel #12
0
        public void AddPort(PortDefenition newPortDefenition)
        {
            PortsDefenitions.Add(newPortDefenition);

            PortPainter externalPort = new PortPainter(newPortDefenition.GUID, Painter.Left - PortPainter.DefaultWidth / 2.0, Painter.Top + 25, newPortDefenition.Name);

            externalPort.IsDelegatePort = false;
            Ports.Add(externalPort);

            PortPainter internalPort = new PortPainter(newPortDefenition.GUID, 0, 0, newPortDefenition.Name);

            internalPort.IsDelegatePort = true;
            InternalPortsInstances.Add(internalPort);

            Ports.DoSort();
            InternalPortsInstances.DoSort();
        }
        public void AddPortButtonClick(object sender, System.Windows.RoutedEventArgs e)
        {
            if (composition != null)
            {
                if (AddPortForm.GetInstance().ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    PortDefenition newPortDef = AddPortForm.GetInstance().CreatedPortDefenition;
                    if (newPortDef != null)
                    {
                        composition.AddPort(newPortDef);

                        UpdatePortsGrid();
                        tree.UpdateAutosarTreeView(tree.SelectedItem);
                    }
                }
            }
        }
Beispiel #14
0
        public static String GenerateReadWriteConnectionFunctionName(PortDefenition port, SenderReceiverInterfaceField field)
        {
            String res = "Rte_";

            if (port.PortType == PortType.Sender)
            {
                res += "Write_";
            }
            else
            {
                res += "Read_";
            }

            ComponentDefenition compDefenition = AutosarApplication.GetInstance().FindComponentDefenitionByPort(port);

            res += compDefenition.Name + "_" + port.Name + "_" + field.Name;

            return(res);
        }
        protected virtual void RenderEntrails(RenderContext context)
        {
            PortDefenition portDef = AutosarApplication.GetInstance().GetPortDefenition(PortDefenitionGuid);

            if (portDef != null)
            {
                if (portDef.PortType == PortDefenitions.PortType.Client)
                {
                    if (!isDelegate)
                    {
                        ClientPort.RenderEntrails(context, this.rectanglePainter, ConnectionPortLocation);
                    }
                    else
                    {
                        ClientPort.RenderEntrails(context, this.rectanglePainter, RectangleSide.Right);
                    }
                }
                else if (portDef.PortType == PortDefenitions.PortType.Server)
                {
                    ServerPort.RenderEntrails(context, this.rectanglePainter);
                }
                else if (portDef.PortType == PortDefenitions.PortType.Sender)
                {
                    if (!isDelegate)
                    {
                        SenderPort.RenderEntrails(context, this.rectanglePainter, ConnectionPortLocation);
                    }
                    else
                    {
                        SenderPort.RenderEntrails(context, this.rectanglePainter, RectangleSide.Right);
                    }
                }
                else if (portDef.PortType == PortDefenitions.PortType.Receiver)
                {
                    ReceiverPortPainter.RenderEntrails(context, this.rectanglePainter, ConnectionPortLocation);
                }
            }
            else
            {
                EmptyPort.RenderEntrails(context, this.rectanglePainter);
            }
        }
Beispiel #16
0
        public bool DeletePortButtonClick()
        {
            int  index  = portsGrid.SelectedIndex;
            bool result = false;

            if ((index < portsGrid.Items.Count) && (index >= 0))
            {
                PortDefenition portDef = portsGrid.Items[index] as PortDefenition;
                bool           delete  = MessageUtilities.AskToDelete("Do you want to delete " + portDef.Name + "?");
                if (delete == true)
                {
                    _componentDefenition.Ports.Remove(portDef);
                    AutosarApplication.GetInstance().UpdatePortsInComponentInstances();
                    tree.UpdateAutosarTreeView(tree.SelectedItem);
                    RefreshPortsGridView();
                    result = true;
                }
            }
            return(result);
        }
        public PortDefenition FindPortDefenition(Guid portDefenitionGuid)
        {
            /* Check component's ports */
            foreach (ComponentDefenition compDef in this.ComponentDefenitionsList)
            {
                PortDefenition portDefenition = compDef.Ports.FindObject(portDefenitionGuid);
                if (portDefenition != null)
                {
                    return(portDefenition);
                }
            }

            /* Check composition's ports */
            foreach (CompositionInstance composition in this.compositions)
            {
                PortDefenition portDefenition = composition.PortsDefenitions.FindObject(portDefenitionGuid);
                if (portDefenition != null)
                {
                    return(portDefenition);
                }
            }

            return(null);
        }
Beispiel #18
0
        void GenerateRteCallPortFieldFunction(StreamWriter writer, ComponentDefenition compDef, PortDefenition port, ClientServerOperation operation)
        {
            String returnValue   = Properties.Resources.STD_RETURN_TYPE;
            String RteFuncName   = RteFunctionsGenerator.Generate_RteCall_FunctionName(port, operation);
            String fieldVariable = RteFunctionsGenerator.GenerateClientServerInterfaceArguments(operation, compDef.MultipleInstantiation);

            writer.WriteLine(returnValue + RteFuncName + fieldVariable);
            writer.WriteLine("{");
            writer.WriteLine("    " + TestArtefactsVariable + "." + RteFuncName + "." + CallCount + "++;");
            foreach (var csField in operation.Fields)
            {
                writer.WriteLine("    " + TestArtefactsVariable + "." + RteFuncName + ".Arguments." + csField.Name + " = *" + csField.Name + ";");
            }
            writer.WriteLine("    return " + TestArtefactsVariable + "." + RteFuncName + ".ReturnValue;");
            writer.WriteLine("}");
            writer.WriteLine("");
        }
Beispiel #19
0
 public static String GenerateRteWriteFieldInComponentDefenitionStruct(PortDefenition portDefenition, SenderReceiverInterfaceField field)
 {
     return("Rte_WriteField_" + portDefenition.Name + "_" + field.Name);
 }
 public ComponentDefenition FindComponentDefenitionByPort(PortDefenition portDefenition)
 {
     return(FindComponentDefenitionByPortGuid(portDefenition.GUID));
 }
Beispiel #21
0
 public static String Generate_RteCall_FunctionName(PortDefenition portDef, ClientServerOperation operation)
 {
     return("Rte_Call_" + portDef.Name + "_" + operation.Name);
 }
Beispiel #22
0
        void CreateServerCalls(String dir, ComponentDefenition compDefenition, PortDefenition portDefenition)
        {
            String       filename = dir + compDefenition.Name + "_" + portDefenition.Name + ".c";
            StreamWriter writer   = new StreamWriter(filename);

            RteFunctionsGenerator.GenerateFileTitle(writer, filename, "Implementation for " + compDefenition.Name + " " + portDefenition.Name);

            writer.WriteLine("");
            writer.WriteLine(RteFunctionsGenerator.IncludesLine);
            RteFunctionsGenerator.AddInclude(writer, compDefenition.Name + ".h");
            writer.WriteLine("");
            writer.WriteLine(RteFunctionsGenerator.EndOfIncludesLine);
            writer.WriteLine("");

            writer.WriteLine("");
            writer.WriteLine(RteFunctionsGenerator.MacrosLine);
            writer.WriteLine("");
            writer.WriteLine(RteFunctionsGenerator.EndOfMacrosLine);
            writer.WriteLine("");

            writer.WriteLine("");
            writer.WriteLine(RteFunctionsGenerator.TypeDefenitionsLine);
            writer.WriteLine("");
            writer.WriteLine(RteFunctionsGenerator.EndOfTypeDefenitionsLine);
            writer.WriteLine("");

            writer.WriteLine("");
            writer.WriteLine(RteFunctionsGenerator.VariablesLine);
            writer.WriteLine("");
            writer.WriteLine(RteFunctionsGenerator.EndOfVariableLine);
            writer.WriteLine("");

            writer.WriteLine("");
            writer.WriteLine(RteFunctionsGenerator.LocalFunctionsDeclarationLine);
            writer.WriteLine("");
            writer.WriteLine(RteFunctionsGenerator.EndOfLocalFunctionsDeclarationLine);
            writer.WriteLine("");

            writer.WriteLine("");
            writer.WriteLine(RteFunctionsGenerator.LocalFunctionsDefenitionsLine);
            writer.WriteLine("");
            writer.WriteLine(RteFunctionsGenerator.EndOfLocalFunctionsDefenitionsLine);
            writer.WriteLine("");

            writer.WriteLine("");
            writer.WriteLine(RteFunctionsGenerator.GlobalFunctionsDefenitionsLine);
            writer.WriteLine("");
            ClientServerInterface csInterface = AutosarApplication.GetInstance().ClientServerInterfaces.FindObject(portDefenition.InterfaceGUID);

            if (csInterface != null)
            {
                foreach (ClientServerOperation operation in csInterface.Operations)
                {
                    /* Fill functions which component could use */
                    /* Fill all function names which component could use*/
                    WriteAllFunctionWhichComponentCouldUse(compDefenition, writer);

                    String funcName     = RteFunctionsGenerator.Generate_RteCall_FunctionName(portDefenition, operation);
                    String funcArgument = RteFunctionsGenerator.GenerateClientServerInterfaceArguments(operation, compDefenition.MultipleInstantiation);
                    writer.WriteLine(Properties.Resources.STD_RETURN_TYPE + funcName + funcArgument);
                    writer.WriteLine("{");
                    writer.WriteLine("    return " + Properties.Resources.RTE_E_OK + ";");
                    writer.WriteLine("}");
                    writer.WriteLine("");
                }

                writer.WriteLine(RteFunctionsGenerator.EndOfGlobalFunctionsDefenitionsLine);
                writer.WriteLine("");

                RteFunctionsGenerator.WriteEndOfFile(writer);
                writer.Close();
            }
            else
            {
                System.Windows.MessageBox.Show(portDefenition.GUID.ToString("B") + " not found in interfaces!");
            }
        }
 public void GenerateFieldsForSenderPorts(StreamWriter writer, ComponentDefenition componentDefenition, PortDefenition portDefenition, SenderReceiverInterfaceField srInterfaceField)
 {
     writer.WriteLine("    " + srInterfaceField.DataTypeName + " " + RteFunctionsGenerator.GenerateRteWriteFieldInComponentDefenitionStruct(portDefenition, srInterfaceField) + ";");
 }
Beispiel #24
0
        public PortPainter GetExternalPortPainter(PortDefenition portDef)
        {
            PortPainter portPainter = base.GetPort(portDef);

            return(portPainter);
        }
Beispiel #25
0
        void GenerateRteCallPortFieldFunction(StreamWriter writer, ComponentDefenition compDef, PortDefenition port, ClientServerOperation operation)
        {
            String returnValue   = Properties.Resources.STD_RETURN_TYPE;
            String RteFuncName   = RteFunctionsGenerator.Generate_RteCall_ConnectionGroup_FunctionName(compDef, port, operation);
            String fieldVariable = RteFunctionsGenerator.GenerateClientServerInterfaceArguments(operation, compDef.MultipleInstantiation);

            writer.WriteLine(returnValue + RteFuncName + fieldVariable);
            writer.WriteLine("{");


            if (!compDef.MultipleInstantiation) //single instantiation component
            {
                ComponentInstancesList components = AutosarApplication.GetInstance().GetComponentInstanceByDefenition(compDef);
                if (components.Count > 0)
                {
                    ComponentInstance compInstance = components[0];

                    PortPainter       portPainter = compInstance.Ports.FindPortByItsDefenition(port);
                    ComponentInstance oppositCompInstance;
                    PortPainter       oppositePort;
                    AutosarApplication.GetInstance().GetOppositePortAndComponent(portPainter, out oppositCompInstance, out oppositePort);
                    if (oppositCompInstance != null)
                    {
                        String functionName = RteFunctionsGenerator.Generate_RteCall_ConnectionGroup_FunctionName(oppositCompInstance.ComponentDefenition, oppositePort.PortDefenition, operation);
                        String arguments    = RteFunctionsGenerator.Generate_ClientServerPort_Arguments(oppositCompInstance, operation, oppositCompInstance.ComponentDefenition.MultipleInstantiation);
                        writer.WriteLine("    return " + functionName + arguments + ";");
                    }
                    else
                    {
                        writer.WriteLine("    return " + Properties.Resources.RTE_E_UNCONNECTED + ";");
                    }
                }
            }
            else //multiple instantiation component
            {
                ComponentInstancesList components = AutosarApplication.GetInstance().GetComponentInstanceByDefenition(compDef);
                if (components.Count > 0)
                {
                    writer.WriteLine("    switch(((" + compDef.Name + "*)" + "instance)->index)");
                    writer.WriteLine("    {");
                    for (int i = 0; i < components.Count; i++)
                    {
                        ComponentInstance compInstance = components[i];
                        PortPainter       portPainter  = compInstance.Ports.FindPortByItsDefenition(port);
                        ComponentInstance oppositCompInstance;
                        PortPainter       oppositePort;
                        AutosarApplication.GetInstance().GetOppositePortAndComponent(portPainter, out oppositCompInstance, out oppositePort);

                        writer.WriteLine("        case " + i.ToString() + ": ");
                        writer.WriteLine("        {");

                        if (oppositCompInstance != null)
                        {
                            String functionName = RteFunctionsGenerator.Generate_RteCall_ConnectionGroup_FunctionName(oppositCompInstance.ComponentDefenition, oppositePort.PortDefenition, operation);
                            String arguments    = RteFunctionsGenerator.Generate_ClientServerPort_Arguments(oppositCompInstance, operation, oppositCompInstance.ComponentDefenition.MultipleInstantiation);
                            writer.WriteLine("            return " + functionName + arguments + ";");
                        }
                        else
                        {
                            writer.WriteLine("            return " + Properties.Resources.RTE_E_UNCONNECTED + ";");
                        }

                        writer.WriteLine("        }");
                    }
                    writer.WriteLine("    }");
                }
                writer.WriteLine("    return " + Properties.Resources.RTE_E_UNCONNECTED + ";");
            }
            writer.WriteLine("}");
            writer.WriteLine("");
        }
Beispiel #26
0
        void GenerateRteReadPortFieldFunction(StreamWriter writer, ComponentDefenition compDef, PortDefenition port, SenderReceiverInterfaceField field)
        {
            String returnValue   = Properties.Resources.STD_RETURN_TYPE;
            String RteFuncName   = RteFunctionsGenerator.GenerateReadWriteConnectionFunctionName(port, field);
            String fieldVariable = RteFunctionsGenerator.GenerateSenderReceiverInterfaceArguments(field, port.PortType, compDef.MultipleInstantiation);

            writer.WriteLine(returnValue + RteFuncName + fieldVariable);
            writer.WriteLine("{");

            if (!compDef.MultipleInstantiation) //single instantiation component
            {
                ComponentInstancesList components = AutosarApplication.GetInstance().GetComponentInstanceByDefenition(compDef);
                if (components.Count > 0)
                {
                    /* At least one component exists at this step */
                    ComponentInstance compInstance = components[0];

                    PortPainter       portPainter = compInstance.Ports.FindPortByItsDefenition(port);
                    ComponentInstance oppositCompInstance;
                    PortPainter       oppositePort;
                    AutosarApplication.GetInstance().GetOppositePortAndComponent(portPainter, out oppositCompInstance, out oppositePort);
                    if (oppositCompInstance != null)
                    {
                        String copyFromField    = RteFunctionsGenerator.GenerateRteWriteFieldInComponentDefenitionStruct(oppositePort.PortDefenition, field);
                        String oppositeCompName = RteFunctionsGenerator.GenerateComponentName(oppositCompInstance.Name);
                        writer.WriteLine("    memcpy(" + field.Name + ", " + "&" + oppositeCompName + "." + copyFromField + ", sizeof(" + field.DataTypeName + "));");
                        writer.WriteLine("    return " + Properties.Resources.RTE_E_OK + ";");
                    }
                    else
                    {
                        writer.WriteLine("    memset(" + field.Name + ", " + "0, sizeof(" + field.DataTypeName + "));");
                        writer.WriteLine("    return " + Properties.Resources.RTE_E_UNCONNECTED + ";");
                    }
                }
            }
            else //multiple instantiation component
            {
                ComponentInstancesList components = AutosarApplication.GetInstance().GetComponentInstanceByDefenition(compDef);
                if (components.Count > 0)
                {
                    writer.WriteLine("    switch(((" + compDef.Name + "*)" + "instance)->index)");
                    writer.WriteLine("    {");
                    for (int i = 0; i < components.Count; i++)
                    {
                        ComponentInstance compInstance = components[i];
                        PortPainter       portPainter  = compInstance.Ports.FindPortByItsDefenition(port);
                        ComponentInstance oppositCompInstance;
                        PortPainter       oppositePort;
                        AutosarApplication.GetInstance().GetOppositePortAndComponent(portPainter, out oppositCompInstance, out oppositePort);

                        writer.WriteLine("        case " + i.ToString() + ": ");
                        writer.WriteLine("        {");

                        if (oppositCompInstance != null)
                        {
                            String copyFromField    = RteFunctionsGenerator.GenerateRteWriteFieldInComponentDefenitionStruct(oppositePort.PortDefenition, field);
                            String oppositeCompName = RteFunctionsGenerator.GenerateComponentName(oppositCompInstance.Name);
                            writer.WriteLine("            memcpy(" + field.Name + ", " + "&" + oppositeCompName + "." + copyFromField + ", sizeof(" + field.DataTypeName + "));");
                            writer.WriteLine("            return " + Properties.Resources.RTE_E_OK + ";");
                        }
                        else
                        {
                            writer.WriteLine("            memset(" + field.Name + ", " + "0, sizeof(" + field.DataTypeName + "));");
                            writer.WriteLine("            return " + Properties.Resources.RTE_E_UNCONNECTED + ";");
                        }

                        writer.WriteLine("        }");
                    }
                    writer.WriteLine("    }");
                }
                writer.WriteLine("    return " + Properties.Resources.RTE_E_UNCONNECTED + ";");
            }

            writer.WriteLine("}");
            writer.WriteLine("");
        }
Beispiel #27
0
        void GenerateRteWritePortFieldFunction(StreamWriter writer, ComponentDefenition compDef, PortDefenition port, SenderReceiverInterfaceField field)
        {
            String returnValue   = Properties.Resources.STD_RETURN_TYPE;
            String RteFuncName   = RteFunctionsGenerator.GenerateReadWriteConnectionFunctionName(port, field);
            String fieldVariable = RteFunctionsGenerator.GenerateSenderReceiverInterfaceArguments(field, port.PortType, compDef.MultipleInstantiation);

            writer.WriteLine(returnValue + RteFuncName + fieldVariable);
            writer.WriteLine("{");

            if (!compDef.MultipleInstantiation) //single instantiation component
            {
                ComponentInstancesList components = AutosarApplication.GetInstance().GetComponentInstanceByDefenition(compDef);
                if (components.Count > 0)
                {
                    ComponentInstance compInstance = components[0];
                    String            compName     = RteFunctionsGenerator.GenerateComponentName(compInstance.Name);
                    String            fieldName    = RteFunctionsGenerator.GenerateRteWriteFieldInComponentDefenitionStruct(port, field);
                    writer.WriteLine("    " + compName + "." + fieldName + " = *" + field.Name + ";");
                }
            }
            else //multiple instantiation component
            {
                String rteStructFieldName = RteFunctionsGenerator.GenerateRteWriteFieldInComponentDefenitionStruct(port, field);
                String instanceLine       = "((" + compDef.Name + "*)instance)->" + rteStructFieldName + " = *" + field.Name + ";";
                writer.WriteLine("    " + instanceLine);
            }

            writer.WriteLine("    return " + Properties.Resources.RTE_E_OK + ";");
            writer.WriteLine("}");
            writer.WriteLine("");
            //}
        }
Beispiel #28
0
        public void AddConnection(PortConnection newConnection)
        {
            /* Connection cann't be dublicated */
            bool foundSimilarConnection = false;

            foreach (PortConnection connection in this)
            {
                if (connection.Component1.GUID.Equals(newConnection.Component1.GUID) && connection.Port1.GUID.Equals(newConnection.Port1.GUID) &&
                    connection.Component2.GUID.Equals(newConnection.Component2.GUID) && connection.Port2.GUID.Equals(newConnection.Port2.GUID))
                {
                    foundSimilarConnection = true;
                    break;
                }

                if (connection.Component1.GUID.Equals(newConnection.Component2.GUID) && connection.Port1.GUID.Equals(newConnection.Port2.GUID) &&
                    connection.Component2.GUID.Equals(newConnection.Component1.GUID) && connection.Port2.GUID.Equals(newConnection.Port1.GUID))
                {
                    foundSimilarConnection = true;
                    break;
                }
            }

            if (foundSimilarConnection)
            {
                return;
            }

            /* Client and Receiver connections can't have more than one connection */
            PortDefenition portDef1 = AutosarApplication.GetInstance().GetPortDefenition(newConnection.Port1.PortDefenitionGuid);


            if (!newConnection.Port1.IsDelegatePort) /* Port of component */
            {
                if ((portDef1.PortType == PortType.Client) || (portDef1.PortType == PortType.Receiver))
                {
                    if (IsThisPointConnectionExists(newConnection.Component1, newConnection.Port1) == true)
                    {
                        return;
                    }
                }
            }
            else /* Port of composition */
            {
                if ((portDef1.PortType == PortType.Sender) || (portDef1.PortType == PortType.Server))
                {
                    if (IsThisPointConnectionExists(newConnection.Component1, newConnection.Port1) == true)
                    {
                        return;
                    }
                }
            }

            PortDefenition portDef2 = AutosarApplication.GetInstance().GetPortDefenition(newConnection.Port2.PortDefenitionGuid);

            if (!newConnection.Port2.IsDelegatePort) /* Port of component */
            {
                if ((portDef2.PortType == PortType.Client) || (portDef2.PortType == PortType.Receiver))
                {
                    if (IsThisPointConnectionExists(newConnection.Component2, newConnection.Port2) == true)
                    {
                        return;
                    }
                }
            }
            else /* Port of composition */
            {
                if ((portDef2.PortType == PortType.Sender) || (portDef2.PortType == PortType.Server))
                {
                    if (IsThisPointConnectionExists(newConnection.Component2, newConnection.Port2) == true)
                    {
                        return;
                    }
                }
            }


            this.Add(newConnection);
        }
        public void Render(RenderContext context)
        {
            if (Selected)
            {
                context.DrawFillRectangle(rectanglePainter.TopLeft.X - 5, rectanglePainter.TopLeft.Y - 5, rectanglePainter.BottomRight.X + 5, rectanglePainter.BottomRight.Y, Colors.Green);
                context.DrawFillRectangle(rectanglePainter.TopLeft.X - 5, rectanglePainter.BottomRight.Y, rectanglePainter.BottomRight.X + 5, rectanglePainter.BottomRight.Y + 5, Colors.Green);
                context.DrawFillRectangle(rectanglePainter.TopLeft.X - 5, rectanglePainter.TopLeft.Y - 5, rectanglePainter.TopLeft.X, rectanglePainter.BottomRight.Y + 5, Colors.Green);
                context.DrawFillRectangle(rectanglePainter.BottomRight.X, rectanglePainter.TopLeft.Y - 5, rectanglePainter.BottomRight.X + 5, rectanglePainter.BottomRight.Y + 5, Colors.Green);
            }

            rectanglePainter.Render(context);
            context.DrawFillRectangle(rectanglePainter.TopLeft.X, rectanglePainter.TopLeft.Y, rectanglePainter.BottomRight.X, rectanglePainter.BottomRight.Y, rectanglePainter.BackgroundColor);

            RenderEntrails(context);

            context.DrawRectangle(rectanglePainter.TopLeft.X, rectanglePainter.TopLeft.Y, rectanglePainter.BottomRight.X, rectanglePainter.BottomRight.Y, Colors.Black);

            /* Draw port name*/
            Point rectangleCenter = rectanglePainter.Center;

            portNamePainter.Text      = PortDefenition.Name;
            portNamePainter.Font      = AutosarApplication.GetInstance().PortsNamesFont;
            portNamePainter.TextColor = Colors.Black;

            if (isDelegate == false)
            {
                switch (ConnectionPortLocation)
                {
                case RectangleSide.Left:
                {
                    portNamePainter.Direction     = TextDirection.LeftToRight;
                    portNamePainter.Coordinates.X = rectangleCenter.X + 15.0;
                    portNamePainter.Coordinates.Y = rectangleCenter.Y;
                    break;
                }

                case RectangleSide.Right:
                {
                    portNamePainter.Direction     = TextDirection.RightToLeft;
                    portNamePainter.Coordinates.X = rectangleCenter.X - 15.0;
                    portNamePainter.Coordinates.Y = rectangleCenter.Y;
                    break;
                }

                case RectangleSide.Top:
                {
                    portNamePainter.Direction     = TextDirection.TopToBottom;
                    portNamePainter.Coordinates.X = rectangleCenter.X;
                    portNamePainter.Coordinates.Y = rectangleCenter.Y + 15.0;
                    break;
                }

                case RectangleSide.Bottom:
                {
                    portNamePainter.Direction     = TextDirection.BottomToTop;
                    portNamePainter.Coordinates.X = rectangleCenter.X;
                    portNamePainter.Coordinates.Y = rectangleCenter.Y - 15.0;
                    break;
                }

                default:
                {
                    break;
                }
                }
            }
            else /* isDelegate is true */
            {
                PortDefenition portDef = AutosarApplication.GetInstance().GetPortDefenition(PortDefenitionGuid);
                if ((portDef.PortType == PortDefenitions.PortType.Client) || (portDef.PortType == PortDefenitions.PortType.Sender))
                {
                    portNamePainter.Direction     = TextDirection.LeftToRight;
                    portNamePainter.Coordinates.X = rectangleCenter.X + 15.0;
                    portNamePainter.Coordinates.Y = rectangleCenter.Y;
                }
                else
                {
                    portNamePainter.Direction     = TextDirection.RightToLeft;
                    portNamePainter.Coordinates.X = rectangleCenter.X - 15.0;
                    portNamePainter.Coordinates.Y = rectangleCenter.Y;
                }
            }
            portNamePainter.Render(context);
        }
Beispiel #30
0
 public static String Generate_RteCall_ConnectionGroup_FunctionName(ComponentDefenition compDef, PortDefenition port, ClientServerOperation operation)
 {
     return("Rte_Call_" + compDef.Name + "_" + port.Name + "_" + operation.Name);
 }