本文整理汇总了C#中Bus.Disconnect方法的典型用法代码示例。如果您正苦于以下问题:C# Bus.Disconnect方法的具体用法?C# Bus.Disconnect怎么用?C# Bus.Disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bus
的用法示例。
在下文中一共展示了Bus.Disconnect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: switchON
//.........这里部分代码省略.........
{
SqlDataReader _dt = sqlComm.ExecuteReader();
while (_dt.Read())
{
GroupAddressON.Add(_dt["On/Off Address"].ToString());
GroupAddressMeter.Add(_dt["MeasureCurrent Address"].ToString());
}
_dt.Close();
}
}
conn.Close();
}
Ping pingOrder = new Ping();
for (var i=0; i<4; i++)
{
try
{
pingOrder.Send(AddressIP);
}
catch (PingException ex)
{
}
}
pingOrder = null;
using (Bus _bus = new Bus(new KnxIpTunnelingConnectorParameters(AddressIP, ushort.Parse(AddressPort), AddressNat)))
{
try
{
_bus.Connect();
for (var i = 0; i < GroupAddressON.Count; i++)
{
GroupAddress _groupAddress = GroupAddress.Parse(GroupAddressON[i]);
GroupValue _groupValue = new GroupValue(true);
_bus.WriteValue(_groupAddress, _groupValue, Priority.Low);
//GroupAddress _groupAddressMeter = GroupAddress.Parse(GroupAddressMeter[i]);
//GroupValue groupValue = _bus.ReadValue(_groupAddressMeter, Priority.Low);
//DataPointTranslator _dpt = new DataPointTranslator();
//decimal _value = (decimal)_dpt.FromDataPoint("9.001", groupValue.Value);
//storeValueToDB(_value, MeterSerial, ChannelsArray[i]);
}
_bus.Disconnect();
_bus.Dispose();
updateSchedulerTable(_TaskID, false);
updatePillarDeparturesSQL(_PillarID, _channelGroup, true);
updateTask(_taskguid, "On");
emailWaring(_TaskID, _TaskSubject, _TaskStart, _TaskEnd, _channelGroup, _PillarID, null, null, null);
}
catch (ConnectorException ex)
{
updateSchedulerTable(_TaskID, true);
updateReportScheduler1(_TaskID, ex.ErrorReason);
emailWaring(_TaskID, _TaskSubject, _TaskStart, _TaskEnd, _channelGroup, _PillarID, ex, null, null);
if (_bus != null)
{
_bus.Disconnect();
_bus.Dispose();
}
}
catch (ConnectionException ex)
{
updateSchedulerTable(_TaskID, true);
updateReportScheduler2(_TaskID, ex.ErrorReason);
emailWaring(_TaskID, _TaskSubject, _TaskStart, _TaskEnd, _channelGroup, _PillarID, null, ex, null);
if (_bus != null)
{
_bus.Disconnect();
_bus.Dispose();
}
}
catch (NoResponseReceivedException ex)
{
updateSchedulerTable(_TaskID, true);
updateReportScheduler3(_TaskID, ex.ErrorReason);
emailWaring(_TaskID, _TaskSubject, _TaskStart, _TaskEnd, _channelGroup, _PillarID, null, null, ex);
if (_bus != null)
{
_bus.Disconnect();
_bus.Dispose();
}
}
finally
{
if (_bus != null)
{
_bus.Disconnect();
_bus.Dispose();
}
}
}
}
示例2: meterCurrent
//.........这里部分代码省略.........
sqlSelect = "SELECT [MeasureCurrent Address] FROM [db_knx].[dbo].[" + TypeKNX + "_" + MeterSerial + "] WHERE [Departure] = " + ChannelsArray[i] + ";";
using (SqlCommand sqlComm = new SqlCommand(sqlSelect, conn))
{
SqlDataReader _dt = sqlComm.ExecuteReader();
while (_dt.Read())
{
if (!_dt.IsDBNull(0))
{
GroupAddressMeasure.Add(_dt["MeasureCurrent Address"].ToString());
}
}
_dt.Close();
}
}
conn.Close();
}
Ping pingOrder = new Ping();
for (var i = 0; i < 4; i++)
{
try
{
pingOrder.Send(AddressIP);
}
catch (PingException ex)
{
}
}
pingOrder = null;
using (Bus _bus = new Bus(new KnxIpTunnelingConnectorParameters(AddressIP, ushort.Parse(AddressPort), AddressNat)))
{
try
{
_bus.Connect();
for (var i = 0; i < GroupAddressMeasure.Count; i++)
{
GroupValue groupValue = _bus.ReadValue(GroupAddress.Parse(GroupAddressMeasure[i]), Priority.Low);
if (groupValue != null)
{
try
{
DataPointTranslator _dpt = new DataPointTranslator();
decimal _value = (decimal)_dpt.FromDataPoint("9.001", groupValue.Value);
storeCurrentValueToDB(_value, MeterSerial, ChannelsArray[i]);
}
catch (Exception exception)
{
Console.WriteLine(exception);
}
}
}
_bus.Disconnect();
_bus.Dispose();
updateTask(_taskguid, "Meter");
}
catch (ConnectorException ex)
{
updateReportScheduler1(_TaskID, ex.ErrorReason);
if (_bus != null)
{
_bus.Disconnect();
_bus.Dispose();
}
}
catch (ConnectionException ex)
{
updateReportScheduler2(_TaskID, ex.ErrorReason);
if (_bus != null)
{
_bus.Disconnect();
_bus.Dispose();
}
}
catch (NoResponseReceivedException ex)
{
updateReportScheduler3(_TaskID, ex.ErrorReason);
if (_bus != null)
{
_bus.Disconnect();
_bus.Dispose();
}
}
finally
{
if (_bus != null)
{
_bus.Disconnect();
_bus.Dispose();
}
}
}
}