import clr
clr.AddReference('Soti.Connect.SemanticEngine.Conversions')
from Soti.Connect.SemanticEngine.Conversions import Converter
import math

print("Loading GenericToEpsonSpeed Converter")
class GenericToEpsonSpeed(Converter):
    def Execute(self, args):
        if args is None or len(args) == 0 or args[0] is None:
            return None
        try:
            input_speed = float(args[0])
        except (ValueError, TypeError):
            return None
        level = int(math.floor((input_speed - 25.4) / 25.4 + 0.5)) + 1
        return max(1, min(level, 17))

plugin = GenericToEpsonSpeed("GenericToEpsonSpeed")
store.AddConverter(plugin)