Compare commits
3 Commits
16a63c6a8c
...
e94064cff2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e94064cff2 | ||
|
|
3c81bc334e | ||
|
|
c475af3f6d |
Binary file not shown.
Binary file not shown.
@ -4,7 +4,7 @@
|
|||||||
@using Microsoft.EntityFrameworkCore
|
@using Microsoft.EntityFrameworkCore
|
||||||
@inject IDbContextFactory<DbDataContext> DataContextFactory;
|
@inject IDbContextFactory<DbDataContext> DataContextFactory;
|
||||||
@inject IWebHostEnvironment env;
|
@inject IWebHostEnvironment env;
|
||||||
@layout SideScrollLayout
|
<!--layout SideScrollLayout-->
|
||||||
<!--<h3>Cocktails</h3>-->
|
<!--<h3>Cocktails</h3>-->
|
||||||
|
|
||||||
<SectionContent SectionId="TopRow.Title">
|
<SectionContent SectionId="TopRow.Title">
|
||||||
@ -15,31 +15,35 @@
|
|||||||
<a href="/cocktails/add">Cocktail hinzufügen</a>
|
<a href="/cocktails/add">Cocktail hinzufügen</a>
|
||||||
</p>
|
</p>
|
||||||
-->
|
-->
|
||||||
<div class="container py-2 border border-5 overflow-auto d-inline-block">
|
<!-- Flex Container für Horizontalen Scroll - klappt aber nicht so richtig->
|
||||||
<div class="row flex-nowrap">
|
<!--<div class="container py-2 border border-5 overflow-auto d-inline-block">
|
||||||
@foreach (Cocktail c in CocktailListe)
|
<div class="row flex-nowrap">-->
|
||||||
{
|
|
||||||
<div class="col">
|
|
||||||
<a href="/cocktails/@c.Id">
|
|
||||||
<div class="card" style="width: 18rem;">
|
|
||||||
@if (c.ImageURL != null && File.Exists(Path.Join(env.WebRootPath, c.ImageURL)))
|
|
||||||
{
|
|
||||||
<img class="card-img-top" src="@($"/{c.ImageURL}")" alt="@c.Name">
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<img class="card-img-top mh-50" src="@($"/img/cocktail-default.jpg")" alt="@c.Name">
|
|
||||||
}
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">@c.Name</h5>
|
|
||||||
<!--<p class="card-text">
|
|
||||||
Testy
|
|
||||||
</p>-->
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
<div class="card-group gap-3 flex-nowrap">
|
||||||
|
@foreach (Cocktail c in CocktailListe)
|
||||||
|
{
|
||||||
|
<div class="col">
|
||||||
|
<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" style="width:100%; min-height:70vh; object-fit:cover;" src="@($"/{c.ImageURL}")" alt="@c.Name">
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
<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-footer">
|
||||||
|
<h5 class="card-title">@c.Name</h5>
|
||||||
|
<!--<p class="card-text">
|
||||||
|
Testy
|
||||||
|
</p>-->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
</div>
|
||||||
@ -1,5 +1,4 @@
|
|||||||
@page "/"
|
@page "/"
|
||||||
@using System.IO.Ports
|
|
||||||
|
|
||||||
<PageTitle>Index</PageTitle>
|
<PageTitle>Index</PageTitle>
|
||||||
|
|
||||||
@ -7,47 +6,7 @@
|
|||||||
|
|
||||||
Welcome to your new app.
|
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 {
|
@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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
71
CocktailWeb/Pages/SerialTest.razor
Normal file
71
CocktailWeb/Pages/SerialTest.razor
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -12,7 +12,7 @@
|
|||||||
<main>
|
<main>
|
||||||
<TopRow />
|
<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
|
@Body
|
||||||
</article>
|
</article>
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
<div class="dropdown-menu dropdown-menu-end" aria-labelledby="dropdownMenuLink">
|
<div class="dropdown-menu dropdown-menu-end" aria-labelledby="dropdownMenuLink">
|
||||||
<a class="dropdown-item" href="/flaschen">Zutaten</a>
|
<a class="dropdown-item" href="/flaschen">Zutaten</a>
|
||||||
<a class="dropdown-item" href="/cocktails">Cocktails</a>
|
<a class="dropdown-item" href="/cocktails">Cocktails</a>
|
||||||
|
<a class="dropdown-item" href="/serialtest">Serial Test</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user