Skip to content

Instantly share code, notes, and snippets.

@czinegeroland
czinegeroland / PID_simulation.m
Last active October 26, 2025 07:24
PID_simulation.m
clear;
clc;
close all;
P = 1.0;
I = 1.0;
D = 1.0;
Setpoint = 100;
@czinegeroland
czinegeroland / IPidControllerConnectorService.cs
Created October 25, 2025 16:59
IPidControllerConnectorService.cs
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>
@czinegeroland
czinegeroland / PidControllerPlugin.cs
Created October 25, 2025 16:50
PidControllerPlugin.cs
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();
}
@czinegeroland
czinegeroland / PidTuningAgent.cs
Created October 25, 2025 11:07
PidTuningAgent.cs
// 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());
@czinegeroland
czinegeroland / PID_Discrete-time.m
Created October 24, 2025 21:34
PID_Discrete-time
error = Setpoint - current_value;
% PID calculations
proportional = P * error;
integral = integral + (I * error * dt);
derivative = D * (error - previous_error) / dt;
@czinegeroland
czinegeroland / PID_Formula.md
Last active October 24, 2025 21:15
PID_Formula

$$ u(t) = K_p \cdot e(t) + K_i \int_0^t e(\tau),d\tau + K_d \cdot \frac{de(t)}{dt} $$

pipelines:
default:
- step:
runs-on:
- self.hosted
- linux
script:
@czinegeroland
czinegeroland / Dockerfile
Last active March 14, 2025 17:43
Dockerfile
# 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
@czinegeroland
czinegeroland / program.cs
Last active March 13, 2025 21:04
program.cs
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(),
})
);
@czinegeroland
czinegeroland / scaledobject.yaml
Created March 13, 2025 20:30
scaledobject.yaml
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: consumer-scaledobject
namespace: default
spec:
scaleTargetRef:
name: consumer
minReplicaCount: 0
maxReplicaCount: 3