mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
LC, BC: Fix save for update db 0.1.0.
This commit is contained in:
1 parent
d2e5eecf22
commit
19d9a29459
5 files changed
+43
-40
No files matched your search
@@ -35,14 +35,15 @@ logger = logging.getLogger()
|
||||
class Data(SQLSubModel):
|
||||
_sub_classes = []
|
||||
|
||||
def __init__(self, id: int = -1,
|
||||
def __init__(self, data0, data1,
|
||||
id: int = -1,
|
||||
types=[float, float],
|
||||
status=None):
|
||||
super(Data, self).__init__(id)
|
||||
self._status = status
|
||||
|
||||
self._types = types
|
||||
self._data = []
|
||||
self._data = [data0, data1]
|
||||
|
||||
@classmethod
|
||||
def _db_create(cls, execute, ext=""):
|
||||
@@ -133,11 +134,11 @@ class Data(SQLSubModel):
|
||||
data1 = bc._types[1](next(it))
|
||||
|
||||
nd = cls(
|
||||
data0, data1,
|
||||
id=pid,
|
||||
types=bc._types,
|
||||
status=data['status']
|
||||
)
|
||||
nd._data = [data0, data1]
|
||||
|
||||
new.append(nd)
|
||||
|
||||
@@ -150,12 +151,11 @@ class Data(SQLSubModel):
|
||||
data1 = self._db_format(str(self[1]))
|
||||
bc = data["bc"]
|
||||
|
||||
sql = (
|
||||
execute = (
|
||||
"INSERT INTO " +
|
||||
"boundary_condition_data(pamhyr_id, ind, data0, data1, bc) " +
|
||||
f"VALUES ({pid}, {ind}, '{data0}', {data1}, {bc._pamhyr_id})"
|
||||
)
|
||||
execute(sql)
|
||||
|
||||
def __getitem__(self, key):
|
||||
return self._types[key](self._data[key])
|
||||
@@ -309,6 +309,7 @@ class BoundaryCondition(SQLSubModel):
|
||||
|
||||
ind = 0
|
||||
for d in self._data:
|
||||
print(d)
|
||||
data["ind"] = ind
|
||||
|
||||
d._db_save(execute, data)
|
||||
@@ -343,7 +344,7 @@ class BoundaryCondition(SQLSubModel):
|
||||
@property
|
||||
def name(self):
|
||||
if self._name == "":
|
||||
return f"B{self.id + 1}"
|
||||
return f"B #{self.pamhyr_id}"
|
||||
|
||||
return self._name
|
||||
|
||||
@@ -408,10 +409,10 @@ class BoundaryCondition(SQLSubModel):
|
||||
new_0 = self._types[0](data[0].replace(",", "."))
|
||||
new_1 = self._types[1](data[1].replace(",", "."))
|
||||
|
||||
return (new_0, new_1)
|
||||
return Data(new_0, new_1)
|
||||
|
||||
def add(self, index: int):
|
||||
value = (self._default_0, self._default_1)
|
||||
value = Data(self._default_0, self._default_1)
|
||||
self._data.insert(index, value)
|
||||
self._status.modified()
|
||||
return value
|
||||
@@ -461,9 +462,9 @@ class BoundaryCondition(SQLSubModel):
|
||||
return lst
|
||||
|
||||
def _set_i_c_v(self, index, column, value):
|
||||
v = list(self._data[index])
|
||||
v = self._data[index]
|
||||
v[column] = self._types[column](value)
|
||||
self._data[index] = tuple(v)
|
||||
self._data[index] = v
|
||||
self._status.modified()
|
||||
|
||||
def set_i_0(self, index: int, value):
|
||||
|
||||
Reference in new issue
Block a user