Ejemplo n.º 1
0
        private void AddClientServerMenu_Click(object sender, RoutedEventArgs e)
        {
            ClientServerInterface csInterface = clientServerInterfaceController.CreateClientServerInterface();

            AutosarTree.UpdateAutosarTreeView(csInterface);
            AutosarTree.Focus();
        }
 public bool Delete(ClientServerInterface datatype)
 {
     if (isClientServerInterfaceUsed(datatype) == false)
     {
         ClientServerInterfaces.Remove(datatype);
         return(true);
     }
     else
     {
         /* datatype is used and we cannot delete it */
         return(false);
     }
 }
Ejemplo n.º 3
0
 void CreateRteCallFunctions(StreamWriter writer, ComponentDefenition compDefenition)
 {
     foreach (PortDefenition port in compDefenition.Ports)
     {
         if (port.PortType == PortType.Client)
         {
             ClientServerInterface csInterface = port.InterfaceDatatype as ClientServerInterface;
             foreach (ClientServerOperation operation in csInterface.Operations)
             {
                 GenerateRteCallPortFieldFunction(writer, compDefenition, port, operation);
             }
         }
     }
 }
        void Generate_ExternalRunnables_File()
        {
            String       FileName = RteFunctionsGenerator.GetRteFolder() + "\\" + Properties.Resources.RTE_EXTERNAL_RUNNABLES_H_FILENAME;
            StreamWriter writer   = new StreamWriter(FileName);

            RteFunctionsGenerator.GenerateFileTitle(writer, FileName, Properties.Resources.RTE_EXTERNAL_RUNNABLES_FILE_DESCRIPTION);
            RteFunctionsGenerator.OpenGuardDefine(writer);

            writer.WriteLine();
            writer.WriteLine("/* Declaration of all periodic runnables */");
            writer.WriteLine();
            foreach (ComponentDefenition compDefinition in AutosarApplication.GetInstance().ComponentDefenitionsList)
            {
                foreach (PeriodicRunnableDefenition runnable in compDefinition.Runnables)
                {
                    writer.WriteLine(RteFunctionsGenerator.Generate_RunnableFunction(compDefinition, runnable) + ";");
                }
            }

            writer.WriteLine();
            writer.WriteLine("/* Declaration of all server call functions */");
            writer.WriteLine();
            foreach (ComponentDefenition componentDefenition in AutosarApplication.GetInstance().ComponentDefenitionsList)
            {
                foreach (PortDefenition port in componentDefenition.Ports)
                {
                    if (port.PortType == PortType.Server)
                    {
                        ClientServerInterface csInterface = AutosarApplication.GetInstance().ClientServerInterfaces.FindObject(port.InterfaceGUID);
                        if (csInterface != null)
                        {
                            foreach (ClientServerOperation operation in csInterface.Operations)
                            {
                                String funcName      = RteFunctionsGenerator.Generate_RteCall_ConnectionGroup_FunctionName(componentDefenition, port, operation);
                                String funcArguments = RteFunctionsGenerator.GenerateClientServerInterfaceArguments(operation, componentDefenition.MultipleInstantiation);
                                writer.WriteLine(Properties.Resources.STD_RETURN_TYPE + funcName + funcArguments + ";");
                            }
                        }
                    }
                }
            }

            writer.WriteLine();
            RteFunctionsGenerator.CloseGuardDefine(writer);

            writer.WriteLine();
            RteFunctionsGenerator.WriteEndOfFile(writer);
            writer.Close();
        }
Ejemplo n.º 5
0
 void CreateRteCallFunctionDeclarations(StreamWriter writer, ComponentDefenition compDefenition)
 {
     foreach (PortDefenition port in compDefenition.Ports)
     {
         if (port.PortType == PortType.Server)
         {
             ClientServerInterface csInterface = port.InterfaceDatatype as ClientServerInterface;
             foreach (ClientServerOperation operation in csInterface.Operations)
             {
                 String returnValue   = Properties.Resources.STD_RETURN_TYPE;
                 String RteFuncName   = RteFunctionsGenerator.Generate_RteCall_FunctionName(port, operation);
                 String fieldVariable = RteFunctionsGenerator.GenerateClientServerInterfaceArguments(operation, compDefenition.MultipleInstantiation);
                 String writeValue    = returnValue + RteFuncName + fieldVariable + ";";
                 writer.WriteLine(writeValue);
             }
         }
     }
 }
        public ClientServerInterface CreateClientServerInterface()
        {
            string templateName = "iClientServer";

            if (AutosarApplication.GetInstance().ClientServerInterfaces.FindObject(templateName) != null)
            {
                int index = 0;
                while (AutosarApplication.GetInstance().ClientServerInterfaces.FindObject(templateName) != null)
                {
                    index++;
                    templateName = "iClientServer" + index.ToString();
                }
            }

            ClientServerInterface csInterface = DataTypeFabric.Instance().CreateClientServerInterface(templateName);

            AutosarApplication.GetInstance().ClientServerInterfaces.Add(csInterface);
            return(csInterface);
        }
Ejemplo n.º 7
0
        protected void TestClientServer(ClientServerInterface elem)
        {
            bool withoutErrors = true;

            if (elem.Operations.Count == 0)
            {
                AppendText(elem.Name + " :  does not have any operations!", Error: true);
            }

            /* Check if there is an operation with similar names */
            withoutErrors &= CheckSimilarNames(elem.Operations.ConvertAll(x => x as IGUID), elem.Name + ": operations");

            /* Check if there is an similar fields in an operation */
            foreach (ClientServerOperation operation in elem.Operations)
            {
                withoutErrors &= CheckSimilarNames(operation.Fields.ConvertAll(x => x as IGUID), elem.Name + ": operation fields");
            }

            /* CheckDatatype */
            foreach (ClientServerOperation operation in elem.Operations)
            {
                foreach (ClientServerOperationField field in operation.Fields)
                {
                    if (field.DataTypeName.Equals(AutosarApplication.ErrorDataType))
                    {
                        AppendText(elem.Name + " : " + operation.Name + " : " + field.Name + " doesn't have specified datatype ", Error: true);
                        withoutErrors = false;
                    }
                }
            }

            if (withoutErrors)
            {
                AppendText(elem.Name);
            }
        }
Ejemplo n.º 8
0
 public ClientServerInterface CreateClientServerInterface(String Name)
 {
     ClientServerInterface csInterface = new ClientServerInterface();
     csInterface.Name = Name;
     return csInterface;
 }
 public bool isClientServerInterfaceUsed(ClientServerInterface datatype)
 {
     return(false);
 }
Ejemplo n.º 10
0
        /* Generate funcitons for Sender-Receiver ports and call operations from client ports */
        public void CreateRteIncludes(String dir, ComponentDefenition componentDefenition)
        {
            String       filename = dir + "\\" + "Rte_" + componentDefenition.Name + ".h";
            StreamWriter writer   = new StreamWriter(filename);

            RteFunctionsGenerator.GenerateFileTitle(writer, filename, "Implementation for " + componentDefenition.Name + " header file");
            string guardDefine = RteFunctionsGenerator.OpenGuardDefine(writer);

            writer.WriteLine("");
            writer.WriteLine(RteFunctionsGenerator.IncludesLine);
            RteFunctionsGenerator.AddInclude(writer, Properties.Resources.SYSTEM_ERRORS_H_FILENAME);
            RteFunctionsGenerator.AddInclude(writer, Properties.Resources.RTE_DATATYPES_H_FILENAME);
            writer.WriteLine("");
            writer.WriteLine(RteFunctionsGenerator.EndOfIncludesLine);
            writer.WriteLine("");

            /* MACROS */
            writer.WriteLine("");
            writer.WriteLine(RteFunctionsGenerator.MacrosLine);

            /* Write all runnables frequences */
            writer.WriteLine("/* Runnables frequences */");
            foreach (PeriodicRunnableDefenition runnable in componentDefenition.Runnables)
            {
                String runnableFreqMacroName = "Rte_Period_" + componentDefenition.Name + "_ru" + runnable.Name;
                String define = RteFunctionsGenerator.CreateDefine(runnableFreqMacroName, (runnable.PeriodMs * 1000).ToString() + "UL");
                writer.WriteLine(define);
            }

            /* Write all pims */
            foreach (PimDefenition pim in componentDefenition.PerInstanceMemoryList)
            {
                String define = RteFunctionsGenerator.CreateDefine(RteFunctionsGenerator.GenerateShortPimFunctionName(pim), RteFunctionsGenerator.GenerateFullPimFunctionName(componentDefenition, pim), false);
                writer.WriteLine(define);
            }

            /* Write all cdata */
            foreach (CDataDefenition cdata in componentDefenition.CDataDefenitions)
            {
                String define = RteFunctionsGenerator.CreateDefine(RteFunctionsGenerator.GenerateShortCDataFunctionName(cdata), RteFunctionsGenerator.GenerateFullCDataFunctionName(componentDefenition, cdata), false);
                writer.WriteLine(define);
            }

            String externFunctions = "";

            /* Add defines for all ports */
            foreach (PortDefenition portDefenition in componentDefenition.Ports)
            {
                if ((portDefenition.PortType == PortType.Sender) || (portDefenition.PortType == PortType.Receiver))
                {
                    SenderReceiverInterface srInterface = AutosarApplication.GetInstance().SenderReceiverInterfaces.FindObject(portDefenition.InterfaceGUID);
                    foreach (SenderReceiverInterfaceField field in srInterface.Fields)
                    {
                        String funcName    = RteFunctionsGenerator.GenerateReadWriteFunctionName(portDefenition, field);
                        String RteFuncName = RteFunctionsGenerator.GenerateReadWriteConnectionFunctionName(portDefenition, field);
                        writer.WriteLine(RteFunctionsGenerator.CreateDefine(funcName, RteFuncName, false));
                        String fieldVariable = RteFunctionsGenerator.GenerateSenderReceiverInterfaceArguments(field, portDefenition.PortType, componentDefenition.MultipleInstantiation);

                        externFunctions += Properties.Resources.STD_RETURN_TYPE + funcName + fieldVariable + ";" + Environment.NewLine;
                    }
                }
                else if (portDefenition.PortType == PortType.Client)
                {
                    ClientServerInterface csInterface = AutosarApplication.GetInstance().ClientServerInterfaces.FindObject(portDefenition.InterfaceGUID);
                    foreach (ClientServerOperation operation in csInterface.Operations)
                    {
                        String funcName     = RteFunctionsGenerator.Generate_RteCall_FunctionName(portDefenition, operation);
                        String RteFuncName  = RteFunctionsGenerator.Generate_RteCall_ConnectionGroup_FunctionName(componentDefenition, portDefenition, operation);
                        String funcArgument = RteFunctionsGenerator.GenerateClientServerInterfaceArguments(operation, componentDefenition.MultipleInstantiation);
                        writer.WriteLine(RteFunctionsGenerator.CreateDefine(funcName, RteFuncName, false));
                        externFunctions += Properties.Resources.STD_RETURN_TYPE + funcName + funcArgument + ";" + Environment.NewLine;
                    }
                }
                else if (portDefenition.PortType == PortType.Server)
                {
                    ClientServerInterface csInterface = AutosarApplication.GetInstance().ClientServerInterfaces.FindObject(portDefenition.InterfaceGUID);
                    foreach (ClientServerOperation operation in csInterface.Operations)
                    {
                        String funcName     = RteFunctionsGenerator.Generate_RteCall_FunctionName(portDefenition, operation);
                        String RteFuncName  = RteFunctionsGenerator.Generate_RteCall_ConnectionGroup_FunctionName(componentDefenition, portDefenition, operation);
                        String funcArgument = RteFunctionsGenerator.GenerateClientServerInterfaceArguments(operation, componentDefenition.MultipleInstantiation);
                        writer.WriteLine(RteFunctionsGenerator.CreateDefine(funcName, RteFuncName, false));
                    }
                }
            }

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

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

            /* Add function */
            writer.Write(externFunctions);

            /* Add Pim's functions */
            foreach (PimDefenition pimDefenition in componentDefenition.PerInstanceMemoryList)
            {
                String datatype    = pimDefenition.DataTypeName;
                String pimFuncName = RteFunctionsGenerator.GenerateShortPimFunctionName(pimDefenition);
                String arguments   = "(";
                if (componentDefenition.MultipleInstantiation)
                {
                    arguments += RteFunctionsGenerator.ComponentInstancePointerDatatype + " instance";
                }
                arguments += ");";
                writer.WriteLine(datatype + " * " + pimFuncName + arguments);
            }

            /* Add CData functions */
            foreach (CDataDefenition cdataDefenition in componentDefenition.CDataDefenitions)
            {
                String datatype      = cdataDefenition.DataTypeName;
                String cdataFuncName = RteFunctionsGenerator.GenerateShortCDataFunctionName(cdataDefenition);
                String arguments     = "(";
                if (componentDefenition.MultipleInstantiation)
                {
                    arguments += RteFunctionsGenerator.ComponentInstancePointerDatatype + " instance";
                }
                arguments += ");";
                writer.WriteLine(datatype + " " + cdataFuncName + arguments);
            }

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

            writer.WriteLine("");
            RteFunctionsGenerator.CloseGuardDefine(writer);
            writer.Close();
        }
Ejemplo n.º 11
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!");
            }
        }
Ejemplo n.º 12
0
        private static void WriteAllFunctionWhichComponentCouldUse(ComponentDefenition compDefenition, StreamWriter writer)
        {
            List <String> lines = new List <string>();

            /* Write function name and its body */

            foreach (PimDefenition pimDefenition in compDefenition.PerInstanceMemoryList)
            {
                lines.Add(" *  " + RteFunctionsGenerator.GenerateShortPimFunctionName(pimDefenition));
            }
            foreach (CDataDefenition cdataDefenition in compDefenition.CDataDefenitions)
            {
                lines.Add(" *  " + RteFunctionsGenerator.GenerateShortCDataFunctionName(cdataDefenition));
            }

            foreach (PortDefenition port in compDefenition.Ports)
            {
                if (port.PortType == PortType.Receiver)
                {
                    SenderReceiverInterface srInterface = AutosarApplication.GetInstance().SenderReceiverInterfaces.FindObject(port.InterfaceGUID);
                    foreach (SenderReceiverInterfaceField field in srInterface.Fields)
                    {
                        lines.Add(" *  " + RteFunctionsGenerator.GenerateReadWriteFunctionName(port, field));
                    }
                }
            }

            foreach (PortDefenition port in compDefenition.Ports)
            {
                if (port.PortType == PortType.Sender)
                {
                    SenderReceiverInterface srInterface = AutosarApplication.GetInstance().SenderReceiverInterfaces.FindObject(port.InterfaceGUID);
                    foreach (SenderReceiverInterfaceField field in srInterface.Fields)
                    {
                        lines.Add(" *  " + RteFunctionsGenerator.GenerateReadWriteFunctionName(port, field));
                    }
                }
            }

            foreach (PortDefenition port in compDefenition.Ports)
            {
                if (port.PortType == PortType.Client)
                {
                    ClientServerInterface csInterface = AutosarApplication.GetInstance().ClientServerInterfaces.FindObject(port.InterfaceGUID);
                    foreach (ClientServerOperation operation in csInterface.Operations)
                    {
                        lines.Add(" *  " + RteFunctionsGenerator.Generate_RteCall_FunctionName(port, operation));
                    }
                }
            }

            if (lines.Count > 0)
            {
                writer.WriteLine("/* ");
                writer.WriteLine(" *  This RTE function could be used: ");
                foreach (String str in lines)
                {
                    writer.WriteLine(str);
                }
                writer.WriteLine(" */");
            }
        }
Ejemplo n.º 13
0
        void CreateTestArtefactStructure(StreamWriter writer, ComponentDefenition compDef)
        {
            writer.WriteLine("typedef struct");
            writer.WriteLine("{");

            /* Write All CData structures */
            foreach (CDataDefenition cdataDef in compDef.CDataDefenitions)
            {
                writer.WriteLine("    struct");
                writer.WriteLine("    {");
                writer.WriteLine("        uint32 " + CallCount + ";");
                writer.WriteLine("        " + cdataDef.DataType.Name + " Value;");
                writer.WriteLine("    } " + RteFunctionsGenerator.GenerateShortCDataFunctionName(cdataDef) + ";");
                writer.WriteLine();
            }

            /* Write All Rte Read structures */
            foreach (PortDefenition portDef in compDef.Ports)
            {
                if (portDef.InterfaceDatatype is SenderReceiverInterface)
                {
                    SenderReceiverInterface srInterface = (SenderReceiverInterface)portDef.InterfaceDatatype;
                    foreach (SenderReceiverInterfaceField srField in srInterface.Fields)
                    {
                        writer.WriteLine("    struct");
                        writer.WriteLine("    {");
                        writer.WriteLine("        uint32 " + CallCount + ";");
                        writer.WriteLine("        Std_ReturnType ReturnValue;");

                        writer.WriteLine("        struct");
                        writer.WriteLine("        {");
                        writer.WriteLine("            " + srField.DataTypeName + " data;");
                        writer.WriteLine("        } Arguments;");
                        String fieldName = RteFunctionsGenerator.GenerateReadWriteFunctionName(portDef, srField);
                        writer.WriteLine("    } " + fieldName + ";");
                        writer.WriteLine();
                    }
                }
            }

            /* Write All pims */
            foreach (PimDefenition pimDef in compDef.PerInstanceMemoryList)
            {
                writer.WriteLine("    struct");
                writer.WriteLine("    {");
                writer.WriteLine("        uint32 " + CallCount + ";");
                writer.WriteLine("        " + pimDef.DataTypeName + " data;");
                string pimFieldName = RteFunctionsGenerator.GenerateShortPimFunctionName(pimDef);
                writer.WriteLine("    } " + pimFieldName + ";");
                writer.WriteLine();
            }

            /* Write all client calls */
            foreach (PortDefenition portDef in compDef.Ports)
            {
                if (portDef.InterfaceDatatype is ClientServerInterface)
                {
                    ClientServerInterface srInterface = (ClientServerInterface)portDef.InterfaceDatatype;
                    foreach (ClientServerOperation csOperation in srInterface.Operations)
                    {
                        writer.WriteLine("    struct");
                        writer.WriteLine("    {");
                        writer.WriteLine("        uint32 " + CallCount + ";");
                        writer.WriteLine("        Std_ReturnType ReturnValue;");
                        writer.WriteLine("        struct");
                        writer.WriteLine("        {");
                        foreach (var field in csOperation.Fields)
                        {
                            writer.WriteLine("            " + field.DataTypeName + " " + field.Name + ";");
                        }
                        writer.WriteLine("        } Arguments;");
                        String operationName = RteFunctionsGenerator.Generate_RteCall_FunctionName(portDef, csOperation);
                        writer.WriteLine("    } " + operationName + ";");
                        writer.WriteLine();
                    }
                }
            }

            writer.WriteLine("} " + TestArtefactsStructureDataType + ";");
            writer.WriteLine();
            writer.WriteLine("extern " + TestArtefactsStructureDataType + " " + TestArtefactsVariable + ";");
            writer.WriteLine();
        }