001// Copyright (c) FIRST and other WPILib contributors. 002// Open Source Software; you can modify and/or share it under the terms of 003// the WPILib BSD license file in the root directory of this project. 004 005package edu.wpi.first.networktables; 006 007/** NetworkTables publish/subscribe options. */ 008@SuppressWarnings("MemberName") 009public class PubSubOptions { 010 /** 011 * Construct from a list of options. 012 * 013 * @param options options 014 */ 015 public PubSubOptions(PubSubOption... options) { 016 for (PubSubOption option : options) { 017 switch (option.m_kind) { 018 case periodic: 019 periodic = option.m_dValue; 020 break; 021 case sendAll: 022 sendAll = option.m_bValue; 023 break; 024 case topicsOnly: 025 topicsOnly = option.m_bValue; 026 break; 027 case pollStorage: 028 pollStorage = option.m_iValue; 029 break; 030 case keepDuplicates: 031 keepDuplicates = option.m_bValue; 032 break; 033 case disableRemote: 034 disableRemote = option.m_bValue; 035 break; 036 case disableLocal: 037 disableLocal = option.m_bValue; 038 break; 039 case excludePublisher: 040 excludePublisher = option.m_iValue; 041 break; 042 case excludeSelf: 043 excludeSelf = option.m_bValue; 044 break; 045 case hidden: 046 hidden = option.m_bValue; 047 break; 048 default: 049 break; 050 } 051 } 052 } 053 054 PubSubOptions( 055 int pollStorage, 056 double periodic, 057 int excludePublisher, 058 boolean sendAll, 059 boolean topicsOnly, 060 boolean keepDuplicates, 061 boolean prefixMatch, 062 boolean disableRemote, 063 boolean disableLocal, 064 boolean excludeSelf, 065 boolean hidden) { 066 this.pollStorage = pollStorage; 067 this.periodic = periodic; 068 this.excludePublisher = excludePublisher; 069 this.sendAll = sendAll; 070 this.topicsOnly = topicsOnly; 071 this.keepDuplicates = keepDuplicates; 072 this.prefixMatch = prefixMatch; 073 this.disableRemote = disableRemote; 074 this.disableLocal = disableLocal; 075 this.excludeSelf = excludeSelf; 076 this.hidden = hidden; 077 } 078 079 /** Default value of periodic. */ 080 public static final double kDefaultPeriodic = 0.1; 081 082 /** 083 * Polling storage size for a subscription. Specifies the maximum number of updates NetworkTables 084 * should store between calls to the subscriber's readQueue() function. If zero, defaults to 1 if 085 * sendAll is false, 20 if sendAll is true. 086 */ 087 public int pollStorage; 088 089 /** 090 * How frequently changes will be sent over the network, in seconds. NetworkTables may send more 091 * frequently than this (e.g. use a combined minimum period for all values) or apply a restricted 092 * range to this value. The default is 100 ms. 093 */ 094 public double periodic = kDefaultPeriodic; 095 096 /** 097 * For subscriptions, if non-zero, value updates for readQueue() are not queued for this 098 * publisher. 099 */ 100 public int excludePublisher; 101 102 /** Send all value changes over the network. */ 103 public boolean sendAll; 104 105 /** For subscriptions, don't ask for value changes (only topic announcements). */ 106 public boolean topicsOnly; 107 108 /** Preserve duplicate value changes (rather than ignoring them). */ 109 public boolean keepDuplicates; 110 111 /** 112 * Perform prefix match on subscriber topic names. Is ignored/overridden by subscribe() functions; 113 * only present in struct for the purposes of getting information about subscriptions. 114 */ 115 public boolean prefixMatch; 116 117 /** 118 * For subscriptions, if remote value updates should not be queued for readQueue(). See also 119 * disableLocal. 120 */ 121 public boolean disableRemote; 122 123 /** 124 * For subscriptions, if local value updates should not be queued for readQueue(). See also 125 * disableRemote. 126 */ 127 public boolean disableLocal; 128 129 /** For entries, don't queue (for readQueue) value updates for the entry's internal publisher. */ 130 public boolean excludeSelf; 131 132 /** 133 * For subscriptions, don't share the existence of the subscription with the network. Note this 134 * means updates will not be received from the network unless another subscription overlaps with 135 * this one, and the subscription will not appear in metatopics. 136 */ 137 public boolean hidden; 138}