This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| clear; | |
| clc; | |
| close all; | |
| P = 1.0; | |
| I = 1.0; | |
| D = 1.0; | |
| Setpoint = 100; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface IPidControllerConnectorService | |
| { | |
| /// <summary> | |
| /// Gets any initial configuration needed for the PID controller connection like ControlIterationDelayInMs, OutputMax, OutputMin. | |
| /// </summary> | |
| Task<InitConfig> GetInitConfig(); | |
| /// <summary> | |
| /// Gets the current PID controller parameters (gains). | |
| /// </summary> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class PidControllerPlugin( | |
| IPidControllerConnectorService pidControllerConnector | |
| ) : IPidControllerPlugin | |
| { | |
| [KernelFunction("GetSetPoint")] | |
| [Description("Gets the current setpoint of the PID controller. The setpoint is the desired target value that the system should reach.")] | |
| public async Task<decimal> GetSetPoint() | |
| { | |
| return await pidControllerConnector.GetSetPointAsync(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Build Semantic Kernel with OpenAI chat completion | |
| var builder = Kernel.CreateBuilder(); | |
| builder.AddOpenAIChatCompletion("gpt-5-nano", apiKey); | |
| var kernel = builder.Build(); | |
| var chatCompletion = _kernel.GetRequiredService<IChatCompletionService>(); | |
| // Initialize chat history with system prompt | |
| var chatHistory = new ChatHistory(); | |
| chatHistory.AddSystemMessage(PromtsHelper.GetSystemPrompt()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| error = Setpoint - current_value; | |
| % PID calculations | |
| proportional = P * error; | |
| integral = integral + (I * error * dt); | |
| derivative = D * (error - previous_error) / dt; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pipelines: | |
| default: | |
| - step: | |
| runs-on: | |
| - self.hosted | |
| - linux | |
| script: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This stage is used when running from VS in fast mode (Default for Debug configuration) | |
| FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base | |
| USER $APP_UID | |
| WORKDIR /app | |
| EXPOSE 8080 | |
| EXPOSE 8081 | |
| # This stage is used to build the service project | |
| FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| app.MapGet("/submitOrders-parallel/{messageCount:int}", async ( | |
| [FromRoute] int messageCount, | |
| [FromServices] IPublishEndpoint publishEndpoint) => | |
| { | |
| var messages = Enumerable.Range(0, messageCount) | |
| .Select(_ => publishEndpoint.Publish(new OrderSubmitted | |
| { | |
| OrderId = NewId.NextGuid(), | |
| }) | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apiVersion: keda.sh/v1alpha1 | |
| kind: ScaledObject | |
| metadata: | |
| name: consumer-scaledobject | |
| namespace: default | |
| spec: | |
| scaleTargetRef: | |
| name: consumer | |
| minReplicaCount: 0 | |
| maxReplicaCount: 3 |
NewerOlder