public void generate_schedule(object sender, EventArgs e) { if (Models.EngineManagerModel.instance != null && Models.EngineManagerModel.instance.IsConnected) { //get the schedule schedule = Barrista.getInstance().Schedule_Generate(); if (OnRefresh != null) OnRefresh(sender, e); //generate system -> time collection float totalTime = 0; PerfTimeData.Clear(); OperationList.OperationListEnumerator en = schedule.GetEnumerator(); while (en.MoveNext()) { float timesample = (float)en.Current.samples_sum / (float)en.Current.samples_num; PerfData p = new PerfData(){ AvgRunTime = timesample, SystemName = en.Current.name }; PerfTimeData.Add(p); totalTime += timesample; } //generate fps statusText = ""; statusText += "Total Frametime: " + (totalTime / 1000.0f).ToString(); statusText += "\t\tFPS: " + ((1.0f/(totalTime / 10000.0f))*100.0f).ToString(); PropertyChanged(this, new PropertyChangedEventArgs("statusText")); } }
private State BuildGraph(string name, OperationList operations, ICollection<State> allStates) { var entryState = new State(name, true, Enumerable.Empty<Parameter>()); allStates.Add(entryState); var previousStates = new List<State> { entryState }; foreach (var operation in operations) { BuildGraph(previousStates, operation, allStates); } return entryState; }
public void List() { moq::Mock <GlobalOperations.GlobalOperationsClient> mockGrpcClient = new moq::Mock <GlobalOperations.GlobalOperationsClient>(moq::MockBehavior.Strict); ListGlobalOperationsRequest request = new ListGlobalOperationsRequest { Project = "projectaa6ff846", }; OperationList expectedResponse = new OperationList { Id = "id74b70bb8", Kind = "kindf7aa39d9", Warning = new Warning(), NextPageToken = "next_page_tokendbee0940", Items = { new Operation(), }, SelfLink = "self_link7e87f12d", }; mockGrpcClient.Setup(x => x.List(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); GlobalOperationsClient client = new GlobalOperationsClientImpl(mockGrpcClient.Object, null); OperationList response = client.List(request.Project); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public OperationList FindCandidateOperations() { OperationList selectedOperations = new OperationList(); return(selectedOperations); }
/// <exception cref="InvalidOperationException"> /// The type does not support the given kind of member. /// </exception> public void InsertMember(MemberType type, int index) { if (type == MemberType.Field) { if (index > FieldCount) { index = FieldCount; } } else { index -= FieldCount; if (index > OperationCount) { index = OperationCount; } } if (index < 0) { index = 0; } switch (type) { case MemberType.Field: Field field = AddField(); FieldList.RemoveAt(FieldCount - 1); FieldList.Insert(index, field); break; case MemberType.Method: Method method = AddMethod(); OperationList.RemoveAt(OperationCount - 1); OperationList.Insert(index, method); break; case MemberType.Constructor: Constructor constructor = AddConstructor(); OperationList.RemoveAt(OperationCount - 1); OperationList.Insert(index, constructor); break; case MemberType.Destructor: Destructor destructor = AddDestructor(); OperationList.RemoveAt(OperationCount - 1); OperationList.Insert(index, destructor); break; case MemberType.Property: Property property = AddProperty(); OperationList.RemoveAt(OperationCount - 1); OperationList.Insert(index, property); break; case MemberType.Event: Event _event = AddEvent(); OperationList.RemoveAt(OperationCount - 1); OperationList.Insert(index, _event); break; } }
/// <summary> /// Перегрузка конструктора принимает сообщение об ошибке /// </summary> /// <param name="exeption">Сообщение об ошибке</param> /// <param name="operation">Тип операции</param> public ParsingResult(string exeption, string tableName, OperationList operation) { this.exeptionMsg = exeption; this.tableName = tableName; this.operation = operation; }
public HydraOperation GetOperation(HttpMethod method) { return(OperationList.FirstOrDefault(x => x.Method == method)); }
public FluentSyntax() { Usings = new UsingList(); Operations = new OperationList(); }
protected override void SelectOperation(Unitload unitloadIn, OperationList operationsIn, StationList processCellsIn) { unitloadIn.Operation = unitloadIn.Alternates[0].Operations[unitloadIn.Completed.Count]; }
private ProcessorList processors; //state public Station() { this.operations = new OperationList(); this.processors = new ProcessorList(); this.CreateStatistics(); }
protected abstract void SelectOperation(Unitload unitloadIn, OperationList operationsIn, StationList processCellsIn);
public OperationList Schedule_Generate() { OperationList ret = new OperationList(SharpMochaPINVOKE.Barrista_Schedule_Generate(swigCPtr), true); return ret; }
///////////////////////////////////////////////////////////////////// // PER-CLIENT THREAD ///////////////////////////////////////////////////////////////////// private void ClientThread(object tcpClientObject) { TcpClient client = tcpClientObject as TcpClient; //create packet stream PacketStream stream = null; if (CaptureException(() => { stream = new PacketStream(client); })) { return; } //read from stream bool clientSideDisconnect = false; ClientData clientData = null; while (running && stream.Connected) { //if we're connected already, send any pending metadata if (clientData != null && clientData.OutgoingMetadata.Count > 0) { lock (stateLock) { if (clientData.OutgoingMetadata.Count > 0) { if (CaptureException(() => { stream.Write(ID, new ClientMetadata(clientData.OutgoingMetadata)); })) { break; } clientData.OutgoingMetadata.Clear(); } } } //check if client has sent data if (!stream.DataAvailable) { Thread.Sleep(1); continue; } //read incoming packet Packet packet = null; if (CaptureException(() => { packet = stream.Read(); })) { break; } //check if guid matches server's (shouldn't happen?) if (packet.SenderID.Equals(ID)) { break; } //is this the first packet from a new client? if (clientData == null) { //check packet type //if it's not a connection or disconnection request, abort since the client //is not funtioning correctly if (packet.PayloadType != ConnectionRequest.PayloadType && packet.PayloadType != DisconnectionRequest.PayloadType) { //let client know we're cutting them off CaptureException(() => { stream.Write(ID, new ConnectionResponse(ConnectionResponse.ResponseCode.InvalidState)); }); break; } //deserialize packet ConnectionRequest request = null; if (CaptureException(() => { request = packet.Payload.Deserialize <ConnectionRequest>(); })) { break; } //check password if ((startParams.Password != null && (request.Password == null || !startParams.Password.Matches(request.Password))) || //requires password (startParams.Password == null && request.Password != null)) //no password required (reject incoming requests with passwords) { CaptureException(() => { stream.Write(ID, new ConnectionResponse(ConnectionResponse.ResponseCode.IncorrectPassword)); }); break; } lock (stateLock) { //duplicate id (already connected... shouldn't happen?) ClientData cl = null; if (connectedClients.TryGetValue(packet.SenderID, out cl)) { CaptureException(() => { stream.Write(ID, new ConnectionResponse(ConnectionResponse.ResponseCode.DuplicateGUID)); }); break; } //too many connections already if (connectedClients.Count >= startParams.MaxClients) { CaptureException(() => { stream.Write(ID, new ConnectionResponse(ConnectionResponse.ResponseCode.SessionFull)); }); break; } /* * COMP7722: Master operation list is sent to new clients as part of the server's response * to their initial connection request, to bring them up to speed without further handshaking. */ //get outgoing set of metadata for other clients for initial sync //(doubles as client list) Dictionary <Guid, byte[]> metadata = new Dictionary <Guid, byte[]>(); foreach (var kvp in connectedClients) { metadata[kvp.Key] = kvp.Value.Metadata; } //send response with initial sync list and metadata for other clients if (!CaptureException(() => { stream.Write(ID, new ConnectionResponse(startParams.FilePath, startParams.Name, masterOperations.Count == 0 ? null : masterOperations, metadata)); })) { //add metadata to outgoing list of other clients //(doubles as connection notification) foreach (var kvp in connectedClients) { kvp.Value.OutgoingMetadata[packet.SenderID] = request.Metadata; } //create the internal data for this client (includes list of staged operations) connectedClients[packet.SenderID] = clientData = new ClientData(packet.SenderID); } else { break; //sending ConnectionResponse failed (connection broken) } } //notify OnClientConnected?.Invoke(this, clientData.ID); } else //initial handshake sync has been performed, handle normal requests { //check guid if (!packet.SenderID.Equals(clientData.ID)) { continue; //ignore (shouldn't happen?) } switch (packet.PayloadType) { case DisconnectionRequest.PayloadType: //disconnection request from client clientSideDisconnect = true; break; case OperationList.PayloadType: //normal update request { //deserialize operation request OperationList incoming = null; if (CaptureException(() => { incoming = packet.Payload.Deserialize <OperationList>(); })) { break; } /* * COMP7722: step 3 of HOB: receive new operations from the client, * transform them using SLOT, respond with new operations from other clients, * and append the new operations to the outgoing lists of other connected clients. */ //lock operation lists (3a) lock (stateLock) { //if this oplist is not an empty request if (incoming.Operations != null && incoming.Operations.Count > 0) { //perform SLOT(OB,SIB) (3b) if (clientData.OutgoingOperations.Count > 0) { Operation.SymmetricLinearTransform(incoming.Operations, clientData.OutgoingOperations); } //append incoming ops to master and to all other outgoing (3c) masterOperations.AddRange(incoming.Operations); foreach (var kvp in connectedClients) { if (!kvp.Key.Equals(clientData.ID)) { kvp.Value.OutgoingOperations.AddRange(incoming.Operations); } } } //send response CaptureException(() => { stream.Write(ID, new OperationList(clientData.OutgoingOperations.Count > 0 ? clientData.OutgoingOperations : null)); }); //clear outgoing packet list (3d) clientData.OutgoingOperations.Clear(); } } break; case ClientMetadata.PayloadType: //client is updating it's metadata { //deserialize metadata packet ClientMetadata metadataPacket = null; if (CaptureException(() => { metadataPacket = packet.Payload.Deserialize <ClientMetadata>(); }) || metadataPacket.Metadata == null || metadataPacket.Metadata.Count == 0) { break; } //get metadata array byte[] metadata; if (!metadataPacket.Metadata.TryGetValue(clientData.ID, out metadata)) { break; //shouldn't happen; clients only send their own } //compare it to existing metadata if ((metadata == null && clientData.Metadata != null) || (metadata != null && (clientData.Metadata == null || !metadata.MemoryEquals(clientData.Metadata)))) { //update client metadata clientData.Metadata = metadata; //add to staging lists for other clients lock (stateLock) { foreach (var kvp in connectedClients) { if (!kvp.Key.Equals(clientData.ID)) { kvp.Value.OutgoingMetadata[clientData.ID] = clientData.Metadata; } } } } } break; } if (clientSideDisconnect) { break; } } } //remove the internal data for this client if (clientData != null) { bool disconnected = false; lock (stateLock) { disconnected = connectedClients.Remove(clientData.ID); } if (disconnected) { //if the client has not requested a disconnection themselves, send them one if (!clientSideDisconnect) { CaptureException(() => { stream.Write(ID, new DisconnectionRequest()); }); } OnClientDisconnected?.Invoke(this, clientData.ID); } } //close stream and tcp client stream.Dispose(); client.Close(); }
public Operation() { Parameters = new ParameterList(); Operations = new OperationList(); }
public JobRoute() { this.operations = new OperationList(); this.operationNames = new StringList(); createStatistics(); }
public void ApplyOperation(OperationList operationEnum, dynamic[] args) { IsNotSaved = true; switch (operationEnum) { case OperationList.None: return; case OperationList.Resize: args = new dynamic[] { ResizeWidth, ResizeHeight }; break; case OperationList.Scale: args = new dynamic[] { ResizeScale }; break; case OperationList.Crop: if (selectionRect.Width > 0 && selectionRect.Height > 0) { args = new dynamic[] { Canvas.GetLeft(selectionRect), Canvas.GetTop(selectionRect), selectionRect.Width, selectionRect.Height }; IsSelectToolEnabled = false; break; } else { return; } case OperationList.Undo: if (HistoryIndex > 0) { HistoryIndex = HistoryIndex - 1; } return; case OperationList.Redo: if (HistoryIndex + 1 < OperationHistory.Count) { HistoryIndex = HistoryIndex + 1; } return; case OperationList.Reset: HistoryIndex = 0; OperationHistory.Clear(); History.Clear(); operationEnum = OperationList.Original; break; } DisableAllTools(); Dissolve(); Operation operation = Operations.ImageOperations[operationEnum]; DisplayImage(operation.Operate(image, args)); OperationHistory.Add(image); History.Add(operation.OperationName); HistoryIndex = History.Count - 1; }
public Unitload() { this.alternates = new JobRouteList(); this.completed = new OperationList(); }
/// <summary> /// Listen for packets coming in from the server and handle them accordingly. /// </summary> /// <param name="stream">PacketStream in use by the Control thread.</param> /// <returns>True if the server has asked us to disconnect.</returns> private bool Listen(PacketStream stream) { while (stream.Connected && stream.DataAvailable) { //read incoming packet Packet packet = null; if (CaptureException(() => { packet = stream.Read(); })) { break; } //check if guid of sender matches server if (!packet.SenderID.Equals(serverID)) { continue; //ignore } switch (packet.PayloadType) { case DisconnectionRequest.PayloadType: //disconnection request from server return(true); case OperationList.PayloadType: //operation list (4) /* * COMP7722: step 4 of HOB: incoming operations are appended to the local * incoming operation buffer. */ if (awaitingOperationList) { OperationList operationList = null; if (CaptureException(() => { operationList = packet.Payload.Deserialize <OperationList>(); })) { break; } if (operationList.Operations != null && operationList.Operations.Count > 0) { incomingOperations.AddRange(operationList.Operations); } awaitingOperationList = false; } break; case ClientMetadata.PayloadType: { //deserialize metadata packet ClientMetadata metadataPacket = null; if (CaptureException(() => { metadataPacket = packet.Payload.Deserialize <ClientMetadata>(); }) || metadataPacket.Metadata == null || metadataPacket.Metadata.Count == 0) { break; } if (metadataPacket.Metadata != null && OnMetadataUpdated != null) { foreach (var md in metadataPacket.Metadata) { OnMetadataUpdated?.Invoke(this, md.Key, md.Value); } } } break; } } return(false); }
public Unitload(string nameIn, FLOWObject parentIn) : base(nameIn, parentIn) { this.alternates = new JobRouteList(); this.completed = new OperationList(); }
private double estimatedRepairTime; //state public Processor() { this.operations = new OperationList(); this.CreateStatistics(); }