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.

164 lines
4.4 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.

namespace Service.Execute.StaticTools
{
public class SoundTool
{
private static ServiceReferenceSound.WebServiceSoundSoapClient client = new ServiceReferenceSound.WebServiceSoundSoapClient(ServiceReferenceSound.WebServiceSoundSoapClient.EndpointConfiguration.WebServiceSoundSoap);
/// <summary>
/// 播放通道换电步骤声音
/// </summary>
/// <param name="step">步骤。10:车辆已到位40:换电开始50:换电进行中60:车辆换电完成90:停止播报</param>
/// <returns>声音播放结果</returns>
private static bool ChannelPlayStepSound(ushort step)
{
bool bRst = false;
try
{
Task<bool> result = client.PlaySoundBySwapStepAsync(step);
}
catch(Exception ex)
{
ex.ToString();
}
return bRst;
}
/// <summary>
/// 根据声音编码单次播放相关语音
/// </summary>
/// <param name="soundCode">声音文件编码。比如:50001-请将车辆行驶到指定位置</param>
/// <returns>声音播放结果</returns>
public static void PlayOneSound(int soundCode)
{
try
{
client.PlaySoundBySwapStepAsync((ushort)soundCode);
}
catch (Exception ex)
{
ex.ToString();
}
}
/// <summary>
/// 根据声音编码循环播放相关语音
/// </summary>
/// <param name="soundcode">声音文件编码。比如:50001-请将车辆行驶到指定位置</param>
/// <param name="interval">播放声音间隔时间-秒</param>
/// <returns>声音播放结果</returns>
public static void PlayLoopSound(int soundcode,int interval)
{
try
{
client.PlayLoopSoundFileAsync(soundcode,interval);
}
catch (Exception ex)
{
ex.ToString();
}
}
/// <summary>
/// 播放欢迎语
/// </summary>
public static void PlayWelcomeSound()
{
ChannelPlayStepSound(10);
}
/// <summary>
/// 播放车辆到位,请拉手刹、熄火
/// </summary>
public static void PlayTruskIsReached()
{
ChannelPlayStepSound(40);
}
/// <summary>
/// 播放读RFID电子标签失败
/// </summary>
public static void PlayReadeRfidFail()
{
ChannelPlayStepSound(22);
}
/// <summary>
/// 播放车辆认证成功
/// </summary>
public static void PlayTruckSignOK()
{
ChannelPlayStepSound(23);
}
/// <summary>
/// 播放车辆认证失败
/// </summary>
public static void PlayTruckSignFail()
{
ChannelPlayStepSound(24);
}
/// <summary>
/// 播放蓝牙连接失败,异常结束请驶离
/// </summary>
public static void PlayBlueToothFail()
{
ChannelPlayStepSound(32);
}
/// <summary>
/// 播放换电进行中,请勿执行任何操作
/// </summary>
public static void PlaySwapStart()
{
ChannelPlayStepSound(50);
}
/// <summary>
/// 播放电池入库搬运中
/// </summary>
public static void PlayBatteryEntry()
{
ChannelPlayStepSound(51);
}
/// <summary>
/// 播放电池出库搬运中
/// </summary>
public static void PlayBatteryDelivery()
{
ChannelPlayStepSound(52);
}
/// <summary>
/// 播放电池安装完成
/// </summary>
public static void PlayBatteryFinished()
{
ChannelPlayStepSound(53);
}
/// <summary>
/// 播放换电完成,车辆请驶离
/// </summary>
public static void PlaySwapFinished()
{
ChannelPlayStepSound(60);
}
/// <summary>
/// 停止语音播放
/// </summary>
public static void PlaySoundStop()
{
ChannelPlayStepSound(90);
}
}
}