Example #1
0
    void CreateSimulation(SimulationType type, int count)
    {
        if (m_simulation != null)
        {
            m_simulation.Shutdown();
            m_simulation = null;
        }

        if (type == SimulationType.Native)
        {
            m_simulation = new NativeSimulation();
        }
        else if (type == SimulationType.Managed)
        {
            m_simulation = new ManagedSimulation();
        }
        else if (type == SimulationType.Pain)
        {
            m_simulation = new ManagedPainSimulation();
        }
        else
        {
            m_simulation = new UnsafeManagedSimulation();
        }

        m_simulation.Init(count);
        RecreateViews(count);
        m_simulation.UpdateViews(Views);

        foreach (var view in Views)
        {
            view.GetComponent <TrailRenderer>().Clear();
        }

        m_workTime       = 0.0;
        m_simulationTime = 0.0;
        m_steps          = 0;
        m_count          = count;
    }
Example #2
0
 public void Init()
 {
     Simulation.Init();
     Print($"Init()");
 }
Example #3
0
        // This gets called from Logik::Program.Main
        public static void InitUI(ISimulation sim, IComponentGraphics[] comps)
        {
            Console.ResetColor();
            Simulation = sim;
            if (LogSimulationCommunication)
            {
                Simulation = new LoggingSimulation(Simulation);
            }
            Simulation.Init();

            CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;

            Value a = new Value(0b00_00_00_00_01_01_01_01_10_10_10_10_11_11_11_11, 16);
            Value b = new Value(0b00_01_10_11_00_01_10_11_00_01_10_11_00_01_10_11, 16);

            Console.WriteLine($"Resolve: {Value.Resolve(a, b)}");
            Console.WriteLine($"And: {Value.And(a, b)}");
            Console.WriteLine($"Or: {Value.Or(a, b)}");
            Console.WriteLine($"Not: {Value.Not(a)}");

            Application.Init();

            GLib.ExceptionManager.UnhandledException += ExceptionManager_UnhandledException;

            Window wnd = new Window("Logik");

            wnd.Resize(1600, 800);

            Notebook nbook         = new Notebook();
            var      circuitEditor = new CircuitEditor();

            circuitEditor.Scene.Gates.Components = comps.ToDictionary(kvp => kvp.Type);
            nbook.AppendPage(circuitEditor.DrawingArea, new Label("Circuit editor"));
            nbook.AppendPage(new Label("TODO: Package editor"), new Label("Package editor"));

            Notebook sideBar    = new Notebook();
            var      components = new ComponentView(new List <ComponentFolder> {
                new ComponentFolder("Test folder 1", new List <Component.Component>()
                {
                    new Component.Component("Test comp 1", "x-office-document"),
                    new Component.Component("Test comp 2", "x-office-document"),
                    new Component.Component("Test comp 3", "x-office-document"),
                }),
                new ComponentFolder("Test folder 2", new List <Component.Component>()
                {
                    new Component.Component("Another test comp 1", "x-office-document"),
                    new Component.Component("Another test comp 2", "x-office-document"),
                    new Component.Component("Another test comp 3", "x-office-document"),
                }),
            });

            sideBar.AppendPage(components.TreeView, new Label("Components"));
            var hierarchy = new HierarchyView(new HierarchyComponent("Top comp", "x-office-document", new List <HierarchyComponent>()
            {
                new HierarchyComponent("Test Comp 1", "x-office-document", new List <HierarchyComponent>()
                {
                    new HierarchyComponent("Test Nested Comp 1", "x-office-document", new List <HierarchyComponent>()),
                }),
                new HierarchyComponent("Test Comp 2", "x-office-document", new List <HierarchyComponent>()
                {
                    new HierarchyComponent("Test Nested Comp 1", "x-office-document", new List <HierarchyComponent>()),
                    new HierarchyComponent("Test Nested Comp 2", "x-office-document", new List <HierarchyComponent>()),
                }),
                new HierarchyComponent("Test Comp 3", "x-office-document", new List <HierarchyComponent>()),
            }));

            sideBar.AppendPage(hierarchy.TreeView, new Label("Hierarchy"));

            HPaned hPaned = new HPaned();

            hPaned.Pack1(sideBar, false, false);
            hPaned.Pack2(nbook, true, false);

            //Add the label to the form
            VBox box = new VBox(false, 0);

            box.PackStart(CreateMenuBar(wnd, circuitEditor), false, false, 0);
            box.PackStart(CreateToolbar(circuitEditor), false, false, 0);
            box.PackEnd(hPaned, true, true, 0);
            box.Expand = true;
            wnd.Add(box);

            wnd.Destroyed += Wnd_Destroyed;

            wnd.ShowAll();
            Application.Run();
        }