/// <summary> /// 加载板卡驱动程序并初始化当前板卡下的所有通道 /// </summary> /// <returns>如果初始成功则返回0,否则返回相应的错误编码</returns> protected override long Initialize() { base.Initialize(); // 执行基类的初始化工作 // 添加呼入事件分配器 Logger.Info("初始化板卡内置的事件分配器 Call……"); IEventService eventService = workItem.Services.Get <IEventService>(); if (eventService != null) { eventService.RegisterEventDispatcher("Call", new CallDispatcher(typeof(ICallHandler), typeof(CallDispatcher), this)); } Logger.Info(string.Format("准备初始化{0}板卡适配器……", VersionInfo.Name)); long loadDriverSucces = -1; try { loadDriverSucces = D160X.LoadDRV(); if (loadDriverSucces != -1) { CanWork = true; } else { return(loadDriverSucces); } } catch (Exception ex) { Logger.Fatal(string.Format("加载{0}驱动程序失败,错误代码为:{1}", VersionInfo.Name, loadDriverSucces), ex); } // 初始化板卡的会议资源 int Initconf = D160X.DConf_EnableConfCard(); string[] InitconfResult = new string[] { "成功", "不是D161A卡", "在INI中,Connect参数必须设置为1", "已经使用了模拟的会议卡,并且初始化成功" }; Logger.Info(String.Format("初始化{0}的会议资源,{1}", VersionInfo.Name, InitconfResult[Initconf])); if (Initconf == 0) { confGroups = new Dictionary <int, List <int> >(); } D160X.Sig_Init(0); // 初始化信号音检测 int chnlCount = D160X.CheckValidCh(); for (int i = 0; i < chnlCount; i++) { // 初始化每条通道 AbstractChannel chnl = new DB160XChannel(this, i); if (chnl != null) { ISubscripterRegister subscripter = new CallSubscripter(chnl); // 预定义的呼叫事件订阅器 if (eventService != null) { eventService.RegisterSubscripter(subscripter); } Channels.Add(chnl); chnl.CurrentStatus = ChannelStatus.IDLE; OnCreatedChannel(this, new EventArgs <IChannel>(chnl)); // 触发通道创建事件 } } D160X.EnableCard(chnlCount, FileBufferLength); int initFax = D160X.DJFax_DriverReady(2048); if (initFax == 0) { Logger.Info("初始化传真资源,成功"); } else { Logger.Info("因为不是传真卡或配置不正确初始化板卡的传真资源失败,返回的错误代码: " + initFax.ToString()); } Logger.Info(string.Format("完成{0}板卡适配器的初始化工作", VersionInfo.Name)); return(loadDriverSucces); }