| 27 | |
| 28 | |
| 29 | class FitCapacitorGraph(FitGraph): |
| 30 | # UI stuff |
| 31 | internalName = 'capacitorGraph' |
| 32 | name = _t('Capacitor') |
| 33 | xDefs = [ |
| 34 | XDef(handle='time', unit='s', label=_t('Time'), mainInput=('time', 's')), |
| 35 | XDef(handle='capAmount', unit='GJ', label=_t('Cap amount'), mainInput=('capAmount', '%')), |
| 36 | XDef(handle='capAmount', unit='%', label=_t('Cap amount'), mainInput=('capAmount', '%'))] |
| 37 | yDefs = [ |
| 38 | YDef(handle='capAmount', unit='GJ', label=_t('Cap amount')), |
| 39 | YDef(handle='capRegen', unit='GJ/s', label=_t('Cap regen'))] |
| 40 | inputs = [ |
| 41 | Input(handle='time', unit='s', label=_t('Time'), iconID=1392, defaultValue=120, defaultRange=(0, 300), conditions=[ |
| 42 | (('time', 's'), None)]), |
| 43 | Input(handle='capAmount', unit='%', label=_t('Cap amount'), iconID=1668, defaultValue=25, defaultRange=(0, 100), conditions=[ |
| 44 | (('capAmount', 'GJ'), None), |
| 45 | (('capAmount', '%'), None)]), |
| 46 | Input(handle='capAmountT0', unit='%', label=_t('Starting cap amount'), iconID=1668, defaultValue=100, defaultRange=(0, 100), conditions=[ |
| 47 | (('time', 's'), None)])] |
| 48 | checkboxes = [InputCheckbox(handle='useCapsim', label=_t('Use capacitor simulator'), defaultValue=True, conditions=[ |
| 49 | (('time', 's'), ('capAmount', 'GJ'))])] |
| 50 | srcExtraCols = ('CapAmount', 'CapTime') |
| 51 | |
| 52 | # Calculation stuff |
| 53 | _normalizers = { |
| 54 | ('capAmount', '%'): lambda v, src, tgt: v / 100 * src.item.ship.getModifiedItemAttr('capacitorCapacity'), |
| 55 | ('capAmountT0', '%'): lambda v, src, tgt: None if v is None else v / 100 * src.item.ship.getModifiedItemAttr('capacitorCapacity')} |
| 56 | _limiters = { |
| 57 | 'time': lambda src, tgt: (0, 3600), |
| 58 | 'capAmount': lambda src, tgt: (0, src.item.ship.getModifiedItemAttr('capacitorCapacity')), |
| 59 | 'capAmountT0': lambda src, tgt: (0, src.item.ship.getModifiedItemAttr('capacitorCapacity'))} |
| 60 | _getters = { |
| 61 | ('time', 'capAmount'): Time2CapAmountGetter, |
| 62 | ('time', 'capRegen'): Time2CapRegenGetter, |
| 63 | ('capAmount', 'capAmount'): CapAmount2CapAmountGetter, |
| 64 | ('capAmount', 'capRegen'): CapAmount2CapRegenGetter} |
| 65 | _denormalizers = {('capAmount', '%'): lambda v, src, tgt: v * 100 / src.item.ship.getModifiedItemAttr('capacitorCapacity')} |
nothing calls this directly
no test coverage detected