Skip to content

Commit 0df908d

Browse files
author
Mariusz
committed
CommServer.DA.Server - create installation package - working on ProtocolHub.MonitorInterface - refactoring
- fixed compilation errors after namespace modification - fixed wrong listener type declamation Issue #: 4862
1 parent 01729d9 commit 0df908d

21 files changed

Lines changed: 116 additions & 199 deletions

CommServer.ProtocolHub.sln

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
VisualStudioVersion = 14.0.25420.1
44
MinimumVisualStudioVersion = 10.0.40219.1
55
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2174EF99-7D4B-45EE-87F7-D5912F3DFB5D}"
6+
ProjectSection(SolutionItems) = preProject
7+
..\..\..\svn.CommServer.DA\CommServer.DA.Server\CommServer.DA.Server\Server.NETServerUnitTest\app.config = ..\..\..\svn.CommServer.DA\CommServer.DA.Server\CommServer.DA.Server\Server.NETServerUnitTest\app.config
8+
EndProjectSection
69
EndProject
710
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "T4Definitions", "..\PR39-CommonResources\T4Definitions\T4Definitions.csproj", "{D506423B-BA21-49E6-8C3B-88A771CA444E}"
811
EndProject

ProtocolHub.Communication/BaseStation/Channel.cs

Lines changed: 6 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
//_______________________________________________________________
1515

1616
using CAS.CommServer.ProtocolHub.Communication.LicenseControl;
17+
using CAS.CommServer.ProtocolHub.MonitorInterface;
1718
using CAS.Lib.CommonBus;
1819
using CAS.Lib.CommonBus.ApplicationLayer;
1920
using CAS.Lib.CommonBus.Management;
@@ -24,19 +25,13 @@
2425
using System.Collections;
2526
using System.ComponentModel;
2627
using System.Xml;
27-
using Statistics = global::BaseStation.Management.Statistics;
2828

2929
namespace CAS.CommServer.ProtocolHub.Communication.BaseStation
3030
{
3131
/// <summary>
3232
/// Channel implementation
3333
/// </summary>
34-
#if COMMSERVER
3534
internal class Channel : HandlerWaitTimeList<SegmentStateMachine>
36-
#endif
37-
#if SNIFFER
38-
internal class Channel
39-
#endif
4035
{
4136

4237
#region private
@@ -96,19 +91,8 @@ private IApplicationLayerMaster CreateApplicationProtocol(ComunicationNet.Protoc
9691
}
9792
return null;
9893
}
99-
#if SNIFFER
100-
private Segment mySegment;
101-
private void Scanner()
102-
{
103-
lock(this)
104-
{
105-
mySegment.SwitchOn();
106-
}
107-
}//Scanner
108-
#endif
109-
#if COMMSERVER
11094
private SegmentStateMachine CurrSegment = null;
111-
#region HandlerWaitTimeList implementation
95+
#region
11296
public override void NewOvertimeCoefficient(long min, long max, long avr)
11397
{
11498
// base.NewOvertimeCoefficient (min, max, avr);
@@ -123,52 +107,24 @@ protected override void Handler(SegmentStateMachine myDsc)
123107
CurrSegment.ConnectRequest();
124108
}//Scanner
125109
#endregion
126-
#endif
110+
127111
#region creator
128-
#if COMMSERVER
129112
private Channel(ComunicationNet.ChannelsRow myCDsc, CommServerComponent parent, bool demoVersion)
130113
: base(false, "ChannelSegTOL_" + myCDsc.Name)
131114
{
132115
CommServerComponent.Tracer.TraceVerbose(150, m_src, "Creating channel: " + myCDsc.Name);
133116
Multichannel.NextChannnel();
134117
myStatistics = new Statistics.ChannelStatistics(myCDsc);
135-
#endif
136-
#region Sniffer
137-
#if SNIFFER
138-
private Channel(NetworkConfig.ComunicationNet.ChannelsRow myCDsc)
139-
{
140-
#endif
141-
#endregion Sniffer
142118
PluginCollection m_Plugins = new PluginCollection(parent.m_CommonBusControl);
143119
foreach (ComunicationNet.ProtocolRow proto in myCDsc.GetProtocolRows())
144120
{
145-
#region SNIFFER
146-
#if SNIFFER
147-
try
148-
{
149-
//*******************************************************
150-
//tutaj kreowanie odpowiedniego protokolu nasluchujacego
151-
//*******************************************************
152-
ApplicationLayer.IApplicationLayerSniffer chnProtocol = (ApplicationLayer.IApplicationLayerSniffer)
153-
NetworkConfig.ApplicationProtocol.CreateApplicationProtocol(typeof(IApplicationLayerPluginHelperSniffer), proto);
154-
mySegment = new Segment(chnProtocol);
155-
//*******************************************************
156-
//tutaj start scannera dla channela i segmentu w bussnifferze
157-
//*******************************************************
158-
Processes.Manager.StartProcess
159-
(new System.Threading.ThreadStart(Scanner), "ChScanner" + myCDsc.Name, true);
160-
}
161-
catch ( NetworkConfig.InterfaceNotImplementedException ) { } //(Assertion) {}
162-
#endif
163-
#endregion
164-
#if COMMSERVER
165121
IApplicationLayerMaster chnProtocol = CreateApplicationProtocol(proto, parent, m_Plugins);
166122
if (chnProtocol != null)
167123
{
168124
foreach (ComunicationNet.SegmentsRow currDSC in proto.GetSegmentsRows())
169125
{
170126
SegmentParameters parameters = new SegmentParameters(currDSC);
171-
Diagnostic.Segment segmentStatistic = new Diagnostic.Segment(currDSC, myStatistics);
127+
Diagnostic.Segment segmentStatistic = new Diagnostic.Segment(currDSC, myStatistics);
172128
Segment segment = new Segment
173129
(currDSC, (byte)proto.MaxNumberOfRetries, chnProtocol, parameters, demoVersion, segmentStatistic, this);
174130
segment.Cycle = parameters.TimeReconnect;
@@ -180,11 +136,11 @@ private Channel(NetworkConfig.ComunicationNet.ChannelsRow myCDsc)
180136
string name = proto != null ? proto.Name : "---not set---";
181137
CommServerComponent.Tracer.TraceWarning(199, m_src, "Cannot find component implementing the required protocol: " + name);
182138
}
183-
#endif
184139
}//foreach (NetworkConfig.ComunicationNet.ProtocolRow proto in myCDsc.GetProtocolRows)
185140
CommServerComponent.Tracer.TraceVerbose(203, m_src, "Channel: " + myCDsc.Name + " has been created.");
186141
}//Channel
187142
#endregion
143+
188144
#endregion
189145

190146
#region API
@@ -198,7 +154,7 @@ internal static void InitializeChannels(ComunicationNet.ChannelsDataTable channe
198154
}
199155
catch (LicenseException ex)
200156
{
201-
string msg = "Cannot create channel {0} becaose of {1}";
157+
string msg = "Cannot create channel {0} because of {1}";
202158
CommServerComponent.Tracer.TraceVerbose(220, m_src, string.Format(msg, currRow.Name, ex.Message));
203159
}
204160
}

ProtocolHub.Communication/BaseStation/ConsoleIterface.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,30 @@
66
// $LastChangedBy$
77
// $URL$
88
// $Id$
9-
// History :
10-
// MZbrzezny 2006-03-01: created
119
//
1210
// Copyright (C)2006, CAS LODZ POLAND.
1311
// TEL: +48 (42) 686 25 47
1412
// mailto:techsupp@cas.eu
1513
// http://www.cas.eu
1614
//</summary>
1715

18-
using BaseStation.Management;
1916
using CAS.CommServer.ProtocolHub.Communication.Properties;
17+
using CAS.CommServer.ProtocolHub.MonitorInterface;
2018
using CAS.Lib.RTLib.Management;
2119
using CAS.Lib.RTLib.Processes;
2220
using System;
2321
using System.Collections.Generic;
2422
using System.Runtime.Remoting;
2523
using System.Runtime.Remoting.Channels;
2624
using System.Runtime.Remoting.Channels.Tcp;
27-
using Statistics = BaseStation.Management.Statistics;
25+
using static CAS.CommServer.ProtocolHub.MonitorInterface.Statistics.InterfaceStatistics;
2826

2927
namespace CAS.CommServer.ProtocolHub.Communication.BaseStation
3028
{
3129
/// <summary>
3230
/// Summary description for ConsoleIterface.
3331
/// </summary>
34-
public class ConsoleIterface : global::BaseStation.ConsoleIterfaceAbstract
32+
public class ConsoleIterface : ConsoleInterfaceAbstract
3533
{
3634
private class StatisticAndIUpdatePair<StatT>
3735
{
@@ -145,7 +143,7 @@ public override SortedList<long, int> GetStationStates()
145143
/// </summary>
146144
/// <param name="index">The index.</param>
147145
/// <returns>selected (by index) interface</returns>
148-
public override Statistics.InterfaceStatistics.InterfaceStatisticsInternal GetInterface(ulong index)
146+
public override InterfaceStatisticsInternal GetInterface(ulong index)
149147
{
150148
Statistics.InterfaceStatistics.InterfaceStatisticsInternal Interface =
151149
interfacelistpairs[index].GetStatisticsObjectUpdated();

ProtocolHub.Communication/BaseStation/DataBlock.cs

Lines changed: 16 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,7 @@ protected Tag[] createdTags
7676
#endregion //IBlockDescription
7777

7878
#region PUBLIC
79-
#if OPCCLIENT
80-
internal abstract class Tag: OPC.OPC_Interface.OPC_Interface_Tag
81-
#elif COMMSERVER
8279
internal abstract class Tag : Device.TagInDevice
83-
#endif
8480
{
8581

8682
#region PRIVATE
@@ -168,37 +164,15 @@ internal static System.Type GetDataTypeFromConfig(ComunicationNet.TagsRow myDSC)
168164
else
169165
return typeof(object);
170166
}
171-
#if OPCCLIENT
172-
internal override bool
173-
#elif COMMSERVER
174-
public override void
175-
#endif
176-
UpdateTag(object Val)
167+
public override void UpdateTag(object Val)
177168
{
178-
#if OPCCLIENT
179-
if ( ! base.UpdateTag(Val) ) return false;
180-
#elif COMMSERVER
181169
base.UpdateTag(Val);
182-
#endif
183170
CheckTagAlarm(Val);
184-
#if OPCCLIENT
185-
return true;
186-
#endif
187171
}
188-
#if OPCCLIENT
189-
internal
190-
#elif COMMSERVER
191-
public override
192-
#endif
193-
bool GetVal(ref object Val)
172+
public override bool GetVal(ref object Val)
194173
{
195-
#if OPCCLIENT
196-
Val=base.Value.Value;
197-
if(base.Value.Quality.QualityBits != Opc.Da.qualityBits.good)return false;
198-
#elif COMMSERVER
199174
if (!base.GetVal(ref Val))
200175
return false;
201-
#endif
202176
CheckTagAlarm(Val);
203177
return true;
204178
}
@@ -207,18 +181,8 @@ bool GetVal(ref object Val)
207181
/// </summary>
208182
/// <param name="myDSC">params from Tags table</param>
209183
/// <param name="myStation">pointer to interface that allow to change priority of the station</param>
210-
#if OPCCLIENT
211-
internal Tag
212-
( BaseStation.Management.Tag myDSC, IStationState myStation )
213-
:base(myDSC,//myDSC.Name,
214-
null, // MPTD raczej empy wariant
215-
Opc.Da.qualityBits.badNotConnected,
216-
myDSC.Writeable ,null,"") //MZTD: - dodac opisy dla tagow i ew. path
217-
#elif COMMSERVER
218-
internal Tag
219-
(ComunicationNet.TagsRow myDSC, IStationState myStation)
184+
internal Tag(ComunicationNet.TagsRow myDSC, IStationState myStation)
220185
: base(myDSC.Name, null, Opc.Da.qualityBits.badNotConnected, (ItemAccessRights)myDSC.AccessRights, GetDataTypeFromConfig(myDSC))
221-
#endif
222186
{
223187
switch ((StateTrigger)myDSC.StateTrigger)
224188
{
@@ -233,21 +197,20 @@ internal Tag
233197
}
234198
stateMask = (int)myDSC.StateMask;
235199
this.myStation = myStation;
236-
#if COMMSERVER
237200
this.EuType = Opc.Da.euType.noEnum;
238201
ItemPropertyCollection itemPropertyCollection = new ItemPropertyCollection();
239202
foreach (ComunicationNet.ItemPropertiesTableRow row_property in myDSC.GetItemPropertiesTableRows())
240203
{
241204
try
242205
{
243-
Opc.Da.PropertyDescription prop_dsc =
244-
Opc.Da.PropertyDescription.Find(
245-
new Opc.Da.PropertyID(
206+
PropertyDescription prop_dsc =
207+
PropertyDescription.Find(
208+
new PropertyID(
246209
new XmlQualifiedName(row_property.ID_Name_Name, row_property.ID_Name_Namespace)
247210
));
248-
Opc.Da.ItemProperty itemprop = new Opc.Da.ItemProperty();
249-
itemprop.ID = prop_dsc.ID;
250-
itemprop.Value = row_property.Value;
211+
ItemProperty _itemProperty = new ItemProperty();
212+
_itemProperty.ID = prop_dsc.ID;
213+
_itemProperty.Value = row_property.Value;
251214
if (prop_dsc.ID != Opc.Da.Property.DATATYPE) //this property is managed differently
252215
// as GetDataTypeFromConfig( myDSC )
253216
// at the constructor
@@ -264,24 +227,24 @@ internal Tag
264227
// this property contains double value
265228
double prop_value = 0;
266229
if (double.TryParse(row_property.Value, out prop_value))
267-
itemprop.Value = prop_value;
230+
_itemProperty.Value = prop_value;
268231
}
269232
if (prop_dsc.ID == Opc.Da.Property.EUTYPE)
270233
{
271-
itemprop.Value = Opc.Da.euType.noEnum;
234+
_itemProperty.Value = Opc.Da.euType.noEnum;
272235
// this property contains vale from enum: Opc.Da.euType
273236
foreach (Opc.Da.euType NEWeuType in Enum.GetValues(typeof(Opc.Da.euType)))
274237
{
275238
if (NEWeuType.ToString() == row_property.Value)
276-
itemprop.Value = NEWeuType;
239+
_itemProperty.Value = NEWeuType;
277240
}
278241
}
279242
if (prop_dsc.ID == Opc.Da.Property.EUINFO)
280243
{
281-
//I assume that this is table of strings splited by ;
282-
itemprop.Value = row_property.Value.Split(';');
244+
//I assume that this is table of strings spited by ;
245+
_itemProperty.Value = row_property.Value.Split(';');
283246
}
284-
itemPropertyCollection.Add(itemprop);
247+
itemPropertyCollection.Add(_itemProperty);
285248
}
286249
}
287250
catch (Exception ex)
@@ -301,20 +264,11 @@ internal Tag
301264
"Problem with many properties for item : " + myDSC.Name + ": " +
302265
TraceEvent.GetMessageWithExceptionNameFromExceptionIncludingInnerException(ex));
303266
}
304-
#endif
305267
}
306268
#endregion PUBLIC
307269

308270
}//Tag
309271

310-
#if OPCCLIENT
311-
internal virtual bool UpdateAllTags(ReadValue val)
312-
{
313-
for (ushort idx = 0; (idx < mylength); idx++)
314-
if ( ! tagHendlers[idx].UpdateTag( val[idx]) ) return false;
315-
return true;
316-
}
317-
#elif COMMSERVER
318272
internal virtual void UpdateAllTags(IReadValue val)
319273
{
320274
for (ushort idx = 0; (idx < mylength); idx++)
@@ -331,7 +285,6 @@ internal virtual void UpdateAllTags(IReadValue val)
331285
}
332286
}
333287
}
334-
#endif
335288

336289
/// <summary>
337290
/// Initializes a new instance of the <see cref="DataBlock"/> class.
@@ -358,7 +311,7 @@ internal DataBlock(ComunicationNet.DataBlocksRow myRow, IDataWrite myWriteInt, I
358311
/// </returns>
359312
public override string ToString()
360313
{
361-
return String.Format("{0}: startaddress={1}; datatype={2}; length={3};", base.ToString(),
314+
return String.Format("{0}: start address={1}; data type={2}; length={3};", base.ToString(),
362315
myStartAddress, myDataType, mylength);
363316
}
364317
#endregion PUBLIC

ProtocolHub.Communication/BaseStation/Interface.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@
1313
// http://www.cas.eu
1414
//_______________________________________________________________
1515

16+
using CAS.CommServer.ProtocolHub.MonitorInterface;
1617
using CAS.Lib.CommonBus.ApplicationLayer;
17-
using CAS.Lib.CommServerConsoleInterface;
1818
using CAS.Lib.RTLib.Processes;
1919
using CAS.NetworkConfigLib;
20-
using Statistics = global::BaseStation.Management.Statistics;
2120

2221
namespace CAS.CommServer.ProtocolHub.Communication.BaseStation
2322
{

ProtocolHub.Communication/BaseStation/Pipe.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
//_______________________________________________________________
1515

1616
using CAS.CommServer.ProtocolHub.Communication.LicenseControl;
17+
using CAS.CommServer.ProtocolHub.MonitorInterface;
1718
using CAS.Lib.CommonBus.ApplicationLayer;
18-
using CAS.Lib.CommServerConsoleInterface;
1919
using CAS.Lib.RTLib.Processes;
2020
using CAS.NetworkConfigLib;
2121
using System;

ProtocolHub.Communication/BaseStation/Segment.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ internal Segment(IApplicationLayerSniffer protocol)
155155
//_______________________________________________________________
156156

157157
using CAS.CommServer.ProtocolHub.Communication.LicenseControl;
158+
using CAS.CommServer.ProtocolHub.MonitorInterface;
158159
using CAS.Lib.CommonBus.ApplicationLayer;
159-
using CAS.Lib.CommServerConsoleInterface;
160160
using CAS.Lib.RTLib.Processes;
161161
using CAS.NetworkConfigLib;
162162
using System;
@@ -287,9 +287,11 @@ internal SegmentWaitTimeList(Segment parent, InterfacesRowDSC[] interfacesList,
287287
}
288288
#endregion
289289
}//SegmentWaitTimeList
290+
290291
private ISegmentStatistics myStatistics;
291292
private SegmentWaitTimeList dataQueue;
292293
private void PickUpHandler() { }
294+
293295
#endregion
294296

295297
#region creator

0 commit comments

Comments
 (0)