Exemplo n.º 1
0
        public static String GenerateSenderReceiverInterfaceArguments(SenderReceiverInterfaceField field, PortType portType, Boolean MultipleInstantiation = false)
        {
            String result = "(";

            if (MultipleInstantiation)
            {
                result += RteFunctionsGenerator.ComponentInstancePointerDatatype + " instance, ";
            }

            String dataTypeName = AutosarApplication.GetInstance().GetDataTypeName(field.BaseDataTypeGUID);

            if (!field.IsPointer)
            {
                if (portType == PortType.Receiver)
                {
                    result += dataTypeName + " * const " + field.Name;
                }
                else
                {
                    result += "const " + dataTypeName + " * const " + field.Name;
                }
            }
            else
            {
                if (portType == PortType.Receiver)
                {
                    result += dataTypeName + " ** const " + field.Name;
                }
                else
                {
                    result += "const " + dataTypeName + "** const " + field.Name;
                }
            }
            return(result + ")");
        }
        public override void Render(RenderContext context)
        {
            base.Render(context);

            /* Draw component name*/
            GlyphFont glyphFont  = LetterGlyphTool.GetFont(AutosarApplication.GetInstance().ComponentNameFont);
            int       width      = glyphFont.GetTextWidth(Name);
            int       textHeight = glyphFont.GetTextHeight(Name);

            Point textCoord = Painter.Center;

            textCoord.Y  = Painter.Top;
            textCoord    = context.GetImageCoordinate(textCoord);
            textCoord.Y += textHeight;
            textCoord.X -= (double)width / 2.0d;
            context.Bitmap.DrawString((int)textCoord.X, (int)textCoord.Y, Colors.Black, AutosarApplication.GetInstance().ComponentNameFont, Name);

            String defName = "<" + this.ComponentDefenition.Name + ">";

            glyphFont = LetterGlyphTool.GetFont(AutosarApplication.GetInstance().ComponentDefinitionNameFont);
            width     = glyphFont.GetTextWidth(defName);

            textCoord    = Painter.Center;
            textCoord.Y  = Painter.Top;
            textCoord    = context.GetImageCoordinate(textCoord);
            textCoord.X -= (double)width / 2.0d;

            context.Bitmap.DrawString((int)textCoord.X, (int)textCoord.Y, Colors.Black, AutosarApplication.GetInstance().ComponentDefinitionNameFont, defName);
        }
        public Boolean FitWorldToImage(double viewportWidth, double viewportHeight)
        {
            if (AutosarApplication.GetInstance().ActiveComposition != null)
            {
                Boundary boundary = AutosarApplication.GetInstance().ActiveComposition.GetInternalBoundary(scene.Context);

                double scaleX = 1;
                double scaleY = 1;

                if ((boundary.Width > 0.1) & (boundary.Height > 0.1))
                {
                    scaleX = viewportWidth / boundary.Width;
                    scaleY = viewportHeight / boundary.Height;
                }

                double scale = Math.Min(scaleX, scaleY);
                scene.Context.Scale = scale;

                AutosarApplication.GetInstance().UpdateFontAccordingScale(scale);

                //get new scene coordinates for last point
                Point newImageCoordForLastPoint = scene.Context.GetWorldCoordinate(new Point(viewportWidth / 2, viewportHeight / 2));
                Point delta      = new Point(-boundary.MiddleX + newImageCoordForLastPoint.X, -boundary.MiddleY + newImageCoordForLastPoint.Y);
                Point deltaImage = scene.Context.GetImageCoordinate(delta);
                scene.Context.Offset.X = deltaImage.X;
                scene.Context.Offset.Y = deltaImage.Y;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 4
0
 private void NewProject_Click(object sender, RoutedEventArgs e)
 {
     AutosarApplication.GetInstance().Clear();
     AutosarApplication.GetInstance().CreateNewProject();
     openSaveController.Clear();
     AutosarTree.UpdateAutosarTreeView();
 }
        public void WriteSimpleDataType(StreamWriter writer, SimpleDataType datatype)
        {
            writer.WriteLine("/* Datatype : " + datatype.Name + " */");

            /* Write limits */
            String upperLimit = datatype.Name + "_UPPER_LIMIT";
            string maxValue = datatype.MaxValue;
            string minValue = datatype.MinValue;
            if (datatype.GetBaseDataType() == AutosarApplication.GetInstance().BaseDataTypes.float32)
            {
                minValue = acceptFloatValue(datatype.MinValue);
                maxValue = acceptFloatValue(datatype.MaxValue);
            }
            writer.WriteLine(RteFunctionsGenerator.CreateDefine(upperLimit, maxValue));

            String lowerLimit = datatype.Name + "_LOWER_LIMIT";
            writer.WriteLine(RteFunctionsGenerator.CreateDefine(lowerLimit, minValue));

            /* Write datatype */
            String dataTypeName = AutosarApplication.GetInstance().GetDataTypeName(datatype.BaseDataTypeGUID);
            string typedef = RteFunctionsGenerator.FillStringForCount("typedef  " + dataTypeName, ' ', 24);
            writer.WriteLine(typedef + datatype.Name + ";");
            writer.WriteLine("");

            /* Generate an array if it existis*/
            ArrayDataTypeGenerator.GenerateArrayForDataType(writer, datatype);
        }
 void WriteAllOsTasks_FREERTOS(StreamWriter writer, RteOsInterfaceGenerator osGenerator)
 {
     foreach (OsTask osTask in AutosarApplication.GetInstance().OsTasks)
     {
         GenerateOsTaskFunctionCallOfRunnables_FREERTOS(writer, osTask, osGenerator);
     }
 }
 public void UpdateAllRunnablesGrid()
 {
     allFreeRunnables = AutosarApplication.GetInstance().GetAllUnnassignedRunnables();
     allFreeRunnables.SortByName();
     RunnablesGrid.ItemsSource = null;
     RunnablesGrid.ItemsSource = allFreeRunnables;
 }
        public void Viewport_MouseWheel(MouseWheelEventArgs e)
        {
            //Scale image with cursor pointer stayed on last plase
            Point currentPoint = e.GetPosition(image);

            //get pointed scene coordinates
            Point firstSceneCoordinates = scene.MouseToXY(currentPoint);

            double scaleFactor = 0.1;

            if (e.Delta < 0)
            {
                //check direction for mouse wheel
                scene.Context.Scale -= scaleFactor;
            }
            else
            {
                scene.Context.Scale += scaleFactor;
            }


            AutosarApplication.GetInstance().UpdateFontAccordingScale(scene.Context.Scale);

            //get new scene coordinates for last point
            Point newImageCoordForLastPoint = scene.XYtoImage(firstSceneCoordinates);

            scene.Context.Offset.X += currentPoint.X - newImageCoordForLastPoint.X;
            scene.Context.Offset.Y += currentPoint.Y - newImageCoordForLastPoint.Y;
        }
        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();
                }
            }
        }
Exemplo n.º 10
0
 public void GenerateComponentsFiles()
 {
     foreach (ComponentDefenition component in AutosarApplication.GetInstance().ComponentDefenitionsList)
     {
         GenerateComponent(component);
     }
 }
Exemplo n.º 11
0
        public void Viewport_MouseLeftButtonDown(Point sceneCoordinates)
        {
            AutosarApplication.GetInstance().UnselectComponents();

            if (AutosarApplication.GetInstance().ActiveComposition != null)
            {
                bool clicked = AutosarApplication.GetInstance().ActiveComposition.GetClickedObject(sceneCoordinates, out SelectedObject);
                if (clicked == true)
                {
                    previousPosition = sceneCoordinates;
                    leftMouseDown    = true;
                    return;
                }

                if (AutosarApplication.GetInstance().ActiveComposition == AutosarApplication.GetInstance().Compositions.GetMainComposition())
                {
                    foreach (CompositionInstance composition in AutosarApplication.GetInstance().Compositions)
                    {
                        if (composition != AutosarApplication.GetInstance().Compositions.GetMainComposition())
                        {
                            clicked = composition.IsClicked(sceneCoordinates, out SelectedObject);
                            if (clicked == true)
                            {
                                previousPosition = sceneCoordinates;
                                leftMouseDown    = true;
                                return;
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 12
0
        public Boundary GetInternalBoundary(RenderContext context)
        {
            Boundary bound = new Boundary();

            CompositionInstance mainComposition = AutosarApplication.GetInstance().Compositions.GetMainComposition();

            if (mainComposition.Equals(this))
            {
                foreach (CompositionInstance composition in AutosarApplication.GetInstance().Compositions)
                {
                    if (composition != mainComposition)
                    {
                        bound += composition.GetBoundary(context);
                    }
                }
            }


            foreach (ComponentInstance component in ComponentInstances)
            {
                bound += component.GetBoundary(context);
            }
            foreach (PortPainter port in InternalPortsInstances)
            {
                bound += port.GetBoundary(context);
            }
            foreach (PortConnection connection in Connections)
            {
                bound += connection.GetBoundary(context);
            }
            return(bound);
        }
Exemplo n.º 13
0
        public virtual bool GetClickedObject(Point sceneCoordinates, out Object clickedObject)
        {
            if (AutosarApplication.GetInstance().ActiveComposition.Equals(this))
            {
                bool clicked = InternalPortsInstances.IsClicked(sceneCoordinates, out clickedObject);
                if (clicked == true)
                {
                    return(true);
                }

                clicked = ComponentInstances.IsClicked(sceneCoordinates, out clickedObject);
                if (clicked == true)
                {
                    return(true);
                }

                clicked = Connections.IsClicked(sceneCoordinates, out clickedObject);
                if (clicked == true)
                {
                    return(true);
                }
            }
            else
            {
                bool clicked = base.IsClicked(sceneCoordinates, out clickedObject);
                if (clicked == true)
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 14
0
        public PortsConnectionsList GetConnections()
        {
            PortsConnectionsList list = new PortsConnectionsList();

            /* Check in component instances in main composition */
            CompositionInstance mainComposition = AutosarApplication.GetInstance().Compositions.GetMainComposition();

            if (mainComposition.Equals(this))
            {
            }
            else
            {
                foreach (PortConnection connection in mainComposition.Connections)
                {
                    foreach (PortPainter port in this.Ports)
                    {
                        if (connection.Port1.GUID.Equals(port.GUID) || connection.Port2.GUID.Equals(port.GUID))
                        {
                            list.Add(connection);
                        }
                    }
                }
            }
            return(list);
        }
 public void UpdateControls()
 {
     compositoinNameTextBox.Text = composition.Name;
     compositionTab.Header       = composition.Name;
     AutosarApplication.GetInstance().ActiveComposition = composition;
     UpdatePortsGrid();
 }
Exemplo n.º 16
0
        public void GenerateConnections()
        {
            String       filename = RteFunctionsGenerator.GetRteFolder() + "\\" + Properties.Resources.RTE_CONNECTIONS_C_FILENAME;
            StreamWriter writer   = new StreamWriter(filename);

            RteFunctionsGenerator.GenerateFileTitle(writer, filename, "Implementation for RTE connections source file");

            /*Add #include */
            RteFunctionsGenerator.AddInclude(writer, "<string.h>");
            switch (AutosarApplication.GetInstance().MCUType.Type)
            {
            case MCUTypeDef.STM32F1xx:
            {
                RteFunctionsGenerator.AddInclude(writer, "<stm32f1xx.h>");
                break;
            }

            case MCUTypeDef.STM32F4xx:
            {
                RteFunctionsGenerator.AddInclude(writer, "<stm32f4xx.h>");
                break;
            }
            }
            RteFunctionsGenerator.AddInclude(writer, Properties.Resources.RTE_DATATYPES_H_FILENAME);
            RteFunctionsGenerator.AddInclude(writer, Properties.Resources.SYSTEM_ERRORS_H_FILENAME);
            RteFunctionsGenerator.AddInclude(writer, Properties.Resources.RTE_EXTERNAL_RUNNABLES_H_FILENAME);

            /* Include */
            writer.WriteLine("");

            /* Create extern variables */
            GenerateAllComponentInstances(writer);

            /* Generate all rte write functions */
            foreach (ComponentDefenition compDef in AutosarApplication.GetInstance().ComponentDefenitionsList)
            {
                writer.WriteLine("/**************************************************");
                writer.WriteLine("        " + compDef.Name);
                writer.WriteLine("***************************************************/");

                /* Check if this components exists */
                if (AutosarApplication.GetInstance().GetComponentInstanceByDefenition(compDef).Count > 0)
                {
                    if (compDef.Name == "DistanceProtector")
                    {
                    }
                    CreateRteWriteFunctions(writer, compDef);

                    CreateRteReadFunctions(writer, compDef);

                    CreateRteCallFunctions(writer, compDef);

                    CreateRtePimFunctions(writer, compDef);

                    CreateRteCDataFunctions(writer, compDef);
                }
            }

            writer.Close();
        }
        void compositionNameTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (allowUpdater.IsUpdateAllowed)
            {
                /* Do not change the name of main composition! */
                if (composition.Equals(AutosarApplication.GetInstance().Compositions.GetMainComposition()))
                {
                    return;
                }

                String newName = (sender as TextBox).Text;
                if (NameUtils.CheckComponentName(newName))
                {
                    composition.Name = newName;

                    compositionTab.Header = "Composition: " + composition.Name;

                    TreeViewItem item = tree.GetItem(composition);
                    if (item != null)
                    {
                        item.Header = composition.Name;
                    }

                    AutosarApplication.GetInstance().UpdateNamesOfConnectionLines();
                    tree.UpdateAutosarTreeView();
                }
            }
        }
Exemplo n.º 18
0
        void GenerateRteCDataFunction(StreamWriter writer, ComponentDefenition compDef, CDataDefenition cdataDef)
        {
            String returnValue = cdataDef.DataTypeName + " ";
            String RteFuncName = RteFunctionsGenerator.GenerateFullCDataFunctionName(compDef, cdataDef);

            String fieldVariable = RteFunctionsGenerator.GenerateMultipleInstanceFunctionArguments(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];
                    String            compName     = RteFunctionsGenerator.GenerateComponentName(compInstance.Name);
                    String            field        = RteFunctionsGenerator.GenerateRteCDataFieldInComponentDefenitionStruct(compDef, cdataDef);
                    writer.WriteLine("    return " + compName + "." + field + ";");
                }
            }
            else //multiple instantiation component
            {
                String field = RteFunctionsGenerator.GenerateRteCDataFieldInComponentDefenitionStruct(compDef, cdataDef);
                writer.WriteLine("    return ((" + compDef.Name + "*)instance)->" + field + ";");
            }

            writer.WriteLine("}");
            writer.WriteLine("");
        }
 void WriteAllOsTasks(StreamWriter writer)
 {
     foreach (OsTask osTask in AutosarApplication.GetInstance().OsTasks)
     {
         GenerateOsTaskFunctionCallOfRunnables(writer, osTask);
     }
 }
Exemplo n.º 20
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("");
            //}
        }
Exemplo n.º 21
0
        String GenerateComplexDatatypeDefaultValue(ComplexDataType datatype, int indent)
        {
            String strIndent = RteFunctionsGenerator.FillStringForCount("", ' ', indent);
            String str       = "{" + Environment.NewLine;

            for (int i = 0; i < datatype.Fields.Count; i++)
            {
                ComplexDataTypeField field = datatype.Fields[i];
                if (IsDatatypeSimple(field.DataTypeGUID))
                {
                    str += RteFunctionsGenerator.GenerateDefaultValueForSimpleDataTypeField(field.Name, indent + 4);
                }
                else
                {
                    ComplexDataType complexDt = AutosarApplication.GetInstance().ComplexDataTypes.FindObject(field.DataTypeGUID);
                    str += RteFunctionsGenerator.FillStringForCount("", ' ', indent + 4) + "." + field.Name + " = " + Environment.NewLine;
                    str += RteFunctionsGenerator.FillStringForCount("", ' ', indent + 4) + GenerateComplexDatatypeDefaultValue(complexDt, indent + 4);
                }
                if (i != datatype.Fields.Count - 1)
                {
                    str += "," + Environment.NewLine;
                }
            }
            str += Environment.NewLine + strIndent + "}";
            return(str);
        }
        public void LoadGuidsFromXML(XElement xml)
        {
            XElement xmlList = xml.Element("Guids");

            if (xmlList != null)
            {
                IEnumerable <XElement> elementsList = xmlList.Elements();
                foreach (XElement element in elementsList)
                {
                    XElement instanceGUID = element.Element("InstanceGuid");
                    if (instanceGUID != null)
                    {
                        Guid resultGuid;
                        if (Guid.TryParse(instanceGUID.Value, out resultGuid) == true)
                        {
                            if (!resultGuid.Equals(Guid.Empty))
                            {
                                PeriodicRunnableInstance runnableInstance = AutosarApplication.GetInstance().GetRunnableInstance(resultGuid);
                                if (runnableInstance != null)
                                {
                                    this.Add(runnableInstance);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 23
0
 void WriteAllErrors(StreamWriter writer)
 {
     AutosarApplication.GetInstance().SystemErrors.SortErrorsByID();
     foreach (SystemErrorObject obj in AutosarApplication.GetInstance().SystemErrors)
     {
         writer.WriteLine(RteFunctionsGenerator.CreateDefine(obj.Name, obj.Value.ToString()));
     }
 }
 public void WriteEnumDataTypes(StreamWriter writer)
 {
     writer.WriteLine("/* Enums data types */");
     writer.WriteLine("");
     foreach (EnumDataType datatype in AutosarApplication.GetInstance().Enums)
     {
         WriteEnumDataType(writer, datatype);
     }
 }
 public void WriteSimpleDataTypes(StreamWriter writer)
 {
     writer.WriteLine("/* Simple data types */");
     writer.WriteLine("");
     foreach (SimpleDataType datatype in AutosarApplication.GetInstance().SimpleDataTypes)
     {
         WriteSimpleDataType(writer, datatype);
     }
 }
Exemplo n.º 26
0
        public void Viewport_MouseDown(MouseButtonEventArgs e, Point sceneCursorPosition)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                /* Add Connection Line command started */
                if (this.AddConnectionLineActive == true)
                {
                    Object selectedObject = null;

                    bool clicked;


                    clicked = AutosarApplication.GetInstance().ActiveComposition.GetClickedObject(sceneCursorPosition, out selectedObject);

                    /* if we check in main composition */
                    if (!clicked)
                    {
                        CompositionInstance mainComposition = AutosarApplication.GetInstance().Compositions.GetMainComposition();
                        foreach (CompositionInstance composition in AutosarApplication.GetInstance().Compositions)
                        {
                            if (!composition.Equals(mainComposition))
                            {
                                clicked = composition.IsClicked(sceneCursorPosition, out selectedObject);
                                if (clicked == true)
                                {
                                    break;
                                }
                            }
                        }
                    }



                    if (clicked == true)
                    {
                        /* Check that PortPainter has been selected  first */
                        if (selectedObject is PortPainter)
                        {
                            firstPort                     = selectedObject as PortPainter;
                            connectionPainter             = PortConnectionFabric.GetInstance().CreatePortConnection();
                            connectionPainter.Port1       = firstPort;
                            connectionPainter.SecondPoint = sceneCursorPosition;
                            leftMouseDown                 = true;
                            return;
                        }
                        else
                        {
                            AddConnectionLineActive = false;
                        }
                    }
                    else
                    {
                        AddConnectionLineActive = false;
                    }
                }
            }
        }
        void AddOsTaskButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            String newtaskName = NameForNewTask();
            OsTask task        = OsTaskFabric.CreateOsTask(newtaskName);

            AutosarApplication.GetInstance().OsTasks.Add(task);
            int index = AutosarApplication.GetInstance().OsTasks.Count - 1;

            UpdateGrid();
        }
 void WriteInitOsTasks_FREERTOS(StreamWriter writer, RteOsInterfaceGenerator osGenerator)
 {
     writer.WriteLine("void " + InitOsFunctionName() + "(void)");
     writer.WriteLine("{");
     foreach (OsTask task in AutosarApplication.GetInstance().OsTasks)
     {
         writeInitOsTask(writer, task, osGenerator);
     }
     writer.WriteLine("}");
 }
Exemplo n.º 29
0
        public void AddRunnableButton_Click()
        {
            PeriodicRunnableDefenition runnable = ComponentFabric.GetInstance().CreateRunnableDefenition("Refresh");

            _componentDefenition.Runnables.Add(runnable);
            _componentDefenition.Runnables.DoSort();
            AutosarApplication.GetInstance().SyncronizeRunnables(_componentDefenition);
            RefreshPortsGridView();
            tree.UpdateAutosarTreeView(tree.SelectedItem);
        }
        public void CreateNewComposition()
        {
            CompositionInstance newComposition = new CompositionInstance();

            newComposition.Painter.Width  = 100;
            newComposition.Painter.Height = 100;
            newComposition.UpdateAnchorsPositions();
            newComposition.Name = FindNewNameForComposition();
            AutosarApplication.GetInstance().Compositions.Add(newComposition);
            tree.UpdateAutosarTreeView(newComposition);
        }