Ejemplo n.º 1
0
		public void Read (BinaryReader reader) 
		{
			machine = (MachineId) reader.ReadUInt16 ();
			sections = reader.ReadInt16 ();
			tdStampRaw = reader.ReadUInt32 ();
			symTabPtr = reader.ReadUInt32 ();
			numSymbols = reader.ReadUInt32 ();
			optHeaderSize = reader.ReadInt16 ();
			characteristics = (Characteristics) reader.ReadUInt16 ();	
		}
Ejemplo n.º 2
0
 void EntryInit()
 {
     l = new List<int>();
     l.Insert(0, 12);
     l.Insert(0, 23);
     l.Insert(0, 12);
     l.Insert(0, 23);
     l.Insert(0, 12);
     l.Insert(0, 23);
     mac = this.CreateMachine(typeof(Tester));
     this.Send(mac, new Config(l, 1));
     this.Send(mac, new SeqPayload(l));
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Инициализирует новый проект с указанными начальными параметрами.
        /// </summary>
        /// <param name="name">Название проекта.</param>
        /// <param name="machine">Тип абстрактного вычислителя, под который создается проект.</param>
        /// <param name="directory">Путь к директории проекта.</param>
        public AbstractProject(string name, MachineId machine, string directory)
        {
            if (name == null)
                throw new ArgumentNullException("Название проекта не может быть неопределенным");
            if(!Enum.IsDefined(typeof(MachineId), machine))
                throw new ArgumentException("Указанный тип не существует");
            if (!CheckName(name))
                throw new ArgumentException("Название проекта некорректно. Название может содержать латинские буквы и десятичные цифры");
            if (string.IsNullOrEmpty(directory))
                throw new ArgumentException("Путь к файлу проекта имеет неверный формат");

            _name = name;
            _machineId = machine;
            _files = new List<string>();
            _directory = directory;
        }
Ejemplo n.º 4
0
 public E(MachineId id)
 {
     this.Id = id;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Constructor.
 /// </summary>
 protected BaseMachine()
 {
     this.Id = new MachineId(this.GetType());
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates a bug trace step.
        /// </summary>
        /// <param name="index">Index</param>
        /// <param name="type">BugTraceStepType</param>
        /// <param name="machine">Machine</param>
        /// <param name="machineState">MachineState</param>
        /// <param name="eventInfo">EventInfo</param>
        /// <param name="action">MethodInfo</param>
        /// <param name="targetMachine">Target machine</param>
        /// <param name="boolChoice">Boolean choice</param>
        /// <param name="intChoice">Integer choice</param>
        /// <param name="extraInfo">Extra info</param>
        /// <returns>BugTraceStep</returns>
        internal static BugTraceStep Create(int index, BugTraceStepType type, MachineId machine,
            string machineState, EventInfo eventInfo, MethodInfo action, MachineId targetMachine,
            bool? boolChoice, int? intChoice, string extraInfo)
        {
            var traceStep = new BugTraceStep();

            traceStep.Index = index;
            traceStep.Type = type;

            traceStep.Machine = machine;
            traceStep.MachineState = machineState;

            traceStep.EventInfo = eventInfo;

            if (action != null)
            {
                traceStep.InvokedAction = action.Name;
            }

            traceStep.TargetMachine = targetMachine;
            traceStep.RandomBooleanChoice = boolChoice;
            traceStep.RandomIntegerChoice = intChoice;
            traceStep.ExtraInfo = extraInfo;

            traceStep.Previous = null;
            traceStep.Next = null;

            return traceStep;
        }
Ejemplo n.º 7
0
 void EntryInit()
 {
     TravelAgentMachine = this.CreateMachine(typeof(TravelAgent));
     this.Send(TravelAgentMachine, new Config(this.Id));
     CityCabMachine = this.CreateMachine(typeof(CityCab));
     this.Send(CityCabMachine, new Config(this.Id));
     RemoteCheckIn = false;
     this.Raise(new Unit());
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Creates a send action info.
        /// </summary>
        /// <param name="index">Index</param>
        /// <param name="mid">MachineId</param>
        /// <param name="targetMachineId">Target MachineId</param>
        /// <param name="e">Event</param>
        /// <param name="sendId">Send id</param>
        /// <returns>MachineActionInfo</returns>
        internal static MachineActionInfo CreateSendActionInfo(int index, MachineId mid,
            MachineId targetMachineId, Event e, int sendId)
        {
            var actionInfo = new MachineActionInfo();

            actionInfo.Index = index;
            actionInfo.Type = MachineActionType.SendAction;

            actionInfo.MachineId = mid.Value;
            actionInfo.TargetMachineId = targetMachineId.Value;
            actionInfo.EventName = e.GetType().FullName;
            actionInfo.EventId = e.GetHashCode();
            actionInfo.SendId = sendId;

            actionInfo.Previous = null;
            actionInfo.Next = null;

            return actionInfo;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Создает новый проект с указанным названием и типом абстрактной машины.
        /// </summary>
        /// <param name="name">Название создаваемого проекта.</param>
        /// <param name="machine">Тип абстрактной машины, под который создается проект.</param>
        /// <param name="settings">Начальные установки визуализатора.</param>
        /// <returns>Созданный проект.</returns>
        private AbstractProject CreateProject(string name, MachineId machine, Dictionary<string, bool> settings = null)
        {
            string fileName = nameBox.Text;
            string folder = newFolderBox.Checked ? Path.Combine(_folderDialog.SelectedPath, fileName) : _folderDialog.SelectedPath;

            AbstractProject result = new AbstractProject(name, machine, folder);
            result.VisualizerSettings = settings;

            return result;
        }
Ejemplo n.º 10
0
 public E(MachineId a)
 {
     this.A = a;
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Sets the id of this machine.
 /// </summary>
 /// <param name="mid">MachineId</param>
 internal void SetMachineId(MachineId mid)
 {
     this.Id = mid;
     this.Runtime = mid.Runtime;
 }
Ejemplo n.º 12
0
 public ConfigureEvent(MachineId id)
     : base()
 {
     this.Target = id;
 }
Ejemplo n.º 13
0
 void Configure()
 {
     this.Target = (this.ReceivedEvent as ConfigureEvent).Target;
     this.Raise(new StartTimerEvent());
 }
Ejemplo n.º 14
0
 void Configure()
 {
     this.Server  = (this.ReceivedEvent as Config).Id;
     this.Counter = 0;
     this.Raise(new Unit());
 }
Ejemplo n.º 15
0
 void InitOnEntry()
 {
     this.Client = this.CreateMachine(typeof(Client));
     this.Send(this.Client, new Config(this.Id));
     this.Raise(new Unit());
 }
Ejemplo n.º 16
0
 void Configure()
 {
     this.Target = (this.ReceivedEvent as Config).Target;
     this.Raise(new Unit());
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Sends an event to a remote machine.
 /// </summary>
 /// <param name="target">Target machine id</param>
 /// <param name="e">Event</param>
 void INetworkProvider.RemoteSend(MachineId target, Event e)
 {
     this.Channel.SendEvent(target, e);
 }
Ejemplo n.º 18
0
 void SOnEntry()
 {
     this.N = this.CreateMachine(typeof(N));
     this.Send(this.N, new E(this.Id));
     this.Raise(new Unit());
 }
Ejemplo n.º 19
0
 void Configure()
 {
     this.Master = (this.ReceivedEvent as Config).Id;
     this.Raise(new Unit());
 }
Ejemplo n.º 20
0
 void Configure()
 {
     RealMachine = (this.ReceivedEvent as Config).Id;
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Sends an asynchronous event to a machine.
 /// </summary>
 /// <param name="target">Target machine id</param>
 /// <param name="e">Event</param>
 void IRemoteCommunication.SendEvent(MachineId target, Event e)
 {
     Output.Print("Received sent event {0}", e.GetType());
     PSharpRuntime.SendEvent(target, e);
 }
Ejemplo n.º 22
0
 public Config(MachineId id) : base(-1, -1)
 {
     this.Id = id;
 }
Ejemplo n.º 23
0
 void SOnEntry()
 {
     this.N = this.CreateMachine(typeof(N));
     this.Send(this.N, new E(this.Id));
     this.Raise(new Unit());
 }
Ejemplo n.º 24
0
 void EntryInit()
 {
     GhostMachine = this.CreateMachine(typeof(Ghost));
     this.Send(GhostMachine, new Config(this.Id));
     this.Raise(new Unit());
 }
Ejemplo n.º 25
0
 public Config(MachineId id)
     : base()
 {
     this.Target = id;
 }
Ejemplo n.º 26
0
 public static void Send(PSharpRuntime runtime, MachineId target)
 {
     runtime.SendEvent(target, new E(2));
 }
Ejemplo n.º 27
0
 void EntryInit()
 {
     GhostMachine = this.CreateMachine(typeof(GhostMachine));
     this.Send(GhostMachine, new Config(this.Id));
     this.Raise(new Unit());
 }
Ejemplo n.º 28
0
 public Config(MachineId server)
 {
     this.Server = server;
 }
Ejemplo n.º 29
0
 public Ping(MachineId id)
     : base(1, -1)
 {
     this.Id = id;
 }
Ejemplo n.º 30
0
 public Ping(MachineId client)
 {
     this.Client = client;
 }
Ejemplo n.º 31
0
        /// <summary>
        /// Получает краткое название машины по ее идентификатору.
        /// </summary>
        /// <param name="id">Идентификатор машины.</param>
        /// <returns>Название машины.</returns>
        private string GetMachineShortName(MachineId id)
        {
            switch(id)
            {
                case MachineId.Post: return "МП";
                case MachineId.Turing: return "МТ";
                case MachineId.Register: return  "МБР";
            }

            return "???";
        }
Ejemplo n.º 32
0
 internal virtual void Initialize(MachineId machineId, AppMachineInitializePayload payload)
 {
     this.machineId  = machineId;
     peekProxy       = payload.peekProxy;
     annotationProxy = payload.annotationProxy;
 }
Ejemplo n.º 33
0
 public void Deserialize(Stream stream)
 {
     StreamHelper.Read(stream, out Magic);
     StreamHelper.Read(stream, out MajorVersion);
     StreamHelper.Read(stream, out MinorVersion);
     byte mId;
     StreamHelper.Read(stream, out mId);
     MachineId = (MachineId)mId;
     StreamHelper.Read(stream, out Flags);
 }
Ejemplo n.º 34
0
 internal override void Initialize(MachineId machineId, AppMachineInitializePayload payload)
 {
     base.Initialize(machineId, payload);
     migratingTable = new MasterMigratingTable(payload.configService, payload.oldTable, payload.newTable,
                                               new ChainTableMonitor(this), MigrationModel.GetEnabledBug());
 }
Ejemplo n.º 35
0
 /// <summary>
 /// Sends an asynchronous event to a machine.
 /// </summary>
 /// <param name="target">Target machine id</param>
 /// <param name="e">Event</param>
 void IRemoteCommunication.SendEvent(MachineId target, Event e)
 {
     this.Runtime.Log("<RemoteLog> Received remotely sent event {0}", e.GetType());
     this.Runtime.SendEvent(target, e);
 }
Ejemplo n.º 36
0
 public ReplyTarget(object replyId, MachineId machineId)
 {
     this.replyId   = replyId;
     this.machineId = machineId;
     tcs            = new TaskCompletionSource <TResult>(TaskCreationOptions.RunContinuationsAsynchronously);
 }
Ejemplo n.º 37
0
 /// <summary>
 /// Sends an asynchronous event to a machine.
 /// </summary>
 /// <param name="target">Target machine id</param>
 /// <param name="e">Event</param>
 void INetworkProvider.RemoteSend(MachineId target, Event e)
 {
     this.Runtime.SendEvent(target, e);
 }
Ejemplo n.º 38
0
 public Config(List <MachineId> servers, MachineId parentServer, int myRank)
 {
     this.Servers      = servers;
     this.ParentServer = parentServer;
     this.MyRank       = myRank;
 }
Ejemplo n.º 39
0
 private void Configure()
 {
     this.Master = (this.ReceivedEvent as Config).Id;
     this.Raise(new Unit());
 }
Ejemplo n.º 40
0
 public Ping(MachineId leaderElection, int rank)
 {
     this.LeaderElection = leaderElection;
     this.Rank           = rank;
 }
Ejemplo n.º 41
0
        /// <summary>
        /// Creates an invocation action info.
        /// </summary>
        /// <param name="index">Index</param>
        /// <param name="mid">MachineId</param>
        /// <param name="actionName">Action name</param>
        /// <param name="actionId">Action id</param>
        /// <returns>MachineActionInfo</returns>
        internal static MachineActionInfo CreateInvocationActionInfo(int index, MachineId mid,
            string actionName, int actionId)
        {
            var actionInfo = new MachineActionInfo();

            actionInfo.Index = index;
            actionInfo.Type = MachineActionType.InvocationAction;

            actionInfo.MachineId = mid.Value;
            actionInfo.ActionName = actionName;
            actionInfo.ActionId = actionId;

            actionInfo.Previous = null;
            actionInfo.Next = null;

            return actionInfo;
        }
Ejemplo n.º 42
0
 public NewLeader(MachineId leader, int rank)
 {
     this.CurrentLeader = leader;
     this.Rank          = rank;
 }
Ejemplo n.º 43
0
 void EntryInit()
 {
     mac = this.CreateMachine(typeof(Real2));
     this.Raise(new E1());
 }
Ejemplo n.º 44
0
 void InitOnEntry()
 {
     this.Client = this.CreateMachine(typeof(Client));
     this.Send(this.Client, new Config(this.Id));
     this.Raise(new Unit());
 }
Ejemplo n.º 45
0
 public E(MachineId a)
 {
     this.A = a;
 }
Ejemplo n.º 46
0
 void ExitInit()
 {
     GhostMachine = this.CreateMachine(typeof(Ghost));
     this.Send(GhostMachine, new Config(this.Id));
 }
Ejemplo n.º 47
0
 public Ping(MachineId sender)
     : base()
 {
     this.Sender = sender;
 }
Ejemplo n.º 48
0
 public Config(MachineId id)
 {
     this.Id = id;
 }
Ejemplo n.º 49
0
 void Configure()
 {
     this.Server = (this.ReceivedEvent as Config).Id;
     this.Counter = 0;
     this.Raise(new Unit());
 }
Ejemplo n.º 50
0
 public Pong(MachineId node)
     : base()
 {
     this.Node = node;
 }
Ejemplo n.º 51
0
 public static void Send(PSharpRuntime runtime, MachineId target)
 {
     runtime.SendEvent(target, new E1(2));
 }
Ejemplo n.º 52
0
        void InitOnEntry()
        {
            this.Servers = new List <MachineId>();
            this.Clients = new List <MachineId>();

            this.NumOfServers = 3;

            for (int i = 0; i < this.NumOfServers; i++)
            {
                MachineId server = null;

                if (i == 0)
                {
                    server = this.CreateMachine(typeof(ChainReplicationServer),
                                                new ChainReplicationServer.Config(i, true, false));
                }
                else if (i == this.NumOfServers - 1)
                {
                    server = this.CreateMachine(typeof(ChainReplicationServer),
                                                new ChainReplicationServer.Config(i, false, true));
                }
                else
                {
                    server = this.CreateMachine(typeof(ChainReplicationServer),
                                                new ChainReplicationServer.Config(i, false, false));
                }

                this.Servers.Add(server);
            }

            this.Monitor <InvariantMonitor>(
                new InvariantMonitor.Config(this.Servers));
            this.Monitor <ServerResponseSeqMonitor>(
                new ServerResponseSeqMonitor.Config(this.Servers));

            for (int i = 0; i < this.NumOfServers; i++)
            {
                MachineId pred = null;
                MachineId succ = null;

                if (i > 0)
                {
                    pred = this.Servers[i - 1];
                }
                else
                {
                    pred = this.Servers[0];
                }

                if (i < this.NumOfServers - 1)
                {
                    succ = this.Servers[i + 1];
                }
                else
                {
                    succ = this.Servers[this.NumOfServers - 1];
                }

                this.Send(this.Servers[i], new ChainReplicationServer.PredSucc(pred, succ));
            }

            this.Clients.Add(this.CreateMachine(typeof(Client),
                                                new Client.Config(0, this.Servers[0], this.Servers[this.NumOfServers - 1], 1)));

            this.Clients.Add(this.CreateMachine(typeof(Client),
                                                new Client.Config(1, this.Servers[0], this.Servers[this.NumOfServers - 1], 100)));

            this.ChainReplicationMaster = this.CreateMachine(typeof(ChainReplicationMaster),
                                                             new ChainReplicationMaster.Config(this.Servers, this.Clients));

            this.Raise(new Halt());
        }
Ejemplo n.º 53
0
 void Configure()
 {
     RealMachine = (this.ReceivedEvent as Config).Id;
 }
 public ReminderCancellationSource(MachineId actor, MachineId reminder)
 {
     this.Actor    = actor;
     this.Reminder = reminder;
 }
Ejemplo n.º 55
0
 public Config(MachineId id)
     : base(-1, -1)
 {
     this.Id = id;
 }
Ejemplo n.º 56
0
        /// <summary>
        /// Gets result from the given machine.
        /// </summary>
        /// <param name="runtime">The P# runtime.</param>
        /// <param name="mid">Machine to get response from.</param>
        static async Task GetDataAndPrint(PSharpRuntime runtime, MachineId mid)
        {
            var resp = await GetReponseMachine <M1.Response> .GetResponse(runtime, mid, m => new M1.Get(m));

            Console.WriteLine("Got response: {0}", resp.v);
        }
Ejemplo n.º 57
0
 void Configure()
 {
     EmployeeMachine = (this.ReceivedEvent as Config).Id;
     this.Raise(new Unit());
 }
Ejemplo n.º 58
0
 public Get(MachineId mid)
 {
     this.Mid = mid;
 }
Ejemplo n.º 59
0
 void EntryInit()
 {
     PongId = this.CreateMachine(typeof(PONG));
     this.Raise(new Success());
 }
Ejemplo n.º 60
0
 public I_ReliableStorageMachine(MachineId machine, List <string> permissions) : base(machine, permissions)
 {
 }