Exemplo n.º 1
1
        public static void Main(string[] args)
        {
            // Change the console window
            Terminal term = new Terminal();
            term.Title = "Terminal Window Title";
            term.DisplayMode = (int)ConsoleDisplayModeForSet.CONSOLE_FULLSCREEN_MODE;

            //Console.WriteLine("Terminal Title: {0}", term.Title);
            term.WriteLine("Terminal Window Title - has been set");
            COORD fontSize = term.FontSize;
            Console.WriteLine("Terminal Font Size: X = {0}, Y = {1}", fontSize.X, fontSize.Y);
            Console.WriteLine("mouse buttons: {0}", term.MouseButtons);

            // Instantiate a machine
            Machine aMachine = new Machine();

            // Print some properties
            Console.WriteLine("Name: {0}", aMachine.ShortName);
            Console.WriteLine("Domain: {0}", aMachine.DomainName);

            Environment environ = new Environment();
            Console.WriteLine("Command Line: {0}", environ.CommandLine);

            // Get the name of the process image that this process is running
            //Process aProc = new Process();
            //PrintProcess(aProc);
            //PrintAllProcesses();

            PrintAllDrives();
            //PrintVolumes();

            Console.ReadLine();
        }
Exemplo n.º 2
0
        public void Process__bubbles_processed_dive_before_saving_dive()
        {
            var accessed = 0;

            var parserMock = new Mock<IImageParser>();
            var pixels = new[] { new Pixel(2, 3), new Pixel(3, 4), new Pixel(5, 4) };
            parserMock.Setup(d => d.ReadDocument()).Returns(pixels);

            var dives = new[] { new Dive(15, 50, 23, ""), new Dive(24, 20, 33, "") };
            var dr = new Mock<IDiveRepository>();
            dr.Setup(inp => inp.LoadDives()).Returns(dives);

            var sf = new Mock<ISampleFactory>();
            var processed = new[] { new ProcessedDive(dives[0]), new ProcessedDive(dives[0]) };
            sf.Setup(inp => inp.Create(It.IsAny<IEnumerable<Pixel>>(), dives[0])).Returns(processed[0]);
            sf.Setup(inp => inp.Create(It.IsAny<IEnumerable<Pixel>>(), dives[1])).Returns(processed[1]);

            Func<DlImageParsr.Model.Dive, IImageParser> facFunc = d => { return parserMock.Object; };

            var machine = new Machine(dr.Object, sf.Object, facFunc);
            machine.BeforeSavingDive += (dive) => accessed += dive.DiveLogId;
            machine.Process();

            accessed.Should().BeGreaterOrEqualTo(25);
        }
Exemplo n.º 3
0
        public RemotingHostServer(Machine machine, int port, string name)
            : base(machine)
        {
            this.port = port;
            this.name = name;

            // TODO review this name, get machine name
            this.hostname = "localhost";

            // According to http://www.thinktecture.com/resourcearchive/net-remoting-faq/changes2003
            // in order to have ObjRef accessible from client code
            BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider();
            serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;

            BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider();

            IDictionary props = new Hashtable();
            props["port"] = port;

            TcpChannel channel = new TcpChannel(props, clientProv, serverProv);

            if (!registered)
            {
                ChannelServices.RegisterChannel(channel, false);
                registered = true;
            }

            // end of "according"

            // TODO review other options to publish an object
            this.objref = RemotingServices.Marshal(this, name);
        }
Exemplo n.º 4
0
        public object Apply(Machine machine, ValueEnvironment environment, object[] arguments)
        {
            object name = arguments[0];

            object result = machine.Evaluate(name, environment);

            Type type = null;

            if (!(result is Type))
            {
                if (name is INamed || name is string)
                    type = Utilities.GetType(name);

                if (type == null)
                    throw new ArgumentException("New should receive a type name");
            }
            else
                type = (Type)result;

            object[] parameters = new object[arguments.Length - 1];

            for (int k = 1; k < arguments.Length; k++)
                parameters[k - 1] = machine.Evaluate(arguments[k], environment);

            return Activator.CreateInstance(type, parameters);
        }
        public void TestReport()
        {
            ArrayList line = new ArrayList();
            line.Add(new Machine("mixer", "left"));

            Machine extruder = new Machine("extruder", "center");
            extruder.Put("paste");
            line.Add(extruder);

            Machine oven = new Machine("oven", "right");
            oven.Put("chips");
            line.Add(oven);

            Robot robot = new Robot();
            robot.MoveTo(extruder);
            robot.Pick();

            StringWriter writer = new StringWriter();
            RobotReport.Report(writer, line, robot);

            String expected =
                "FACTORY REPORT\n" +
                "Machine mixer\nMachine extruder\n" +
                "Machine oven bin=chips\n\n" +
                "Robot location=extruder bin=paste\n" +
                "========\n";

            Assert.That(writer.ToString(), Is.EqualTo(expected));
        }
Exemplo n.º 6
0
        public SunxiHighSpeedTimer(Machine machine, long frequency)
        {
            irqEnableRegister = new DoubleWordRegister(this);
            irqStatusRegister = new DoubleWordRegister(this);
            
            timers = new SunxiHighSpeedTimerUnit[4];
            interruptFlags = new IFlagRegisterField[4];
            enableFlags = new IFlagRegisterField[4];

            for(var i = 0; i < 4; ++i)
            {
                var j = i;
                timers[i] = new SunxiHighSpeedTimerUnit(machine, frequency);
                timers[i].LimitReached += () => OnTimerLimitReached(j);
                interruptFlags[i] = irqStatusRegister.DefineFlagField(i, FieldMode.WriteOneToClear, name: "Tx_IRQ_PEND");
                enableFlags[i] = irqEnableRegister.DefineFlagField(i, name: "Tx_INT_EN");
            }

            var innerConnections = new Dictionary<int, IGPIO>();
            for(var i = 0; i < 4; ++i)
            {
                innerConnections[i] = new GPIO();
            }
            Connections = new ReadOnlyDictionary<int, IGPIO>(innerConnections);
        }
Exemplo n.º 7
0
        public void DoIt()
        {
            var machine = new Machine(_stateFactory, _persister);

            machine.Configure(p => p
                 .Setup<StateA>(x => x.Reached5)
                 .Setup<StateA>(x => x.Reaced10)
                     .TransitionTo<StateB>()
                     .TransitionTo<StateC>());

            machine.Configure(p => p
                .Setup<StateB>(x => x.Reached15)
                .Setup<StateC>(x => x.Reached20)
                    .TransitionTo<StateD>());

            string descriptions = machine.GetDescriptions();

            var fooData = new FooData();
            fooData.Id = Guid.NewGuid();

            for (int i = 0; i < 50; i++)
            {
                machine.Process(fooData);
                App.Worker.Increase();
            }
        }
Exemplo n.º 8
0
		public void InterruptTest()
		{
    			var machine = new Machine ();
    			var efm32ggi2ccontroller = new EFM32GGI2CController (machine);
    			machine.SystemBus.Register(efm32ggi2ccontroller, new BusRangeRegistration(0x4000A000, 0x400));
    			efm32ggi2ccontroller.Reset ();

    			// Enable I2C controller
    			efm32ggi2ccontroller.WriteDoubleWord (0x0, 0x1);
    			// Enable all interrupts, bits 0-16
    			efm32ggi2ccontroller.WriteDoubleWord (0x34, 0x1FFFF);
    			// Clear all interrupts
    			efm32ggi2ccontroller.WriteDoubleWord (0x30, 0x1FFFF);
    			Assert.AreEqual (efm32ggi2ccontroller.ReadDoubleWord (0x28), 0x0);
    			// Set Start, ACK, NACK interrupt flags
    			uint interruptMask = 0x1 | 0x40 | 0x80;
    			efm32ggi2ccontroller.WriteDoubleWord (0x2C, interruptMask);
    			// Check the result on interrupt register
    			Assert.AreEqual (efm32ggi2ccontroller.ReadDoubleWord (0x28), interruptMask);
    			// Clear all interrupts
    			efm32ggi2ccontroller.WriteDoubleWord (0x30, 0x1FFFF);
    			Assert.AreEqual (efm32ggi2ccontroller.ReadDoubleWord (0x28), 0x0);
    			// Send start command and check that start interrupt is flagged
    			efm32ggi2ccontroller.WriteDoubleWord (0x4, 0x1);
    			Assert.AreEqual (efm32ggi2ccontroller.ReadDoubleWord (0x28) & 0x1, 0x1);
		}
Exemplo n.º 9
0
        public EnumerableBehavior(IBehavior behavior, IBehavior superclass, Machine machine)
            : base(behavior, superclass, machine, typeof(IEnumerable))
        {
            string dosource = @"
            do: aBlock
            | enumerator |

            enumerator := self !GetEnumerator.

            [enumerator !MoveNext] whileTrue:
            [ aBlock value: enumerator !Current ]
            ";
            string selectsource = @"
            select: aBlock
            | enumerator list |

            enumerator := self !GetEnumerator.
            list := @System.Collections.ArrayList !new.

            [enumerator !MoveNext] whileTrue:
            [ | item |
              item := enumerator !Current.
            (aBlock value: item) ifTrue:  [ list add: item ]
            ].
            ^list
            ";

            Parser parser = new Parser(dosource);
            this.DefineInstanceMethod(parser.CompileInstanceMethod(this));
            parser = new Parser(selectsource);
            this.DefineInstanceMethod(parser.CompileInstanceMethod(this));
            this.DefineInstanceMethod(new FunctionalMethod("includes:", this, this.IncludesMethod));
        }
Exemplo n.º 10
0
        public void CreateNotCurrentMachine()
        {
            Machine machine = new Machine(false);

            Assert.IsTrue(machine != Machine.Current);
            Assert.IsNotNull(machine.Environment);
        }
Exemplo n.º 11
0
 public TegraTimer(Machine machine)
 {
     IRQ = new GPIO();
     sync = new object();
     clockSource = machine.ObtainClockSource();
     Reset();
 }
Exemplo n.º 12
0
 public NS16550(Machine machine, bool wideRegisters = false)
 {
     this.machine = machine;
     mode32 = wideRegisters;
     IRQ = new GPIO();
     Reset();
 }
Exemplo n.º 13
0
 protected override object Evaluate(string text, Machine machine)
 {
     Parser parser = new Parser(text);
     Block block = parser.CompileBlock();
     Process process = new Process(block, null, machine);
     return process.Execute();
 }
Exemplo n.º 14
0
 public FT5336(Machine machine, bool isRotated = false)
 {
     this.machine = machine;
     this.isRotated = isRotated;
     IRQ = new GPIO();
     Reset();
 }
Exemplo n.º 15
0
        public CadenceUart(Machine machine)
        {
            this.machine = machine;
		    buffer = new Queue<byte>();
		    Reset();
            IRQ = new GPIO();
        }
Exemplo n.º 16
0
 public Host(Machine machine)
 {
     this.machine = machine;
     this.machine.Host = this;
     if (Machine.Current != null)
         Machine.Current.RegisterHost(this);
 }
Exemplo n.º 17
0
		public void InitTest()
		{
			    var machine = new Machine ();
			    var efm32ggi2ccontroller = new EFM32GGI2CController (machine);
			    machine.SystemBus.Register(efm32ggi2ccontroller, new BusRangeRegistration(0x4000A000, 0x400));
			    efm32ggi2ccontroller.Reset ();
                Assert.AreEqual (efm32ggi2ccontroller.ReadDoubleWord (0x00), 0);
                // Enable I2C controller
                efm32ggi2ccontroller.WriteDoubleWord (0x0, 0x1);
                Assert.AreEqual (efm32ggi2ccontroller.ReadDoubleWord (0x00), 0x1);
                // Need check reset of interrupt flags before reading rx data (0x1C)
                // as this will trigger RXUF if enabled
                Assert.AreEqual (efm32ggi2ccontroller.ReadDoubleWord (0x28), 0);
                // Check I2Cn_IEN before enabling interrupts
                Assert.AreEqual (efm32ggi2ccontroller.ReadDoubleWord (0x34), 0);
                // Enable all interrupts, bits 0-16
                efm32ggi2ccontroller.WriteDoubleWord (0x34, 0x1FFFF);
                Assert.AreEqual (efm32ggi2ccontroller.ReadDoubleWord (0x08), 0);
                Assert.AreEqual (efm32ggi2ccontroller.ReadDoubleWord (0x0C), 0);
                Assert.AreEqual (efm32ggi2ccontroller.ReadDoubleWord (0x10), 0);
                Assert.AreEqual (efm32ggi2ccontroller.ReadDoubleWord (0x14), 0);
                Assert.AreEqual (efm32ggi2ccontroller.ReadDoubleWord (0x18), 0);
                Assert.AreEqual (efm32ggi2ccontroller.ReadDoubleWord (0x1C), 0);
                Assert.AreEqual (efm32ggi2ccontroller.ReadDoubleWord (0x20), 0);
                // IF - RXUF
                Assert.AreEqual (efm32ggi2ccontroller.ReadDoubleWord (0x28), 0x2000);
                Assert.AreEqual (efm32ggi2ccontroller.ReadDoubleWord (0x34), 0x1FFFF);
                Assert.AreEqual (efm32ggi2ccontroller.ReadDoubleWord (0x38), 0);
		}
Exemplo n.º 18
0
 public LEUART(Machine machine)
 {
     this.machine = machine;
     queueLock = new object();
     IRQ = new GPIO();
     Reset();
 }
Exemplo n.º 19
0
        public object Apply(Machine machine, ValueEnvironment environment, object[] arguments)
        {
            object result = null;
            ValueEnvironment newenv = null;

            foreach (object argument in arguments)
            {
                if (newenv == null)
                {
                    newenv = new ValueEnvironment(environment);

                    if (argument != null)
                    {
                        if (!(argument is ICollection))
                            throw new InvalidOperationException("Let must receive a list as first argument");

                        Utilities.EvaluateBindings(machine, newenv, (ICollection)argument);
                    }
                }
                else
                    result = machine.Evaluate(argument, newenv);
            }

            return result;
        }
Exemplo n.º 20
0
 public ExecutionContext(Machine machine, IObject self, Block block, object[] arguments)
     : this(block, arguments)
 {
     // this.self = receiver; // TODO review
     this.machine = machine;
     this.self = self;
 }
Exemplo n.º 21
0
        public void Execute(Machine machine, Stack<object> stack, Scope scope, Instruction instr)
        {
            int length;
            string name;

            switch (instr)
            {
                default:
                    throw new VMException("Something just went horribly wrong. Variable instructlet is not supposed to receive {0}", instr.ToString());

                case Instruction.SetVar:
                    length = (int)machine.TakeByte();
                    name = machine.TakeBytes(length).AsString();

                    machine.ExecuteNextInstructlet();
                    scope.SetVariable(name, stack.Pop());
                    break;

                case Instruction.GetVar:
                    length = (int)machine.TakeByte();
                    name = machine.TakeBytes((int)length).AsString();

                    stack.Push(scope.GetVariable(name));
                    break;
            }
        }
Exemplo n.º 22
0
 public void Run(ICommandInteraction writer, [Values("set", "add", "rem")] LiteralToken action, StringToken name)
 {
     switch(action.Value)
     {
     case "add":       
         var machine = new Machine();
         EmulationManager.Instance.CurrentEmulation.AddMachine(machine, name.Value);
         if(GetCurrentMachine() == null)
         {
             SetCurrentMachine(machine);
         }
         break;
     case "set":
         try
         {
             SetCurrentMachine(EmulationManager.Instance.CurrentEmulation[name.Value]);
         }
         catch(KeyNotFoundException)
         {
             writer.WriteError(string.Format("Machine {0} not found.", name.Value));
         }
         break;
     case "rem":
         var machineToRemove = EmulationManager.Instance.CurrentEmulation[name.Value];
         EmulationManager.Instance.CurrentEmulation.RemoveMachine(name.Value);
         if(GetCurrentMachine() == machineToRemove)
         {
             SetCurrentMachine(null);
         }
         break;
     }
 }
Exemplo n.º 23
0
        public GaislerMIC(Machine machine, uint totalNumberCPUs = 1)
        {
            this.numberOfProcessors = totalNumberCPUs;
            if(totalNumberCPUs > maxNumberOfProcessors)
            {
                this.Log(LogLevel.Warning, "Registration with unsupported  number of CPUs, defaulting to maximum {0:X]", maxNumberOfProcessors);
                this.numberOfProcessors = maxNumberOfProcessors;
            }
            registers = new deviceRegisters();
            registers.MultiprocessorStatus |= (((numberOfProcessors-1) << 28) & 0xF0000000);
            // Set Broadcast Available bit in MultiprocessorStatus register if ncpu > 1
            if(this.numberOfProcessors > 1)
            {
                registers.MultiprocessorStatus |= (1u << 27);
            }
            irqs = new GPIO[numberOfProcessors];
            resets = new GPIO[numberOfProcessors];
            runs = new GPIO[numberOfProcessors];
            set_nmi_interrupt = new bool[numberOfProcessors];
            for(var i = 0; i < numberOfProcessors; i++)
            {
                irqs[i] = new GPIO();
                resets[i] = new GPIO();
                runs[i] = new GPIO();
                interrupts[i] = new Dictionary<int, int>();
                set_nmi_interrupt[i] = false;
            }

            Connections = new IGPIORedirector((int)numberOfProcessors, HandleIRQConnect);
            Reset();
        }
Exemplo n.º 24
0
        public object Apply(Machine machine, ValueEnvironment environment, object[] arguments)
        {
            ICollection argumentNames;
            IExpression body;

            if (arguments[0] is Symbol)
            {
                if (arguments.Length > 1 && arguments[1] != null && !(arguments[1] is IPersistentVector))
                    return this.ApplyMultiFunction(machine, environment, arguments);

                Symbol symbol = (Symbol)arguments[0];
                argumentNames = (ICollection)arguments[1];
                this.CheckArgumentNames(argumentNames);
                body = Utilities.ToExpression(arguments[2]);

                return new DefinedFunction(symbol.Name, argumentNames, body);
            }

            if (arguments.Length > 1 && arguments[0] != null && !(arguments[0] is IPersistentVector))
                return this.ApplyMultiFunction(machine, environment, arguments);

            argumentNames = (ICollection)arguments[0];
            this.CheckArgumentNames(argumentNames);
            body = Utilities.ToExpression(arguments[1]);

            return new DefinedFunction(null, argumentNames, body);
        }
Exemplo n.º 25
0
 public STM32_UART(Machine machine)
 {
     this.machine = machine;
     IRQ = new GPIO();
     charFifo = new Queue<byte>();
     Reset();
 }
Exemplo n.º 26
0
 public Host()
 {
     this.machine = new Machine(false);
     this.machine.Host = this;
     if (Machine.Current != null)
         Machine.Current.RegisterHost(this);
 }
Exemplo n.º 27
0
 public void Setup()
 {
     this.machine = new Machine();
     this.manager = new TransactionManager(this.machine);
     this.obj = new BaseObject(null, new object[] { 1, 2, 3 });
     this.trobj = new TransactionalObject(this.obj, new TransactionManager(this.machine));
 }
Exemplo n.º 28
0
 public STM32F4GPIOPort(Machine machine, uint modeResetValue = 0, uint outputSpeedResetValue = 0, uint pullUpPullDownResetValue = 0) : base(machine, 16)
 {
     this.modeResetValue = modeResetValue;
     this.outputSpeedResetValue = outputSpeedResetValue;
     this.pullUpPullDownResetValue = pullUpPullDownResetValue;
     Reset();
 }
Exemplo n.º 29
0
        public void Execute(Machine machine, Stack<object> stack, Scope scope, Instruction instr)
        {
            int length = (int)machine.TakeByte();
            string name = machine.TakeBytes(length * sizeof(char)).AsString();

            scope.GetFunction(name).Call(machine);
        }
Exemplo n.º 30
0
 public SynopsysEthernetMAC(Machine machine) : base(machine)
 {
     MAC = EmulationManager.Instance.CurrentEmulation.MACRepository.GenerateUniqueMAC();
     IRQ = new GPIO();
     Link = new NetworkLink(this);
     Reset();
 }