Skip to content

Commit

Permalink
#1016 - new module setup
Browse files Browse the repository at this point in the history
  • Loading branch information
jecollins committed Apr 16, 2019
1 parent ed44c39 commit 333efd8
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 12 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -2,6 +2,7 @@

Core modules needed for both broker and server:

- [metadata](metadata/README.md)
- [aop](aop/README.md)
- [common](common/README.md)
- [broker-core](broker-core/README.md)
Expand Down
Expand Up @@ -28,7 +28,7 @@
*
* @author John Collins
*/
@Domain(fields = {"postedTimeslot", "KWh", "charge"})
@Domain(fields = {"postedTimeslot", "kWh", "charge"})
@XStreamAlias("balance-tx")
public class BalancingTransaction extends BrokerTransaction
{
Expand Down
33 changes: 23 additions & 10 deletions common/src/main/java/org/powertac/common/TariffSpecification.java
Expand Up @@ -54,17 +54,14 @@
*
* @author John Collins
*/
@Domain(fields = {"broker", "powerType", "minDuration",
"signupPayment", "earlyWithdrawPayment", "periodicPayment",
@Domain(fields = {"broker", "powerType", "minDuration", "signupPayment",
"earlyWithdrawPayment", "periodicPayment", "expiration",
"supersedes"})
@XStreamAlias("tariff-spec")
public class TariffSpecification extends TariffMessage
{
static private Logger log = LogManager.getLogger(TariffSpecification.class);

/** Last date new subscriptions will be accepted. Null means never expire. */
private Instant expiration = null;

/** Minimum contract duration (in milliseconds) */
@XStreamAsAttribute
private long minDuration = 0l;
Expand All @@ -87,13 +84,18 @@ public class TariffSpecification extends TariffMessage
@XStreamAsAttribute
private double periodicPayment = 0.0;

/** Last date, in msec past epoch, that new subscriptions will be accepted.
* Zero means never expire. */
@XStreamAsAttribute
private long expiration = 0l;

private List<RateCore> rates;

private List<Long> supersedes;

/**
* Creates a new TariffSpecification for a broker and a specific powerType.
* Attributes are provided by the fluent {@code withX() methods}.
* Attributes are provided by the fluent {@code withX()} methods.
*/
public TariffSpecification (Broker broker, PowerType powerType)
{
Expand All @@ -110,20 +112,31 @@ public PowerType getPowerType ()

public Instant getExpiration ()
{
return expiration;
if (expiration > 0)
return new Instant(expiration);
else
return null;
}

/**
* Sets the expiration date for this tariff. After this date, customers
* will no longer be allowed to subscribe.
* Sets expiration date as msec since epoch. See Issue #1016.
*/
@StateChange
public TariffSpecification withExpiration (Instant expiration)
public TariffSpecification withExpiration (long expiration)
{
this.expiration = expiration;
return this;
}

/**
* Sets the expiration date for this tariff. After this date, customers
* will no longer be allowed to subscribe.
*/
public TariffSpecification withExpiration (Instant expiration)
{
return this.withExpiration(expiration.getMillis());
}

public long getMinDuration ()
{
return minDuration;
Expand Down
Expand Up @@ -199,7 +199,7 @@ public void testXmlSerialization ()
xstream.autodetectAnnotations(true);
StringWriter serialized = new StringWriter();
serialized.write(xstream.toXML(spec));
System.out.println(serialized.toString());
//System.out.println(serialized.toString());
TariffSpecification xspec= (TariffSpecification)xstream.fromXML(serialized.toString());
assertNotNull(xspec, "deserialized something");
//assertEquals(spec, xspec, "correct match");
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Expand Up @@ -24,6 +24,7 @@

<!-- Core components -->
<modules>
<module>powertac-metadata</module>
<module>powertac-aop</module>
<module>common</module>
<module>broker-core</module>
Expand Down
121 changes: 121 additions & 0 deletions powertac-metadata/pom.xml
@@ -0,0 +1,121 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<artifactId>powertac-metadata</artifactId>
<packaging>jar</packaging>

<name>Power TAC logfile metadata generator</name>
<description>Analyzes @Domain annotations, record state log format</description>
<url>https://github.com/powertac/powertac-core/</url>

<parent>
<groupId>org.powertac</groupId>
<artifactId>powertac-parent</artifactId>
<version>1.7.0-SNAPSHOT</version>
</parent>


<dependencies>

<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>


<!-- Testing -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</dependency>

<!-- Logging -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>

</dependencies>


<build>

<plugins>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<compilerArgs>-proc:none</compilerArgs>
</configuration>
</plugins>

</build>


<issueManagement>
<system>github</system>
<url>https://github.com/powertac/powertac-server/issues/</url>
</issueManagement>


<licenses>
<license>
<name>Apache 2</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
<comments>A business-friendly OSS license</comments>
</license>
</licenses>


<developers>

<developer>
<id>john</id>
<name>John Collins</name>
<email>jcollins.cs@gmail.com</email>
<url>http://www.cs.umn.edu/~jcollins/</url>
<organization>University of Minnesota</organization>
<roles>
<role>game designer</role>
<role>architect</role>
<role>project manager</role>
<role>developer</role>
</roles>
<timezone>-6</timezone>
</developer>

<developer>
<id>wolf</id>
<name>Wolf Ketter</name>
<email>wolf.ketter@gmail.com</email>
<url>http://ketter.ws/</url>
<organization>Rotterdam School of Management, Erasmus University</organization>
<roles>
<role>project leader</role>
<role>game designer</role>
</roles>
<timezone>+1</timezone>
</developer>

</developers>


<scm>
<connection>scm:git:git//github.com/powertac/powertac-core.git</connection>
<developerConnection>scm:git:git@github.com:powertac/powertac-core.git</developerConnection>
<url>https://github.com/powertac/powertac-core/</url>
<tag>HEAD</tag>
</scm>


</project>

0 comments on commit 333efd8

Please sign in to comment.