Skip to content

Commit

Permalink
common: Added new Cable channel derived from cDatarateChannel.
Browse files Browse the repository at this point in the history
This channel updates the line style based on whether the channel is disabled/enabled.
  • Loading branch information
levy committed Feb 16, 2024
1 parent edaf438 commit bf7f21b
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/inet/common/Cable.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// Copyright (C) 2013 OpenSim Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later
//

#include "inet/common/Cable.h"

namespace inet {

Define_Channel(Cable);

void Cable::initialize()
{
cDatarateChannel::initialize();
enabledLineStyle = par("enabledLineStyle");
disabledLineStyle = par("disabledLineStyle");
}

void Cable::refreshDisplay() const
{
cDatarateChannel::refreshDisplay();
getDisplayString().setTagArg("ls", 2, isDisabled() ? disabledLineStyle : enabledLineStyle);
}

} // namespace inet
28 changes: 28 additions & 0 deletions src/inet/common/Cable.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// Copyright (C) 2013 OpenSim Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later
//


#ifndef __INET_CABLE_H
#define __INET_CABLE_H

#include "inet/common/INETDefs.h"

namespace inet {

class INET_API Cable : public cDatarateChannel
{
protected:
const char *enabledLineStyle = nullptr;
const char *disabledLineStyle = nullptr;

protected:
virtual void initialize() override;
virtual void refreshDisplay() const override;
};

} // namespace inet

#endif
18 changes: 18 additions & 0 deletions src/inet/common/Cable.ned
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// Copyright (C) 2020 OpenSim Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later
//


package inet.common;

import ned.DatarateChannel;

channel Cable extends DatarateChannel
{
parameters:
string enabledLineStyle = default("solid");
string disabledLineStyle = default("dashed");
@class(Cable);
}

0 comments on commit bf7f21b

Please sign in to comment.