62 lines
2.1 KiB
C#
62 lines
2.1 KiB
C#
using AgroBase.Comum;
|
|
using AgroBase.Models;
|
|
using AgroBase.Models.Modules;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO.Ports;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using static AgroBase.Models.Enuns;
|
|
|
|
namespace AgroBase.Services
|
|
{
|
|
public static class DispositivosServiceFactory
|
|
{
|
|
public static IDispositivosService CreateDispositivoService(T_Code tipoDispositivo, string nome, string descricao, SerialPort porta)
|
|
{
|
|
switch (tipoDispositivo)
|
|
{
|
|
case T_Code.Mov:
|
|
return new DispositivosService<MovimentacaoModel>
|
|
{
|
|
Dispositivo = tipoDispositivo,
|
|
_Nome = nome,
|
|
_Descricao = descricao,
|
|
_Porta = porta,
|
|
_CriadoEm = DateTime.Now,
|
|
};
|
|
case T_Code.Dir:
|
|
return new DispositivosService<DirecionalModel>
|
|
{
|
|
Dispositivo = tipoDispositivo,
|
|
_Nome = nome,
|
|
_Descricao = descricao,
|
|
_Porta = porta,
|
|
_CriadoEm = DateTime.Now,
|
|
};
|
|
case T_Code.Sen:
|
|
return new DispositivosService<SensoriamentoModel>
|
|
{
|
|
Dispositivo = tipoDispositivo,
|
|
_Nome = nome,
|
|
_Descricao = descricao,
|
|
_Porta = porta,
|
|
_CriadoEm = DateTime.Now,
|
|
};
|
|
case T_Code.Atu:
|
|
return new DispositivosService<AtuadorModel>
|
|
{
|
|
Dispositivo = tipoDispositivo,
|
|
_Nome = nome,
|
|
_Descricao = descricao,
|
|
_Porta = porta,
|
|
_CriadoEm = DateTime.Now,
|
|
};
|
|
default:
|
|
throw new ArgumentException("Tipo de dispositivo não reconhecido.");
|
|
}
|
|
}
|
|
}
|
|
}
|