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