You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

243 lines
9.6 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using Autofac;
using Common.Util;
using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac;
using HybirdFrameworkCore.Autofac.Attribute;
using Repository.Station;
using log4net;
namespace Service.Sound.SoundClient;
[Scope]
public class SoundClient
{
private static readonly ILog Log = LogManager.GetLogger(typeof(SoundClient));
EquipInfoRepository equipInfoRepository = AppInfo.Container.Resolve<EquipInfoRepository>();
EquipNetInfoRepository netInfoRepository = AppInfo.Container.Resolve<EquipNetInfoRepository>();
public static string soundIp = "";
/// <summary>
/// //0-播放停止状态 //1-播放中 //2-播放暂停状态
/// </summary>
private uint m_nPlayStatus = 3;
public string SoundConn()
{
//设备编码 2 - 音响IP "192.168.3.77"
EquipInfo equipInfo = equipInfoRepository.QueryByClause(u => u.Code == "2");
if (equipInfo != null)
{
EquipNetInfo equipNetInfo = netInfoRepository.QueryByClause(u => u.Code == equipInfo.Code);
if (equipNetInfo != null)
{
NAudioClientDll.na_add_play_device(0, 0, equipNetInfo.NetAddr);
IntPtr[] devlist = new IntPtr[512];
int devcnt = 0;
NAudioClientDll.na_get_play_device(0, 0, devlist, ref devcnt);
if (devcnt == 1)
{
soundIp = equipNetInfo.NetAddr;
Log.Info("音响设备" + equipNetInfo.NetAddr + "添加成功");
return "音响设备" + equipNetInfo.NetAddr + "添加成功";
}
else
{
Log.Info("音响设备" + equipNetInfo.NetAddr + "添加失败");
return "音响设备" + equipNetInfo.NetAddr + "添加失败";
}
}
return "数据库设备IP不存在";
}
return "数据库设备信息不存在";
}
/// <summary>
/// 设置音量
/// </summary>
/// <param name="soundValue">0-100</param>
public void ControlSound(byte soundValue)
{
if (soundIp != "")
{
//更新播放设备音量
NAudioClientDll.na_set_device_volume(soundIp, soundValue);
}
}
/// <summary>
/// 播放声音文件
/// </summary>
/// <param name="fileLoad">mp3 文件所在路径</param>
/// 例如:"D:\\Desktop\\Sound\\电池拆卸中请稍后.mp3"
public bool SoundPlay( SoundEnum soundEnum)
{
/*int result = NAudioClientDll.na_start_play_1(0, 0, fileLoad, 10);
if (NAudioClientDll.RET_SUCCESS == result)
return true;
return false;*/
string url = "http://127.0.0.1:5039/" + (Convert.ToByte(soundEnum)).ToString();
HttpUtil.SendGetRequest(url);
return true;
}
/// <summary>
/// 当前设备是否允许播放
/// </summary>
/// <returns></returns>
public bool EnableSoundPlay()
{
NAudioClientDll.na_get_play_status(0, 0, ref m_nPlayStatus);
//当前 播放状态:播放中
if (m_nPlayStatus == NAudioClientDll.PS_PLAYING)
return false;
return true;
}
}
public enum SoundEnum
{
music01=1,//车辆已到位,请停车
music02,//请将车辆行驶到指定位置
music03,//请按屏幕顺序操作车辆;
music04,//请尽快将车辆行驶到指定位置
music05,//认证失败,请联系站务人员
music06,//车站通讯故障,请联系站务
music07,//换电站模式错误,请联系站务
music08,//车辆型号不适配本站,请联系站务了解更多信息
music09,//车辆不符合换电要求,请驶离
music10,//请按屏幕顺序操作车辆;
music11,//无可用电池,请联系站务
music12,//请拉起手刹
music13,//请熄火车辆;
music14,//设备准备中,请勿操作车辆
music15,//请按下启动按钮,开始换电
music16,//开始换电
music17,//请使用手机APP启动换电
music18,//设备不允许换电,请联系站务
music19,//车机不允许换电,请联系站务
music20,//开始换电,请勿操作车辆
music21,//定位电池失败,请联系站务人员
music22,//电池定位不成功,请联系站务确认精度
music23,//车辆角度过大,请将车辆停正
music24,//电池定位结束,请联系站务确认精度
music25,//自动解锁失败,请联系站务手动解锁
music26,//电池解锁中,请稍候
music27,//电池拆卸完成
music28,//电池搬运中,请稍候
music29,//电池安装中,请稍候
music30,//自动上锁失败,请联系站务手动上锁
music31,//电池自动上锁中,请稍候
music32,//换电暂停,请联系站务确认锁状态
music33,//自检失败,请联系站务人员
music34,//换电完成,祝你一路顺风
music35,//突发紧急状况,请尽快撤离
music36,//换电暂停,请联系站务人员
music37,//您已进入危险区域,请尽快离开
music38,//车辆高压异常,请熄火车辆
music39,//车站通讯故障,请联系站务
music41=41,//[Info("欢迎光临换电站!(正在营业)","欢迎光临换电站!,本站正在营业中")]WelcomeInfo=1,
music42,//[Info("标签读写失败", "标签读写失败")] ErrorReadRfid ,
music43,//[Info("车辆连接失败", "车辆连接失败,请联系站务人员")] ErrorTBoxConn ,
music44,//[Info("云端校验失败", "云端校验失败,请联系站务人员")] ErrorCloudCheck ,
music45,//[Info("车辆已到位", "车辆已到位")] InfoCarInPosition ,
music46,//[Info("请熄火挂空挡拉手刹", "请熄火挂空挡拉手刹")] ErrorCarInPositionTimeout,
music47,//[Info("云平台下发换电失败", "云平台下发换电超时")] CloudSendSwapError ,
music48,//[Info("解锁车辆失败", "解锁车辆失败")] ErrUnLockCar ,
music49,//[Info("选包失败,请驶离", "选包失败,请驶离")] ErrorSelectPack ,
music50,//[Info("通道拍照定位失败,请在三分钟内重新调整车辆位置", "通道拍照定位失败,请在三分钟内重新调整车辆位置")]ErrChannelStatus=10,
music51,//[Info("电池拆卸中,请稍后", "电池拆卸中,请稍后")] InfoUnPack ,
music52,//[Info("电池安装中,请稍后", "电池安装中,请稍后")] InfoPack ,
music53,//[Info("电池包已安装完成", "电池包已安装完成")] InfoPackFinish ,
music54,//[Info("航车已回归安全位置", "航车已回归安全位置")] InfoToSafePosition ,
music55,//[Info("换电已完成,请驶离", "换电已完成,请驶离")] InfoCarLeave ,
music56,//[Info("换电失败,请驶离", "换电失败,请驶离")] ErrInfoCarLeave ,
music57,//[Info("电池入仓中,请稍后", "电池入仓中,请稍后")] InfoOldBatteryCarryIn ,
music58,//[Info("电池出仓中,请稍后", "电池出仓中,请稍后")] InfoNewBatteryCarryOut ,
music59,//[Info("车辆上锁失败", "车辆上锁失败")] ErrLockCar ,
music60,//[Info("通道的电池仓无可用换电电池","通道的电池仓无可用换电电池")] NoBatteryErr,
music61,//[Info("结束充电电池数量不足","通道的电池仓无可用换电电池")] LessOfFinishChargingErr,
music62,//[Info("空仓数量不足","通道的电池仓无可用换电电池")] LessOfEmptyBinErr,
music63,//[Info("符合soc限制数量不足","通道的电池仓无可用换电电池")] LessOfSocErr,
music64,//[Info("结束充电大于3分钟的数量不足","通道的电池仓无可用换电电池")] LessOf3MinuteErr,
music65,//[Info("换电站处于手动模式,不能自动换电","换电站处于手动模式,不能自动换电")] InfoStationModel,
music66,//[Info("换电站处于本地模式,不能远程换电","换电站处于本地模式,不能远程换电")] InfoStationModelRemoteErr,
music67,//[Info("车辆驶入","车辆驶入")] CarInInfo,
music68,//[Info("换电任务启动","换电任务启动")] StartSwapInfo,
music69,//[Info("航车拍照中,请稍后","航车拍照中,请稍后")] CarTakePhotoInfo,
music70,//[Info("启动换电失败,请联系站务人员","启动换电失败,请联系站务人员")] ErrStartSwap,
music71,//即将进行消防移仓,请通道车辆驶离
music72,//电池移仓中//
music73,//消防移仓中
music74,//开始读取标签失败
music75,
music76=76,//[Info(" 换电完成,请驶离印尼")] ErrStartSwap,
music77=77,//[Info(" 换电完成,请驶离")] ErrStartSwap,
music78,
music79,
music80,
music81,
music82,
music83,
music84,
music85,
music86,
music87,
music88,
music89,
music90,//[Info("开始换电中")] ErrStartSwap,
music91,//[Info("换电开始印尼")] ErrStartSwap,
music92,//[Info(" 解锁成功中")] ErrStartSwap,
music93,//[Info(" 解锁成功印尼")] ErrStartSwap,
music100=100,//[Info(" 车辆停放不到位印尼")] ErrStartSwap,
music101,//[Info(" 车辆停放不到位")] ErrStartSwap,
music102,//[Info(" 正在等待车辆连接印尼")] ErrStartSwap,
music103,//[Info(" 正在等待车辆连接")] ErrStartSwap,
music104,//[Info(" 解锁失败印尼")] ErrStartSwap,
music105,//[Info(" 解锁失败")] ErrStartSwap,
music106,//[Info(" 选包失败印尼")] ErrStartSwap,
music107,//[Info(" 选包失败")] ErrStartSwap,
music108,//[Info(" 车辆验证失败印尼")] ErrStartSwap,
music109,//[Info(" 车辆验证失败")] ErrStartSwap,
/*
*/
}