import json
from algorithmContract.contract import LoadAnalysisInput,Analysis



# JSON string representing the data contract
jsonString = '''
{
	"dataContractType": {
		"type": "analysisExecuteOrder",
		"version": "1.2.0"
	},
	"dataContract": {
		"autoOrManual": "automatic",
		"dataFilter": {
			"powerFarmID": "WOF01000002",
			"turbines": null,
			"dataBatchNum": "zhaoyuan_20240528",
			"beginTime": "2023-01-01 00:00:00",
			"endTime": "2024-12-31 23:59:59",
			"excludingMonths": [
				"2023-12",
				"2023-09"
			],
			"customFilter": {
				"valueWindSpeed": {
					"min": 3.0,
					"max": 25.0
				},
				"valuePitchAngle": {
					"min": 2,
					"max": null
				},
				"valueActivePower": {
					"min": 10,
					"max": 2500
				},
				"valueGeneratorSpeed": {
					"min": 10,
					"max": 2500
				}
			}
		},
		"configAnalysis": [
			{
				"package": "algorithm.temperatureLargeComponentsAnalyst",
				"className": "TemperatureLargeComponentsAnalyst",
				"methodName": "executeAnalysis",
				"scada": "minute"
			}
		],
		"graphSets": {
			"directDrive": {
				"generatorSpeed": {
					"step": 5,
					"min": 0,
					"max": 30
				},
				"generatorTorque": {
					"step": 10000,
					"min": 0,
					"max": 100000
				}
			},
			"indirectDrive": {
				"generatorSpeed": {
					"step": 200,
					"min": 1000,
					"max": 2000
				},
				"generatorTorque": {
					"step": 2000,
					"min": 0,
					"max": 12000
				}
			},
			"tsr": {
				"step": 5,
				"min": 0,
				"max": 30
			},
			"pitchAngle": {
				"step": 1,
				"min": -1,
				"max": 20
			},
			"activePower": {
				"step": 250,
				"min": 0,
				"max": 2000
			}
		}
	}
}
'''


data=LoadAnalysisInput(jsonString)

print(data.dataContract.graphSets["directDrive"]["generatorSpeed"].step)
print(data.dataContract.graphSets["directDrive"]["generatorTorque"].step)

string=Analysis(data)
print(string)



