Skip to content

Commit

Permalink
added api methods
Browse files Browse the repository at this point in the history
  • Loading branch information
fbarresi committed Nov 15, 2020
1 parent 0b441eb commit 05c188d
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 56 deletions.
47 changes: 47 additions & 0 deletions SoftBeckhoff/Controllers/SoftBeckhoffController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;

namespace SoftBeckhoff.Controllers
{
[ApiController]
[Route("[controller]")]
public class SoftBeckhoffController : ControllerBase
{
private readonly ILogger<SoftBeckhoffController> logger;
private readonly IPlcService plcService;

public SoftBeckhoffController(ILogger<SoftBeckhoffController> logger, IPlcService plcService)
{
this.logger = logger;
this.plcService = plcService;
}

[HttpGet("/symbols")]
public IEnumerable<object> GetSymbols()
{
return plcService.GetSymbols();
}

[HttpGet("/symbols/{name}")]
public object GetSymbol([FromRoute]string name)
{
return plcService.GetSymbol(name);
}

[HttpPut("/symbols/{name}")]
public void SetSymbol([FromRoute]string name, [FromBody]object value)
{
plcService.SetSymbol(name, value);
}

[HttpPost("/symbols")]
public void CreateSymbol([FromBody]object symbol)
{
plcService.CreateSymbol(symbol);
}
}
}
39 changes: 0 additions & 39 deletions SoftBeckhoff/Controllers/WeatherForecastController.cs

This file was deleted.

23 changes: 22 additions & 1 deletion SoftBeckhoff/Services/BeckhoffService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive;
using System.Reactive.Disposables;
Expand Down Expand Up @@ -33,7 +34,27 @@ public void Dispose()
disposables?.Dispose();
}

private Task<Unit> InitializeAsync()
public IEnumerable<object> GetSymbols()
{
throw new NotImplementedException();
}

public object GetSymbol(string name)
{
throw new NotImplementedException();
}

public void SetSymbol(string name, object value)
{
throw new NotImplementedException();
}

public void CreateSymbol(object symbol)
{
throw new NotImplementedException();
}

private Task<Unit> InitializeAsync()
{
logger.LogInformation("Initializing Beckhoff server...");
server = new BeckhoffServer(logger);
Expand Down
6 changes: 5 additions & 1 deletion SoftBeckhoff/Services/IPlcService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
using System;
using System.Collections.Generic;

public interface IPlcService : IDisposable
{

IEnumerable<object> GetSymbols();
object GetSymbol(string name);
void SetSymbol(string name, object value);
void CreateSymbol(object symbol);
}
15 changes: 0 additions & 15 deletions SoftBeckhoff/WeatherForecast.cs

This file was deleted.

0 comments on commit 05c188d

Please sign in to comment.