Compare commits

...

3 Commits

Author SHA1 Message Date
BuildTools
e94064cff2 Aktualisierte DB 2024-01-18 18:18:36 +01:00
BuildTools
3c81bc334e Design aktualisiert 2024-01-18 18:18:21 +01:00
BuildTools
c475af3f6d Seriellen Part auf separate Seite gepackt 2024-01-18 18:18:07 +01:00
8 changed files with 105 additions and 70 deletions

Binary file not shown.

Binary file not shown.

View File

@ -4,7 +4,7 @@
@using Microsoft.EntityFrameworkCore
@inject IDbContextFactory<DbDataContext> DataContextFactory;
@inject IWebHostEnvironment env;
@layout SideScrollLayout
<!--layout SideScrollLayout-->
<!--<h3>Cocktails</h3>-->
<SectionContent SectionId="TopRow.Title">
@ -15,22 +15,27 @@
<a href="/cocktails/add">Cocktail hinzufügen</a>
</p>
-->
<div class="container py-2 border border-5 overflow-auto d-inline-block">
<div class="row flex-nowrap">
<!-- Flex Container für Horizontalen Scroll - klappt aber nicht so richtig->
<!--<div class="container py-2 border border-5 overflow-auto d-inline-block">
<div class="row flex-nowrap">-->
<div class="card-group gap-3 flex-nowrap">
@foreach (Cocktail c in CocktailListe)
{
<div class="col">
<a href="/cocktails/@c.Id">
<div class="card" style="width: 18rem;">
<a class="text-decoration-none text-black;" href="/cocktails/@c.Id">
<div class="card" style="width: 20vw; min-width:15rem; max-height:350px; ">
@if (c.ImageURL != null && File.Exists(Path.Join(env.WebRootPath, c.ImageURL)))
{
<img class="card-img-top" src="@($"/{c.ImageURL}")" alt="@c.Name">
<img class="card-img-top" style="width:100%; min-height:70vh; object-fit:cover;" src="@($"/{c.ImageURL}")" alt="@c.Name">
}
else
{
<img class="card-img-top mh-50" src="@($"/img/cocktail-default.jpg")" alt="@c.Name">
<img class="card-img-top" style="width:100%; min-height:70vh; object-fit:cover;" src="@($"/img/cocktail-default.jpg")" alt="@c.Name">
}
<div class="card-body">
<div class="card-footer">
<h5 class="card-title">@c.Name</h5>
<!--<p class="card-text">
Testy
@ -40,6 +45,5 @@
</a>
</div>
}
</div>
</div>
</div>

View File

@ -1,5 +1,4 @@
@page "/"
@using System.IO.Ports
<PageTitle>Index</PageTitle>
@ -7,47 +6,7 @@
Welcome to your new app.
<label for="portname">Port:</label>
<InputText id="portname" @bind-Value="portname"></InputText>
<button @onclick="SendData">Send data to Arduino</button>
<p>
<label>Received: @receivedText</label>
</p>
@code {
SerialPort? port;
string? portname = "COM5";
string? receivedText;
public async Task SendData()
{
if (port == null && portname != null)
{
port = new SerialPort(portname);
port.BaudRate = 9600;
port.DataReceived += port_DataReceived;
port.DataBits = 8;
port.StopBits = StopBits.One;
port.Parity = Parity.None;
port.Handshake = Handshake.None;
port.RtsEnable = true;
}
if (port == null || port.IsOpen) return; // Port konnte nicht initialisiert werden oder ist bereits geöffnet - dann nicht nochmal öffnen
port.Open();
port.WriteLine("<RECIPE>");
}
private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
if (port != null)
{
var text = port.ReadExisting();
receivedText = text;
port.Close();
}
}
}

View File

@ -0,0 +1,71 @@
@page "/serialtest"
@using System.IO.Ports
<PageTitle>Serial Test</PageTitle>
<label for="portname">Port:</label>
<InputText id="portname" @bind-Value="portname"></InputText>
<label for="inputdata">Data:</label>
<InputText id="inputdata" @bind-Value="inputdata"></InputText>
<button @onclick="SendData">Send</button>
<p>
<label>Received: @receivedText</label>
</p>
@code {
SerialPort? port;
string? portname = "COM5";
string? receivedText;
string? inputdata ="LED";
bool status = false;
bool Sending = false;
bool Receiving = false;
public async Task SendData()
{
if (Sending) return; // nichts senden, wenn bereits am Senden
Sending = true;
if (port == null && portname != null)
{
port = new SerialPort(portname);
port.BaudRate = 115200; //9600
port.DataReceived += port_DataReceived;
//port.DataBits = 8;
//port.StopBits = StopBits.One;
//port.Parity = Parity.None;
//port.Handshake = Handshake.None;
//port.RtsEnable = true;
port.Open();
}
if (port == null || !port.IsOpen) return; // Port konnte nicht initialisiert werden oder ist bereits geöffnet - dann nicht nochmal öffnen
// port.Write($"<REZEPT:1-40,3-20,5-30,7-30,1-40,3-20,5-30,7-30,1-40,3-20,5-30,7-30:REZEPT>");
port.Write($"<{inputdata}> ");
status = !status;
Sending = false;
// inputdata = null;
}
private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
if (Receiving) return;
Receiving = true;
SerialPort port = (SerialPort)sender;
if (port != null)
{
var text = port.ReadExisting();
Console.WriteLine(text);
receivedText = text;
InvokeAsync(StateHasChanged);
// port.Close();
}
Receiving = false;
}
}

View File

@ -12,7 +12,7 @@
<main>
<TopRow />
<article class="content px-4 vh-100" style="margin-top: 3.5rem">
<article class="content px-4 " style="margin-top: 3.5rem; max-height:calc(100vh - 3.5rem);">
@Body
</article>
</main>

View File

@ -15,6 +15,7 @@
<div class="dropdown-menu dropdown-menu-end" aria-labelledby="dropdownMenuLink">
<a class="dropdown-item" href="/flaschen">Zutaten</a>
<a class="dropdown-item" href="/cocktails">Cocktails</a>
<a class="dropdown-item" href="/serialtest">Serial Test</a>
</div>
</div>
</div>